Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 075469d2 authored by Sonny Sasaka's avatar Sonny Sasaka
Browse files

Floss: Extend OnScannerRegistered to include UUID

Clients need to distinguish which scanner the OnScannerRegistered
message is for.

Bug: 217273154
Tag: #floss
Test: Manual - Ran with btclient

Change-Id: I126ef61a1dc201534008333c7105ce64c195d1a7
parent 01e2e6a8
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ use crate::dbus_iface::{
};
use crate::ClientContext;
use crate::{console_red, console_yellow, print_error, print_info};
use bt_topshim::btif::{BtBondState, BtPropertyType, BtSspVariant};
use bt_topshim::btif::{BtBondState, BtPropertyType, BtSspVariant, Uuid128Bit};
use bt_topshim::profiles::gatt::GattStatus;
use btstack::bluetooth::{
    BluetoothDevice, IBluetooth, IBluetoothCallback, IBluetoothConnectionCallback,
@@ -14,6 +14,7 @@ use btstack::bluetooth_gatt::{
    BluetoothGattService, IBluetoothGattCallback, IScannerCallback, LePhy,
};
use btstack::suspend::ISuspendCallback;
use btstack::uuid::UuidWrapper;
use btstack::RPCProxy;
use dbus::nonblock::SyncConnection;
use dbus_crossroads::Crossroads;
@@ -315,13 +316,17 @@ impl ScannerCallback {
}

impl IScannerCallback for ScannerCallback {
    fn on_scanner_registered(&self, status: u8, scanner_id: u8) {
    fn on_scanner_registered(&self, uuid: Uuid128Bit, status: u8, scanner_id: u8) {
        if status != 0 {
            print_error!("Failed registering scanner, status = {}", status);
            return;
        }

        print_info!("Scanner callback registered, id = {}", scanner_id);
        print_info!(
            "Scanner callback registered, uuid = {}, id = {}",
            UuidWrapper(&uuid),
            scanner_id
        );
    }
}

+1 −1
Original line number Diff line number Diff line
@@ -207,7 +207,7 @@ impl RPCProxy for IScannerCallbackDBus {
)]
impl IScannerCallback for IScannerCallbackDBus {
    #[dbus_method("OnScannerRegistered")]
    fn on_scanner_registered(&self, status: u8, scanner_id: u8) {}
    fn on_scanner_registered(&self, uuid: Uuid128Bit, status: u8, scanner_id: u8) {}
}

// Implements RPC-friendly wrapper methods for calling IBluetooth, generated by
+1 −1
Original line number Diff line number Diff line
@@ -142,7 +142,7 @@ struct ScannerCallbackDBus {}
#[dbus_proxy_obj(ScannerCallback, "org.chromium.bluetooth.ScannerCallback")]
impl IScannerCallback for ScannerCallbackDBus {
    #[dbus_method("OnScannerRegistered")]
    fn on_scanner_registered(&self, status: u8, scanner_id: u8) {
    fn on_scanner_registered(&self, uuid: Uuid128Bit, status: u8, scanner_id: u8) {
        dbus_generated!()
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -420,7 +420,7 @@ pub trait IBluetoothGattCallback: RPCProxy {
/// `IBluetoothGatt::register_scanner_callback`.
pub trait IScannerCallback: RPCProxy {
    /// When the `register_scanner` request is done.
    fn on_scanner_registered(&self, status: u8, scanner_id: u8);
    fn on_scanner_registered(&self, uuid: Uuid128Bit, status: u8, scanner_id: u8);
}

#[derive(Debug, FromPrimitive, ToPrimitive)]
@@ -1485,7 +1485,7 @@ impl BtifGattScannerCallbacks for BluetoothGatt {
            info.scanner_id = Some(scanner_id);
            let callback = self.scanner_callbacks.get_by_id(info.callback_id);
            if let Some(cb) = callback {
                cb.on_scanner_registered(status, scanner_id);
                cb.on_scanner_registered(uuid.uu, status, scanner_id);
            } else {
                log::warn!("There is no callback for scanner UUID {}", uuid);
            }