Bluetooth: Implement advertising report meta event
Subsystems (2)
RFC v2 1/4 Bluetooth: Implement advertising report meta event
From: Anderson Briglia <[email protected]>
This patch implements new LE meta event in order to handle advertising reports.
--- include/net/bluetooth/hci.h | 18 ++++++++++++++++++ net/bluetooth/hci_event.c | 22 ++++++++++++++++++++++ 2 files changed, 40 insertions(+), 0 deletions(-)
include/net/bluetooth/hci.h +18 -0
@@ -980,6 +980,24 @@ struct hci_ev_le_conn_complete {__u8 clk_accurancy; } __packed; +#define ADV_IND 0x00 +#define ADV_DIRECT_IND 0x01 +#define ADV_SCAN_IND 0x02 +#define ADV_NONCONN_IND 0x03 +#define SCAN_RSP 0x04 + +#define ADDR_DEV_PUBLIC 0x00 +#define ADDR_DEV_RANDOM 0x01 + +#define HCI_EV_LE_ADVERTISING_REPORT 0x02 +struct hci_ev_le_advertising_info { +__u8 evt_type; +__u8 bdaddr_type; +bdaddr_t bdaddr; +__u8 length; +__u8 data[0 ]; +} __packed; +#define HCI_EV_LE_LTK_REQ 0x05struct hci_ev_le_ltk_req {__le16 handle;
net/bluetooth/hci_event.c +22 -0
@@ -2498,6 +2498,24 @@ static inline void hci_le_ltk_request_evt(struct hci_dev *hdev,hci_dev_unlock (hdev); } +static inline void hci_le_adv_report_evt (struct hci_dev *hdev, +struct sk_buff *skb) +{ +struct hci_ev_le_advertising_info *ev; +u8 num_reports, i; + + num_reports = skb->data[0 ]; + + ev = (void *) &skb->data[1 ]; + +BT_DBG ("adv from: %s" ,batostr (&ev->bdaddr)); + +for (i =1 ; i < num_reports; i++) { + ev = (void *) (ev->data + ev->length +1 ); +BT_DBG ("adv from: %s" ,batostr (&ev->bdaddr)); + } +} +static inline void hci_le_meta_evt (struct hci_dev *hdev,struct sk_buff *skb) {struct hci_ev_le_meta *le_ev = (void *) skb->data;
@@ -2513,6 +2531,10 @@ static inline void hci_le_meta_evt(struct hci_dev *hdev, struct sk_buff *skb)hci_le_ltk_request_evt (hdev, skb);break ; +case HCI_EV_LE_ADVERTISING_REPORT : +hci_le_adv_report_evt (hdev, skb); +break ; +default :break ; }
Signature · 1 line
1.7.1
Hi Briglia,
Quoted 16 lines · * [email protected] <[email protected]> [2011-02-17…
From: Anderson Briglia <[email protected]>
This patch implements new LE meta event in order to handle advertising reports.
Signed-off-by Anderson Briglia <[email protected]>--- include/net/bluetooth/hci.h | 18 ++++++++++++++++++ net/bluetooth/hci_event.c | 22 ++++++++++++++++++++++ 2 files changed, 40 insertions(+), 0 deletions(-)include/net/bluetooth/hci.h +0
-0
include/net/bluetooth/hci.h struct hci_ev_le_conn_complete { · line 987
Quoted 8 lines
include/net/bluetooth/hci.h +5
-0@@ -980,6 +980,24 @@ struct hci_ev_le_conn_complete {__u8 clk_accurancy; } __packed; +#define ADV_IND 0x00 +#define ADV_DIRECT_IND 0x01 +#define ADV_SCAN_IND 0x02 +#define ADV_NONCONN_IND 0x03 +#define SCAN_RSP 0x04
ADV_SCAN_RSP, maybe?
include/net/bluetooth/hci.h struct hci_ev_le_conn_complete { · line 990
Quoted 3 lines
include/net/bluetooth/hci.h +3
-0+ +#define ADDR_DEV_PUBLIC 0x00 +#define ADDR_DEV_RANDOM 0x01
ADDR_LE_ here.
Quoted 25 lines
include/net/bluetooth/hci.h +9
-0+ +#define HCI_EV_LE_ADVERTISING_REPORT 0x02 +struct hci_ev_le_advertising_info { +__u8 evt_type; +__u8 bdaddr_type; +bdaddr_t bdaddr; +__u8 length; +__u8 data[0 ]; +} __packed;#define HCI_EV_LE_LTK_REQ 0x05struct hci_ev_le_ltk_req {__le16 handle;net/bluetooth/hci_event.c +4
-0@@ -2498,6 +2498,24 @@ static inline void hci_le_ltk_request_evt(struct hci_dev *hdev,hci_dev_unlock (hdev); } +static inline void hci_le_adv_report_evt (struct hci_dev *hdev, +struct sk_buff *skb) +{ +struct hci_ev_le_advertising_info *ev;
net/bluetooth/hci_event.c static inline void hci_le_ltk_request_evt(struct hci_dev *hdev, · line 2514
Quoted 10 lines
net/bluetooth/hci_event.c +10
-0+u8 num_reports, i; + + num_reports = skb->data[0 ]; + + ev = (void *) &skb->data[1 ]; + +BT_DBG ("adv from: %s" ,batostr (&ev->bdaddr)); + +for (i =1 ; i < num_reports; i++) { + ev = (void *) (ev->data + ev->length +1 );
You are not using i anywhere here.
Signature · 2 lines
Gustavo F. Padovan http://profusion.mobi
Hi Gustavo,
Quoted 4 lines · Gustavo F. Padovan
Quoted 2 lines
+ for (i = 1; i <
num_reports; i++) {
+ ev = (void *) (ev->data+ev->length+ 1);You are not using i anywhere here.
It's used to iterate the for() itself, but it could be changed to e.g.:
while (--num_reports) {
...
}
It is pre-incremented to skip the first report as it was already processed outside the loop.
Regards,
Signature · 3 lines
Anderson Lizardo Instituto Nokia de Tecnologia - INdT Manaus - Brazil