From 327754a953a87cd0efb6c0749025189faa5a7111 Mon Sep 17 00:00:00 2001 From: Glenn Ruben Bakke Date: Thu, 16 Mar 2017 22:46:26 +0100 Subject: [PATCH] nrf5/bluetooth: capture address type in addition to advertisment type in bluetooth advertisment reports. --- nrf5/bluetooth/ble_drv.c | 5 +++-- nrf5/bluetooth/ble_drv.h | 3 ++- nrf5/modules/ubluepy/ubluepy_scanner.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/nrf5/bluetooth/ble_drv.c b/nrf5/bluetooth/ble_drv.c index bdfb346572..071fd8d9ae 100644 --- a/nrf5/bluetooth/ble_drv.c +++ b/nrf5/bluetooth/ble_drv.c @@ -36,7 +36,7 @@ #include "ble.h" // sd_ble_uuid_encode -#define BLE_DRIVER_VERBOSE 0 +#define BLE_DRIVER_VERBOSE 1 #if BLE_DRIVER_VERBOSE #define BLE_DRIVER_LOG printf #else @@ -770,11 +770,12 @@ static void ble_evt_handler(ble_evt_t * p_ble_evt) { BLE_DRIVER_LOG("BLE EVT ADV REPORT\n"); ble_drv_adv_data_t adv_data = { .p_peer_addr = p_ble_evt->evt.gap_evt.params.adv_report.peer_addr.addr, + .addr_type = p_ble_evt->evt.gap_evt.params.adv_report.peer_addr.addr_type, .is_scan_resp = p_ble_evt->evt.gap_evt.params.adv_report.scan_rsp, .rssi = p_ble_evt->evt.gap_evt.params.adv_report.rssi, .data_len = p_ble_evt->evt.gap_evt.params.adv_report.dlen, .p_data = p_ble_evt->evt.gap_evt.params.adv_report.data, - .type = p_ble_evt->evt.gap_evt.params.adv_report.type + .adv_type = p_ble_evt->evt.gap_evt.params.adv_report.type }; // TODO: Fix unsafe callback to possible undefined callback... diff --git a/nrf5/bluetooth/ble_drv.h b/nrf5/bluetooth/ble_drv.h index a7d831911a..cf70fe1e34 100644 --- a/nrf5/bluetooth/ble_drv.h +++ b/nrf5/bluetooth/ble_drv.h @@ -34,11 +34,12 @@ typedef struct { uint8_t * p_peer_addr; + uint8_t addr_type; bool is_scan_resp; int8_t rssi; uint8_t data_len; uint8_t * p_data; - uint8_t type; + uint8_t adv_type; } ble_drv_adv_data_t; typedef void (*ble_drv_gap_evt_callback_t)(mp_obj_t self, uint16_t event_id, uint16_t conn_handle, uint16_t length, uint8_t * data); diff --git a/nrf5/modules/ubluepy/ubluepy_scanner.c b/nrf5/modules/ubluepy/ubluepy_scanner.c index e9faf2fe14..39e25b9edc 100644 --- a/nrf5/modules/ubluepy/ubluepy_scanner.c +++ b/nrf5/modules/ubluepy/ubluepy_scanner.c @@ -48,7 +48,7 @@ STATIC void adv_event_handler(mp_obj_t self_in, uint16_t event_id, ble_drv_adv_d item->addr[4] = data->p_peer_addr[1]; item->addr[5] = data->p_peer_addr[0]; - item->addr_type = data->type; + item->addr_type = data->addr_type; item->rssi = data->rssi; mp_obj_list_append(self->adv_reports, item);