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

Commit b10dfdbb authored by howardchung's avatar howardchung
Browse files

Floss: Match cod based on major and minor class

According to Spec: Assigned Numbers 2.8, we only need to compare major
and minor classes parts to know the device class. Putting higher bits
into consideration causes issues in some devices, for example, Bornd
C170B replies the device class as 0x2580, which makes it unable to be
recongnized as HID Pointing device.

Bug: 268730275
Test: pair with Bornd C170B
Change-Id: If8581c461da5af7c480aa9670b28ad0a6829470a
parent 081d4fb0
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -115,6 +115,10 @@ const Uuid UUID_BATTERY = Uuid::FromString("180F");
const Uuid UUID_A2DP_SINK = Uuid::FromString("110B");
const Uuid UUID_A2DP_SINK = Uuid::FromString("110B");


#define COD_UNCLASSIFIED ((0x1F) << 8)
#define COD_UNCLASSIFIED ((0x1F) << 8)

/* Focus on Major and minor device class*/
#define COD_DEVICE_MASK 0x1FFC

#define COD_HID_KEYBOARD 0x0540
#define COD_HID_KEYBOARD 0x0540
#define COD_HID_POINTING 0x0580
#define COD_HID_POINTING 0x0580
#define COD_HID_COMBO 0x05C0
#define COD_HID_COMBO 0x05C0
@@ -503,7 +507,7 @@ static uint32_t get_cod(const RawAddress* remote_bdaddr) {
}
}


bool check_cod(const RawAddress* remote_bdaddr, uint32_t cod) {
bool check_cod(const RawAddress* remote_bdaddr, uint32_t cod) {
  return get_cod(remote_bdaddr) == cod;
  return (get_cod(remote_bdaddr) & COD_DEVICE_MASK) == cod;
}
}


bool check_cod_hid(const RawAddress* remote_bdaddr) {
bool check_cod_hid(const RawAddress* remote_bdaddr) {