extmod/modbluetooth: Change scan result's "connectable" to "adv_type".

This commit changes the BLE _IRQ_SCAN_RESULT data from:

    addr_type, addr, connectable, rssi, adv_data

to:

    addr_type, addr, adv_type, rssi, adv_data

This allows _IRQ_SCAN_RESULT to handle all scan result types (not just
connectable and non-connectable passive scans), and to distinguish between
them using adv_type which is an integer taking values 0x00-0x04 per the BT
specification.

This is a breaking change to the API, albeit a very minor one: the existing
connectable value was a boolean and True now becomes 0x00, False becomes
0x02.

Documentation is updated and a test added.

Fixes #5738.
This commit is contained in:
Damien George
2020-03-10 11:45:03 +11:00
parent bd746a4630
commit dd0bc26e65
7 changed files with 55 additions and 42 deletions

View File

@@ -115,11 +115,9 @@ STATIC void btstack_packet_handler(uint8_t packet_type, uint16_t channel, uint8_
int8_t rssi = gap_event_advertising_report_get_rssi(packet);
uint8_t length = gap_event_advertising_report_get_data_length(packet);
const uint8_t *data = gap_event_advertising_report_get_data(packet);
bool connectable = adv_event_type == 0 || adv_event_type == 1;
if (adv_event_type <= 2) {
mp_bluetooth_gap_on_scan_result(address_type, address, connectable, rssi, data, length);
} else if (adv_event_type == 4) {
// TODO: Scan response.
// Emit an event for all advertising types except SCAN_RSP.
if (adv_event_type < 4) {
mp_bluetooth_gap_on_scan_result(address_type, address, adv_event_type, rssi, data, length);
}
} else if (event_type == HCI_EVENT_DISCONNECTION_COMPLETE) {
DEBUG_EVENT_printf(" --> hci disconnect complete\n");