mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-17 09:14:32 +08:00
monitor: Simplify advertising report parsing to single-reports
This commit is contained in:
parent
843447dcc2
commit
0c1145e4c3
10
monitor/bt.h
10
monitor/bt.h
@ -1249,7 +1249,9 @@ struct bt_hci_evt_le_conn_complete {
|
||||
uint8_t clock_accuracy;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct bt_hci_adv_data {
|
||||
#define BT_HCI_EVT_LE_ADV_REPORT 0x02
|
||||
struct bt_hci_evt_le_adv_report {
|
||||
uint8_t num_reports;
|
||||
uint8_t event_type;
|
||||
uint8_t addr_type;
|
||||
uint8_t addr[6];
|
||||
@ -1257,12 +1259,6 @@ struct bt_hci_adv_data {
|
||||
uint8_t data[0];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define BT_HCI_EVT_LE_ADV_REPORT 0x02
|
||||
struct bt_hci_evt_le_adv_report {
|
||||
uint8_t num_reports;
|
||||
uint8_t reports[0];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define BT_HCI_EVT_LE_CONN_UPDATE_COMPLETE 0x03
|
||||
struct bt_hci_evt_le_conn_update_complete {
|
||||
uint8_t status;
|
||||
|
@ -3861,59 +3861,46 @@ static void le_conn_complete_evt(const void *data, uint8_t size)
|
||||
static void le_adv_report_evt(const void *data, uint8_t size)
|
||||
{
|
||||
const struct bt_hci_evt_le_adv_report *evt = data;
|
||||
uint8_t data_left;
|
||||
const char *str;
|
||||
const void *ptr;
|
||||
uint8_t num_reports;
|
||||
const int8_t *rssi;
|
||||
uint8_t evt_len;
|
||||
int8_t *rssi;
|
||||
|
||||
print_num_reports(evt->num_reports);
|
||||
|
||||
data_left = size - sizeof(*evt);
|
||||
ptr = evt->reports;
|
||||
num_reports = evt->num_reports;
|
||||
|
||||
while (data_left > sizeof(struct bt_hci_adv_data) && num_reports > 0) {
|
||||
const struct bt_hci_adv_data *adv = ptr;
|
||||
size_t adv_len = sizeof(*adv) + adv->data_len + 1;
|
||||
|
||||
switch (adv->event_type) {
|
||||
case 0x00:
|
||||
str = "Connectable undirected - ADV_IND";
|
||||
break;
|
||||
case 0x01:
|
||||
str = "Connectable directed - ADV_DIRECT_IND";
|
||||
break;
|
||||
case 0x02:
|
||||
str = "Scannable undirected - ADV_SCAN_IND";
|
||||
break;
|
||||
case 0x03:
|
||||
str = "Non connectable undirected - ADV_NONCONN_IND";
|
||||
break;
|
||||
case 0x04:
|
||||
str = "Scan response - SCAN_RSP";
|
||||
break;
|
||||
default:
|
||||
str = "Reserved";
|
||||
break;
|
||||
}
|
||||
|
||||
print_field("Event type: %s (0x%2.2x)", str, adv->event_type);
|
||||
print_addr_type("Address type", adv->addr_type);
|
||||
print_addr(adv->addr, adv->addr_type);
|
||||
print_field("Data length: %d", adv->data_len);
|
||||
print_eir(adv->data, adv->data_len, true);
|
||||
|
||||
rssi = ptr + (adv_len - 1);
|
||||
print_rssi(*rssi);
|
||||
|
||||
ptr += adv_len;
|
||||
data_left -= adv_len;
|
||||
num_reports--;
|
||||
switch (evt->event_type) {
|
||||
case 0x00:
|
||||
str = "Connectable undirected - ADV_IND";
|
||||
break;
|
||||
case 0x01:
|
||||
str = "Connectable directed - ADV_DIRECT_IND";
|
||||
break;
|
||||
case 0x02:
|
||||
str = "Scannable undirected - ADV_SCAN_IND";
|
||||
break;
|
||||
case 0x03:
|
||||
str = "Non connectable undirected - ADV_NONCONN_IND";
|
||||
break;
|
||||
case 0x04:
|
||||
str = "Scan response - SCAN_RSP";
|
||||
break;
|
||||
default:
|
||||
str = "Reserved";
|
||||
break;
|
||||
}
|
||||
|
||||
if (data_left > 0)
|
||||
packet_hexdump(ptr, data_left);
|
||||
print_field("Event type: %s (0x%2.2x)", str, evt->event_type);
|
||||
print_addr_type("Address type", evt->addr_type);
|
||||
print_addr(evt->addr, evt->addr_type);
|
||||
print_field("Data length: %d", evt->data_len);
|
||||
print_eir(evt->data, evt->data_len, true);
|
||||
|
||||
rssi = (int8_t *) (evt->data + evt->data_len);
|
||||
print_rssi(*rssi);
|
||||
|
||||
evt_len = sizeof(*evt) + evt->data_len + 1;
|
||||
|
||||
if (size > evt_len)
|
||||
packet_hexdump(data + evt_len, size - evt_len);
|
||||
}
|
||||
|
||||
static void le_conn_update_complete_evt(const void *data, uint8_t size)
|
||||
|
Loading…
Reference in New Issue
Block a user