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

Commit 842164c3 authored by Sonny Sasaka's avatar Sonny Sasaka
Browse files

Floss: LE Scan API change: optional ScanFilter and u8 in ScanFilter

* Filter should be optional in StartScan to allow clients to do general
  LE scan.
* ScanFilter fields should be u8 to match the internal type in MSFT HCI
  extension.

Bug: 217274432
Tag: #floss
Test: Build Floss on Chrome OS and Linux

Change-Id: Iad9aa2c556fe94099f56462de81e6c027ea0145d
parent 8578044f
Loading
Loading
Loading
Loading
+2 −10
Original line number Diff line number Diff line
@@ -10,9 +10,7 @@ use crate::{console_red, console_yellow, print_error, print_info};
use bt_topshim::btif::{BtConnectionState, BtStatus, BtTransport};
use bt_topshim::profiles::gatt::LePhy;
use btstack::bluetooth::{BluetoothDevice, IBluetooth, IBluetoothQA};
use btstack::bluetooth_gatt::{
    IBluetoothGatt, ScanFilter, ScanFilterCondition, ScanSettings, ScanType,
};
use btstack::bluetooth_gatt::{IBluetoothGatt, ScanSettings, ScanType};
use btstack::socket_manager::{IBluetoothSocketManager, SocketResult};
use btstack::uuid::{Profile, UuidHelper, UuidWrapper};
use manager_service::iface_bluetooth_manager::IBluetoothManager;
@@ -977,13 +975,7 @@ impl CommandHandler {
                        id,
                        // TODO(b/217274432): Construct real settings and filters.
                        ScanSettings { interval: 0, window: 0, scan_type: ScanType::Active },
                        ScanFilter {
                            condition: ScanFilterCondition::Patterns(vec![]),
                            rssi_low_threshold: 0,
                            rssi_low_timeout: 0,
                            rssi_high_threshold: 0,
                            rssi_sampling_period: 0,
                        },
                        None,
                    );
                    self.context.lock().unwrap().active_scanner_ids.insert(id);
                } else {
+5 −5
Original line number Diff line number Diff line
@@ -231,10 +231,10 @@ impl DBusArg for ScanFilterCondition {

#[dbus_propmap(ScanFilter)]
struct ScanFilterDBus {
    rssi_high_threshold: i16,
    rssi_low_threshold: i16,
    rssi_low_timeout: u16,
    rssi_sampling_period: u16,
    rssi_high_threshold: u8,
    rssi_low_threshold: u8,
    rssi_low_timeout: u8,
    rssi_sampling_period: u8,
    condition: ScanFilterCondition,
}

@@ -996,7 +996,7 @@ impl IBluetoothGatt for BluetoothGattDBus {
        &mut self,
        _scanner_id: u8,
        _settings: ScanSettings,
        _filter: ScanFilter,
        _filter: Option<ScanFilter>,
    ) -> BtStatus {
        dbus_generated!()
    }
+5 −5
Original line number Diff line number Diff line
@@ -322,10 +322,10 @@ impl DBusArg for ScanFilterCondition {

#[dbus_propmap(ScanFilter)]
struct ScanFilterDBus {
    rssi_high_threshold: i16,
    rssi_low_threshold: i16,
    rssi_low_timeout: u16,
    rssi_sampling_period: u16,
    rssi_high_threshold: u8,
    rssi_low_threshold: u8,
    rssi_low_timeout: u8,
    rssi_sampling_period: u8,
    condition: ScanFilterCondition,
}

@@ -478,7 +478,7 @@ impl IBluetoothGatt for IBluetoothGattDBus {
        &mut self,
        scanner_id: u8,
        settings: ScanSettings,
        filter: ScanFilter,
        filter: Option<ScanFilter>,
    ) -> BtStatus {
        dbus_generated!()
    }
+6 −6
Original line number Diff line number Diff line
@@ -208,7 +208,7 @@ pub trait IBluetoothGatt {
        &mut self,
        scanner_id: u8,
        settings: ScanSettings,
        filter: ScanFilter,
        filter: Option<ScanFilter>,
    ) -> BtStatus;

    /// Deactivate scan of the given scanner id.
@@ -707,18 +707,18 @@ pub enum ScanFilterCondition {
#[derive(Debug)]
pub struct ScanFilter {
    /// Advertisements with RSSI above or equal this value is considered "found".
    pub rssi_high_threshold: i16,
    pub rssi_high_threshold: u8,

    /// Advertisements with RSSI below or equal this value (for a period of rssi_low_timeout) is
    /// considered "lost".
    pub rssi_low_threshold: i16,
    pub rssi_low_threshold: u8,

    /// The time in seconds over which the RSSI value should be below rssi_low_threshold before
    /// being considered "lost".
    pub rssi_low_timeout: u16,
    pub rssi_low_timeout: u8,

    /// The sampling interval in milliseconds.
    pub rssi_sampling_period: u16,
    pub rssi_sampling_period: u8,

    /// The condition to match advertisements with.
    pub condition: ScanFilterCondition,
@@ -1013,7 +1013,7 @@ impl IBluetoothGatt for BluetoothGatt {
        &mut self,
        scanner_id: u8,
        _settings: ScanSettings,
        _filter: ScanFilter,
        _filter: Option<ScanFilter>,
    ) -> BtStatus {
        // Multiplexing scanners happens at this layer. The implementations of start_scan
        // and stop_scan maintains the state of all registered scanners and based on the states