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

Commit f961902a authored by Ying Hsu's avatar Ying Hsu Committed by Abhishek Pandit-Subedi
Browse files

floss: changes data type of PHY for advertising to LePhy

This patch moves LePhy definition from stack to bt_btif::profiles::gatt
so that BLE advertising can align its PHY type to other interfaces.

Bug: 237346241
Tag: #floss
Test: build.py --target test
Test: `bclient advertise on` and check their type on dbus-monitor
Change-Id: I1514aa73cc4a337e22921df03347dea6e24b5d79
parent e7f89ff7
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -7,13 +7,13 @@ use crate::dbus_iface::{
use crate::ClientContext;
use crate::{console_red, console_yellow, print_error, print_info};
use bt_topshim::btif::{BtBondState, BtPropertyType, BtSspVariant, BtStatus, Uuid128Bit};
use bt_topshim::profiles::gatt::GattStatus;
use bt_topshim::profiles::gatt::{GattStatus, LePhy};
use btstack::bluetooth::{
    BluetoothDevice, IBluetooth, IBluetoothCallback, IBluetoothConnectionCallback,
};
use btstack::bluetooth_adv::IAdvertisingSetCallback;
use btstack::bluetooth_gatt::{
    BluetoothGattService, IBluetoothGattCallback, IScannerCallback, LePhy, ScanResult,
    BluetoothGattService, IBluetoothGattCallback, IScannerCallback, ScanResult,
};
use btstack::socket_manager::{
    BluetoothServerSocket, BluetoothSocket, IBluetoothSocketManager,
+4 −3
Original line number Diff line number Diff line
@@ -6,9 +6,10 @@ use crate::callbacks::BtGattCallback;
use crate::ClientContext;
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_adv::{AdvertiseData, AdvertisingSetParameters};
use btstack::bluetooth_gatt::{IBluetoothGatt, LePhy, RSSISettings, ScanSettings, ScanType};
use btstack::bluetooth_gatt::{IBluetoothGatt, RSSISettings, ScanSettings, ScanType};
use btstack::socket_manager::{IBluetoothSocketManager, SocketResult};
use btstack::uuid::{Profile, UuidHelper, UuidWrapper};
use manager_service::iface_bluetooth_manager::IBluetoothManager;
@@ -924,8 +925,8 @@ impl CommandHandler {
                    is_legacy: true,
                    is_anonymous: false,
                    include_tx_power: true,
                    primary_phy: 1,
                    secondary_phy: 1,
                    primary_phy: LePhy::Phy1m,
                    secondary_phy: LePhy::Phy1m,
                    interval: 160,
                    tx_power_level: -21,
                    own_address_type: 0, // random
+4 −4
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ use bt_topshim::btif::{
    BtBondState, BtConnectionState, BtDeviceType, BtPropertyType, BtSspVariant, BtStatus,
    BtTransport, Uuid, Uuid128Bit,
};
use bt_topshim::profiles::gatt::GattStatus;
use bt_topshim::profiles::gatt::{GattStatus, LePhy};
use bt_topshim::profiles::socket::SocketType;

use btstack::bluetooth::{
@@ -16,7 +16,7 @@ use btstack::bluetooth_adv::{
use btstack::bluetooth_gatt::{
    BluetoothGattCharacteristic, BluetoothGattDescriptor, BluetoothGattService,
    GattWriteRequestStatus, GattWriteType, IBluetoothGatt, IBluetoothGattCallback,
    IScannerCallback, LePhy, RSSISettings, ScanFilter, ScanResult, ScanSettings, ScanType,
    IScannerCallback, RSSISettings, ScanFilter, ScanResult, ScanSettings, ScanType,
};
use btstack::socket_manager::{
    BluetoothServerSocket, BluetoothSocket, CallbackId, IBluetoothSocketManager,
@@ -699,8 +699,8 @@ struct AdvertisingSetParametersDBus {
    is_legacy: bool,
    is_anonymous: bool,
    include_tx_power: bool,
    primary_phy: i32,
    secondary_phy: i32,
    primary_phy: LePhy,
    secondary_phy: LePhy,
    interval: i32,
    tx_power_level: i32,
    own_address_type: i32,
+4 −5
Original line number Diff line number Diff line
use bt_topshim::profiles::gatt::GattStatus;

use bt_topshim::btif::{BtStatus, BtTransport, Uuid128Bit};
use bt_topshim::profiles::gatt::{GattStatus, LePhy};

use btstack::bluetooth_adv::{
    AdvertiseData, AdvertisingSetParameters, IAdvertisingSetCallback, PeriodicAdvertisingParameters,
@@ -8,7 +7,7 @@ use btstack::bluetooth_adv::{
use btstack::bluetooth_gatt::{
    BluetoothGattCharacteristic, BluetoothGattDescriptor, BluetoothGattService,
    GattWriteRequestStatus, GattWriteType, IBluetoothGatt, IBluetoothGattCallback,
    IScannerCallback, LePhy, RSSISettings, ScanFilter, ScanResult, ScanSettings, ScanType,
    IScannerCallback, RSSISettings, ScanFilter, ScanResult, ScanSettings, ScanType,
};
use btstack::{RPCProxy, SuspendMode};

@@ -318,8 +317,8 @@ struct AdvertisingSetParametersDBus {
    is_legacy: bool,
    is_anonymous: bool,
    include_tx_power: bool,
    primary_phy: i32,
    secondary_phy: i32,
    primary_phy: LePhy,
    secondary_phy: LePhy,
    interval: i32,
    tx_power_level: i32,
    own_address_type: i32,
+5 −11
Original line number Diff line number Diff line
//! BLE Advertising types and utilities

use bt_topshim::profiles::gatt::{Gatt, GattStatus};
use bt_topshim::profiles::gatt::{Gatt, GattStatus, LePhy};

use log::warn;
use num_traits::clamp;
@@ -30,9 +30,9 @@ pub struct AdvertisingSetParameters {
    /// Whether the TX Power will be included.
    pub include_tx_power: bool,
    /// Primary advertising phy. Valid values are: 1 (1M), 2 (2M), 3 (Coded).
    pub primary_phy: i32,
    pub primary_phy: LePhy,
    /// Secondary advertising phy. Valid values are: 1 (1M), 2 (2M), 3 (Coded).
    pub secondary_phy: i32,
    pub secondary_phy: LePhy,
    /// The advertising interval. Bluetooth LE Advertising interval, in 0.625 ms unit.
    /// The valid range is from 160 (100 ms) to 16777215 (10485.759375 sec).
    /// Recommended values are: 160 (100 ms), 400 (250 ms), 1600 (1 sec).
@@ -145,10 +145,6 @@ const PERIODIC_INTERVAL_MAX: i32 = 65519; // 81.89875 sec
const PERIODIC_INTERVAL_MIN: i32 = 80; // 100 ms
const PERIODIC_INTERVAL_DELTA: i32 = 16; // 20 ms gap between min and max

// PHY range.
const PHY_MIN: i32 = 1;
const PHY_MAX: i32 = 3;

// Device name length.
const DEVICE_NAME_MAX: usize = 26;

@@ -185,8 +181,6 @@ impl Into<bt_topshim::profiles::gatt::AdvertiseParameters> for AdvertisingSetPar
        }

        let interval = clamp(self.interval, INTERVAL_MIN, INTERVAL_MAX - INTERVAL_DELTA);
        let primary_phy = clamp(self.primary_phy, PHY_MIN, PHY_MAX);
        let secondary_phy = clamp(self.secondary_phy, PHY_MIN, PHY_MAX);

        bt_topshim::profiles::gatt::AdvertiseParameters {
            advertising_event_properties: props,
@@ -194,8 +188,8 @@ impl Into<bt_topshim::profiles::gatt::AdvertiseParameters> for AdvertisingSetPar
            max_interval: (interval + INTERVAL_DELTA) as u32,
            channel_map: 0x07 as u8, // all channels
            tx_power: self.tx_power_level as i8,
            primary_advertising_phy: primary_phy as u8,
            secondary_advertising_phy: secondary_phy as u8,
            primary_advertising_phy: self.primary_phy.into(),
            secondary_advertising_phy: self.secondary_phy.into(),
            scan_request_notification_enable: 0 as u8, // false
            own_address_type: self.own_address_type as i8,
        }
Loading