jonas-schievink / rubble

(going to be a) BLE stack for embedded Rust
BSD Zero Clause License
396 stars 56 forks source link

Remove flags, as they are not needed according to Bluetooth 4.2 specification #132

Closed elwerene closed 4 years ago

elwerene commented 4 years ago

Bluetooth specification 4.2:

9.2.2.2 Conditions
A device in the non-discoverable mode that sends advertising events shall not
set the ‘LE General Discoverable Mode’ flag or ‘LE Limited Discoverable Mode’
flag in the Flags AD type (see [Core Specification Supplement], Part A, Section
1.3). A Peripheral device in the non-connectable mode may send non-
connectable undirected advertising events or scannable undirected advertising
events or may not send advertising packets.

Sounds to me like sending no Flags AD is totally fine and correct (and saves 3 bytes).

jonas-schievink commented 4 years ago

That doesn't say that it is allowed to leave out the entire flags byte though. The flags structure also has a BR_EDR_NOT_SUPPORTED flag which we set. If that flag is required when classic BT is not supported, then we cannot leave out the flags.

jonas-schievink commented 4 years ago

Ah nevermind, the Core Specification Supplement says:

The Flags data type shall be included when any of the Flag bits are non-zero and the advertising packet is connectable, otherwise the Flags data type may be omitted.