Bluetooth: Add mgmt_device_found event
Subsystems (2)
PATCH 1/2 Bluetooth: Add mgmt_device_found event
From: Johan Hedberg <[email protected]>
This patch adds a device_found event to the Management interface. For now the event only maps to BR/EDR inquiry result HCI events, but in the future the plan is to also use it for the LE device discovery process.
--- include/net/bluetooth/hci_core.h | 2 ++ include/net/bluetooth/mgmt.h | 8 ++++++++ net/bluetooth/hci_event.c | 22 ++++++++++++++-------- net/bluetooth/mgmt.c | 17 +++++++++++++++++ 4 files changed, 41 insertions(+), 8 deletions(-)
include/net/bluetooth/hci_core.h +2 -0
@@ -787,6 +787,8 @@ int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status);int mgmt_set_local_name_complete (u16 index,u8 *name,u8 status);int mgmt_read_local_oob_data_reply_complete (u16 index,u8 *hash,u8 *randomizer,u8 status); +int mgmt_device_found (u16 index,bdaddr_t *bdaddr,u8 *dev_class,s8 rssi, +u8 *eir);/* HCI info for socket */ #define hci_pi (sk) ((struct hci_pinfo *) sk)
include/net/bluetooth/mgmt.h +8 -0
@@ -267,3 +267,11 @@ struct mgmt_ev_auth_failed {struct mgmt_ev_local_name_changed {__u8 name[MGMT_MAX_NAME_LENGTH ]; } __packed; + +#define MGMT_EV_DEVICE_FOUND 0x0012 +struct mgmt_ev_device_found { +bdaddr_t bdaddr; +__u8 dev_class[3 ]; +__s8 rssi; +__u8 eir[HCI_MAX_EIR_LENGTH ]; +} __packed;
net/bluetooth/hci_event.c +14 -8
@@ -1226,7 +1226,7 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *hci_dev_lock (hdev); -for (; num_rsp; num_rsp--) { +for (; num_rsp; num_rsp--, info++) {bacpy (&data.bdaddr, &info->bdaddr); data.pscan_rep_mode = info->pscan_rep_mode; data.pscan_period_mode = info->pscan_period_mode;
@@ -1235,8 +1235,9 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * data.clock_offset = info->clock_offset; data.rssi =0x00 ; data.ssp_mode =0x00 ; - info++;hci_inquiry_cache_update (hdev, &data); +mgmt_device_found (hdev->id, &info->bdaddr, info->dev_class,0 , +NULL ); }hci_dev_unlock (hdev);
@@ -2156,7 +2157,7 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, structstruct inquiry_info_with_rssi_and_pscan_mode *info; info = (void *) (skb->data +1 ); -for (; num_rsp; num_rsp--) { +for (; num_rsp; num_rsp--, info++) {bacpy (&data.bdaddr, &info->bdaddr); data.pscan_rep_mode = info->pscan_rep_mode; data.pscan_period_mode = info->pscan_period_mode;
@@ -2165,13 +2166,15 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct data.clock_offset = info->clock_offset; data.rssi = info->rssi; data.ssp_mode =0x00 ; - info++;hci_inquiry_cache_update (hdev, &data); +mgmt_device_found (hdev->id, &info->bdaddr, + info->dev_class, info->rssi, +NULL ); } }else {struct inquiry_info_with_rssi *info = (void *) (skb->data +1 ); -for (; num_rsp; num_rsp--) { +for (; num_rsp; num_rsp--, info++) {bacpy (&data.bdaddr, &info->bdaddr); data.pscan_rep_mode = info->pscan_rep_mode; data.pscan_period_mode = info->pscan_period_mode;
@@ -2180,8 +2183,10 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct data.clock_offset = info->clock_offset; data.rssi = info->rssi; data.ssp_mode =0x00 ; - info++;hci_inquiry_cache_update (hdev, &data); +mgmt_device_found (hdev->id, &info->bdaddr, + info->dev_class, info->rssi, +NULL ); } }
@@ -2312,7 +2317,7 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, structhci_dev_lock (hdev); -for (; num_rsp; num_rsp--) { +for (; num_rsp; num_rsp--, info++) {bacpy (&data.bdaddr, &info->bdaddr); data.pscan_rep_mode = info->pscan_rep_mode; data.pscan_period_mode = info->pscan_period_mode;
@@ -2321,8 +2326,9 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct data.clock_offset = info->clock_offset; data.rssi = info->rssi; data.ssp_mode =0x01 ; - info++;hci_inquiry_cache_update (hdev, &data); +mgmt_device_found (hdev->id, &info->bdaddr, info->dev_class, + info->rssi, info->data); }hci_dev_unlock (hdev);
net/bluetooth/mgmt.c +17 -0
@@ -2044,3 +2044,20 @@ int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer,return err; } + +int mgmt_device_found (u16 index,bdaddr_t *bdaddr,u8 *dev_class,s8 rssi, +u8 *eir) +{ +struct mgmt_ev_device_found ev; + +memset (&ev,0 ,sizeof (ev)); + +bacpy (&ev.bdaddr, bdaddr); +memcpy (ev.dev_class, dev_class,3 ); + ev.rssi = rssi; + +if (eir) +memcpy (ev.eir, eir,HCI_MAX_EIR_LENGTH ); + +return mgmt_event (MGMT_EV_DEVICE_FOUND , index, &ev,sizeof (ev),NULL ); +}
Signature · 1 line
1.7.4.1
PATCH 2/2 Bluetooth: Add mgmt_remote_name event
From: Johan Hedberg <[email protected]>
This patch adds a new remote_name event to the Management interface which is sent every time the name of a remote device is resolved (over BR/EDR).
--- include/net/bluetooth/hci_core.h | 1 + include/net/bluetooth/mgmt.h | 6 ++++++ net/bluetooth/hci_event.c | 3 +++ net/bluetooth/mgmt.c | 12 ++++++++++++ 4 files changed, 22 insertions(+), 0 deletions(-)
include/net/bluetooth/hci_core.h +1 -0
@@ -789,6 +789,7 @@ int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer, u8 status);int mgmt_device_found (u16 index,bdaddr_t *bdaddr,u8 *dev_class,s8 rssi,u8 *eir); +int mgmt_remote_name (u16 index,bdaddr_t *bdaddr,u8 *name);/* HCI info for socket */ #define hci_pi (sk) ((struct hci_pinfo *) sk)
include/net/bluetooth/mgmt.h +6 -0
@@ -275,3 +275,9 @@ struct mgmt_ev_device_found {__s8 rssi;__u8 eir[HCI_MAX_EIR_LENGTH ]; } __packed; + +#define MGMT_EV_REMOTE_NAME 0x0013 +struct mgmt_ev_remote_name { +bdaddr_t bdaddr; +__u8 name[MGMT_MAX_NAME_LENGTH ]; +} __packed;
net/bluetooth/hci_event.c +3 -0
@@ -1495,6 +1495,9 @@ static inline void hci_remote_name_evt(struct hci_dev *hdev, struct sk_buff *skbhci_dev_lock (hdev); +if (ev->status ==0 &&test_bit (HCI_MGMT , &hdev->flags)) +mgmt_remote_name (hdev->id, &ev->bdaddr, ev->name); + conn =hci_conn_hash_lookup_ba (hdev,ACL_LINK , &ev->bdaddr);if (conn &&hci_outgoing_auth_needed (hdev, conn)) {struct hci_cp_auth_requested cp;
net/bluetooth/mgmt.c +12 -0
@@ -2061,3 +2061,15 @@ int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi,return mgmt_event (MGMT_EV_DEVICE_FOUND , index, &ev,sizeof (ev),NULL ); } + +int mgmt_remote_name (u16 index,bdaddr_t *bdaddr,u8 *name) +{ +struct mgmt_ev_remote_name ev; + +memset (&ev,0 ,sizeof (ev)); + +bacpy (&ev.bdaddr, bdaddr); +memcpy (ev.name, name,HCI_MAX_NAME_LENGTH ); + +return mgmt_event (MGMT_EV_REMOTE_NAME , index, &ev,sizeof (ev),NULL ); +}
Signature · 1 line
1.7.4.1
Hi Johan,
net/bluetooth/mgmt.c int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer, · line 2056
Quoted 9 lines · On Wed, Mar 30, 2011 at 6:18 AM, <[email protected]> wrote:
net/bluetooth/mgmt.c +9
-0+int mgmt_device_found (u16 index,bdaddr_t *bdaddr,u8 *dev_class,s8 rssi, + u8 *eir) +{ + struct mgmt_ev_device_found ev; + + memset(&ev, 0, sizeof(ev)); + + bacpy(&ev.bdaddr, bdaddr); + memcpy(ev.dev_class, dev_class, 3);
What about "sizeof(ev.dev_class)" instead of 3 ?
Quoted 4 lines
+ ev.rssi = rssi;
+
+ if (eir)
+memcpy(ev.eir, eir, HCI_MAX_EIR_LENGTH);
This could be "sizeof(ev.eir)" as well, although it is already clear by the #define.
net/bluetooth/mgmt.c int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer, · line 2063
Quoted 3 lines
net/bluetooth/mgmt.c +3
-0+ + return mgmt_event(MGMT_EV_DEVICE_FOUND, index, &ev, sizeof(ev), NULL); +}
Regards,
Signature · 3 lines
Anderson Lizardo Instituto Nokia de Tecnologia - INdT Manaus - Brazil
Re: [PATCH 2/2] Bluetooth: Add mgmt_remote_name event
In reply to [email protected]Hi Johan,
Quoted 5 lines · On Wed, Mar 30, 2011 at 6:18 AM, <[email protected]> wrote:
From: Johan Hedberg <[email protected]>
This patch adds a new
remote_nameevent to the Management interface which is sent every time the name of a remote device is resolved (over BR/EDR).
Just wondering if we could ever reuse this for LE. For LE (and GATT over BR/EDR ?), I believe the "remote device name resolution" is done by looking at the GAP "Device Name" characteristic after a service discovery (see spec page 1739).
The advertising data may contain the "full" device name as well, but it is not mandatory to include it. GAP Device Name OTOH is mandatory.
Regards,
Signature · 3 lines
Anderson Lizardo Instituto Nokia de Tecnologia - INdT Manaus - Brazil
Re: [PATCH 2/2] Bluetooth: Add mgmt_remote_name event
Hi,
Quoted 11 lines · Anderson Lizardo
Quoted 3 lines
This patch adds a new
remote_nameevent to the Management interface which is sent every time the name of a remote device is resolved (over BR/EDR).Just wondering if we could ever reuse this for LE. For LE (and GATT over BR/EDR ?), I believe the "remote device name resolution" is done by looking at the GAP "Device Name" characteristic after a service discovery (see spec page 1739).
The advertising data may contain the "full" device name as well, but it is not mandatory to include it. GAP Device Name OTOH is mandatory.
I suppose it can't be reused for LE. Btw, this event will *not* be sent for advertising data or extended inquiry response data containing a remote name. User space is expected to do that extraction from the data (which comes in the mgmt_device_found event).
Johan
PATCH v2 1/2 Bluetooth: Add mgmt_device_found event
In reply to Anderson LizardoFrom: Johan Hedberg <[email protected]>
This patch adds a device_found event to the Management interface. For now the event only maps to BR/EDR inquiry result HCI events, but in the future the plan is to also use it for the LE device discovery process.
---
v2: comments from Lizardo taken into account
include/net/bluetooth/hci_core.h | 2 ++ include/net/bluetooth/mgmt.h | 8 ++++++++ net/bluetooth/hci_event.c | 22 ++++++++++++++-------- net/bluetooth/mgmt.c | 17 +++++++++++++++++ 4 files changed, 41 insertions(+), 8 deletions(-)
include/net/bluetooth/hci_core.h +2 -0
@@ -787,6 +787,8 @@ int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status);int mgmt_set_local_name_complete (u16 index,u8 *name,u8 status);int mgmt_read_local_oob_data_reply_complete (u16 index,u8 *hash,u8 *randomizer,u8 status); +int mgmt_device_found (u16 index,bdaddr_t *bdaddr,u8 *dev_class,s8 rssi, +u8 *eir);/* HCI info for socket */ #define hci_pi (sk) ((struct hci_pinfo *) sk)
include/net/bluetooth/mgmt.h +8 -0
@@ -267,3 +267,11 @@ struct mgmt_ev_auth_failed {struct mgmt_ev_local_name_changed {__u8 name[MGMT_MAX_NAME_LENGTH ]; } __packed; + +#define MGMT_EV_DEVICE_FOUND 0x0012 +struct mgmt_ev_device_found { +bdaddr_t bdaddr; +__u8 dev_class[3 ]; +__s8 rssi; +__u8 eir[HCI_MAX_EIR_LENGTH ]; +} __packed;
net/bluetooth/hci_event.c +14 -8
@@ -1226,7 +1226,7 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *hci_dev_lock (hdev); -for (; num_rsp; num_rsp--) { +for (; num_rsp; num_rsp--, info++) {bacpy (&data.bdaddr, &info->bdaddr); data.pscan_rep_mode = info->pscan_rep_mode; data.pscan_period_mode = info->pscan_period_mode;
@@ -1235,8 +1235,9 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * data.clock_offset = info->clock_offset; data.rssi =0x00 ; data.ssp_mode =0x00 ; - info++;hci_inquiry_cache_update (hdev, &data); +mgmt_device_found (hdev->id, &info->bdaddr, info->dev_class,0 , +NULL ); }hci_dev_unlock (hdev);
@@ -2156,7 +2157,7 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, structstruct inquiry_info_with_rssi_and_pscan_mode *info; info = (void *) (skb->data +1 ); -for (; num_rsp; num_rsp--) { +for (; num_rsp; num_rsp--, info++) {bacpy (&data.bdaddr, &info->bdaddr); data.pscan_rep_mode = info->pscan_rep_mode; data.pscan_period_mode = info->pscan_period_mode;
@@ -2165,13 +2166,15 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct data.clock_offset = info->clock_offset; data.rssi = info->rssi; data.ssp_mode =0x00 ; - info++;hci_inquiry_cache_update (hdev, &data); +mgmt_device_found (hdev->id, &info->bdaddr, + info->dev_class, info->rssi, +NULL ); } }else {struct inquiry_info_with_rssi *info = (void *) (skb->data +1 ); -for (; num_rsp; num_rsp--) { +for (; num_rsp; num_rsp--, info++) {bacpy (&data.bdaddr, &info->bdaddr); data.pscan_rep_mode = info->pscan_rep_mode; data.pscan_period_mode = info->pscan_period_mode;
@@ -2180,8 +2183,10 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct data.clock_offset = info->clock_offset; data.rssi = info->rssi; data.ssp_mode =0x00 ; - info++;hci_inquiry_cache_update (hdev, &data); +mgmt_device_found (hdev->id, &info->bdaddr, + info->dev_class, info->rssi, +NULL ); } }
@@ -2312,7 +2317,7 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, structhci_dev_lock (hdev); -for (; num_rsp; num_rsp--) { +for (; num_rsp; num_rsp--, info++) {bacpy (&data.bdaddr, &info->bdaddr); data.pscan_rep_mode = info->pscan_rep_mode; data.pscan_period_mode = info->pscan_period_mode;
@@ -2321,8 +2326,9 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct data.clock_offset = info->clock_offset; data.rssi = info->rssi; data.ssp_mode =0x01 ; - info++;hci_inquiry_cache_update (hdev, &data); +mgmt_device_found (hdev->id, &info->bdaddr, info->dev_class, + info->rssi, info->data); }hci_dev_unlock (hdev);
net/bluetooth/mgmt.c +17 -0
@@ -2044,3 +2044,20 @@ int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer,return err; } + +int mgmt_device_found (u16 index,bdaddr_t *bdaddr,u8 *dev_class,s8 rssi, +u8 *eir) +{ +struct mgmt_ev_device_found ev; + +memset (&ev,0 ,sizeof (ev)); + +bacpy (&ev.bdaddr, bdaddr); +memcpy (ev.dev_class, dev_class,sizeof (ev.dev_class)); + ev.rssi = rssi; + +if (eir) +memcpy (ev.eir, eir,sizeof (ev.eir)); + +return mgmt_event (MGMT_EV_DEVICE_FOUND , index, &ev,sizeof (ev),NULL ); +}
Signature · 1 line
1.7.4.1
Hi Johan,
Quoted 7 lines · * [email protected] <[email protected]> [2011-03-30 23:57:16 +0300]:
From: Johan Hedberg <[email protected]>
This patch adds a
device_foundevent to the Management interface. For now the event only maps to BR/EDR inquiry result HCI events, but in the future the plan is to also use it for the LE device discovery process.Signed-off-by Johan Hedberg <[email protected]>
Quoted 8 lines
---
v2: comments from Lizardo taken into accountinclude/net/bluetooth/hci_core.h | 2 ++ include/net/bluetooth/mgmt.h | 8 ++++++++ net/bluetooth/hci_event.c | 22 ++++++++++++++-------- net/bluetooth/mgmt.c | 17 +++++++++++++++++ 4 files changed, 41 insertions(+), 8 deletions(-)
Both patches were applied, thanks.
Signature · 2 lines
Gustavo F. Padovan http://profusion.mobi