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

Commit e7f89ff7 authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi
Browse files

floss: Refactor gatt client

Several refactors:
* Use BtTransport and LePhy enums where i32 was used before.
* Replace manual callback handling in gatt client.
* Properly handle gatt client disconnects.
* Refactor gatt client callback invocations and remove raw unwraps.

Bug: 193686564
Tag: #floss
Test: chrome-btclient does RegisterClient + ClientConnect
Change-Id: Ie1bdc1f6661aa9239a69c90239602da7151a83e3
parent 104d98ea
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ use crate::{console_red, console_yellow, print_error, print_info};
use bt_topshim::btif::{BtConnectionState, BtStatus, BtTransport};
use btstack::bluetooth::{BluetoothDevice, IBluetooth, IBluetoothQA};
use btstack::bluetooth_adv::{AdvertiseData, AdvertisingSetParameters};
use btstack::bluetooth_gatt::{IBluetoothGatt, RSSISettings, ScanSettings, ScanType};
use btstack::bluetooth_gatt::{IBluetoothGatt, LePhy, RSSISettings, ScanSettings, ScanType};
use btstack::socket_manager::{IBluetoothSocketManager, SocketResult};
use btstack::uuid::{Profile, UuidHelper, UuidWrapper};
use manager_service::iface_bluetooth_manager::IBluetoothManager;
@@ -718,9 +718,9 @@ impl CommandHandler {
                    client_id.unwrap(),
                    addr,
                    false,
                    2,
                    BtTransport::Le,
                    false,
                    1,
                    LePhy::Phy1m,
                );
            }
            "client-disconnect" => {
+2 −2
Original line number Diff line number Diff line
@@ -908,9 +908,9 @@ impl IBluetoothGatt for BluetoothGattDBus {
        client_id: i32,
        addr: String,
        is_direct: bool,
        transport: i32,
        transport: BtTransport,
        opportunistic: bool,
        phy: i32,
        phy: LePhy,
    ) {
        dbus_generated!()
    }
+3 −3
Original line number Diff line number Diff line
use bt_topshim::profiles::gatt::GattStatus;

use bt_topshim::btif::{BtStatus, Uuid128Bit};
use bt_topshim::btif::{BtStatus, BtTransport, Uuid128Bit};

use btstack::bluetooth_adv::{
    AdvertiseData, AdvertisingSetParameters, IAdvertisingSetCallback, PeriodicAdvertisingParameters,
@@ -502,9 +502,9 @@ impl IBluetoothGatt for IBluetoothGattDBus {
        client_id: i32,
        addr: String,
        is_direct: bool,
        transport: i32,
        transport: BtTransport,
        opportunistic: bool,
        phy: i32,
        phy: LePhy,
    ) {
        dbus_generated!()
    }
+315 −144

File changed.

Preview size limit exceeded, changes collapsed.

+5 −0
Original line number Diff line number Diff line
@@ -76,6 +76,8 @@ pub enum Message {

    SocketManagerActions(SocketActions),
    SocketManagerCallbackDisconnected(u32),

    GattClientCallbackDisconnected(u32),
}

/// Represents suspend mode of a module.
@@ -208,6 +210,9 @@ impl Stack {
                Message::SocketManagerCallbackDisconnected(id) => {
                    bluetooth_socketmgr.lock().unwrap().remove_callback(id);
                }
                Message::GattClientCallbackDisconnected(id) => {
                    bluetooth_gatt.lock().unwrap().remove_client_callback(id);
                }
            }
        }
    }