Bluetooth: Implement Read Supported Commands commands for mgmt
Subsystems (2)
PATCH 1/1 Bluetooth: Implement Read Supported Commands commands for mgmt
From: Johan Hedberg <[email protected]>
This patch implements the Read Supported Commands mgmt command which was recently added to the API specification. It returns a list of supported commands and events to user space.
--- include/net/bluetooth/mgmt.h | 7 +++ net/bluetooth/mgmt.c | 101 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 0 deletions(-)
include/net/bluetooth/mgmt.h +7 -0
@@ -63,6 +63,13 @@ struct mgmt_rp_read_version {__le16 revision; } __packed; +#define MGMT_OP_READ_COMMANDS 0x0002 +struct mgmt_rp_read_commands { +__le16 num_commands; +__le16 num_events; +__le16 opcodes[0 ]; +} __packed; +#define MGMT_OP_READ_INDEX_LIST 0x0003struct mgmt_rp_read_index_list {__le16 num_controllers;
net/bluetooth/mgmt.c +101 -0
119 lines not on this page · raw message
Signature · 1 line
1.7.9
Hi Johan,
Quoted 69 lines
This patch implements the Read Supported Commands mgmt command which was recently added to the API specification. It returns a list of supported commands and events to user space.
Signed-off-by Johan Hedberg <[email protected]>--- include/net/bluetooth/mgmt.h | 7 +++ net/bluetooth/mgmt.c | 101 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 0 deletions(-)include/net/bluetooth/mgmt.h +7
-0@@ -63,6 +63,13 @@ struct mgmt_rp_read_version {__le16 revision; } __packed; +#define MGMT_OP_READ_COMMANDS 0x0002 +struct mgmt_rp_read_commands { +__le16 num_commands; +__le16 num_events; +__le16 opcodes[0 ]; +} __packed; +#define MGMT_OP_READ_INDEX_LIST 0x0003struct mgmt_rp_read_index_list {__le16 num_controllers;net/bluetooth/mgmt.c +33
-0@@ -35,6 +35,71 @@#define MGMT_VERSION 0#define MGMT_REVISION 1 +static u16 mgmt_commands[] = { +MGMT_OP_READ_INDEX_LIST , +MGMT_OP_READ_INFO , +MGMT_OP_SET_POWERED , +MGMT_OP_SET_DISCOVERABLE , +MGMT_OP_SET_CONNECTABLE , +MGMT_OP_SET_FAST_CONNECTABLE , +MGMT_OP_SET_PAIRABLE , +MGMT_OP_SET_LINK_SECURITY , +MGMT_OP_SET_SSP , +MGMT_OP_SET_HS , +MGMT_OP_SET_LE , +MGMT_OP_SET_DEV_CLASS , +MGMT_OP_SET_LOCAL_NAME , +MGMT_OP_ADD_UUID , +MGMT_OP_REMOVE_UUID , +MGMT_OP_LOAD_LINK_KEYS , +MGMT_OP_LOAD_LONG_TERM_KEYS , +MGMT_OP_DISCONNECT , +MGMT_OP_GET_CONNECTIONS , +MGMT_OP_PIN_CODE_REPLY , +MGMT_OP_PIN_CODE_NEG_REPLY , +MGMT_OP_SET_IO_CAPABILITY , +MGMT_OP_PAIR_DEVICE , +MGMT_OP_CANCEL_PAIR_DEVICE , +MGMT_OP_UNPAIR_DEVICE , +MGMT_OP_USER_CONFIRM_REPLY , +MGMT_OP_USER_CONFIRM_NEG_REPLY , +MGMT_OP_USER_PASSKEY_REPLY , +MGMT_OP_USER_PASSKEY_NEG_REPLY , +MGMT_OP_READ_LOCAL_OOB_DATA , +MGMT_OP_ADD_REMOTE_OOB_DATA , +MGMT_OP_REMOVE_REMOTE_OOB_DATA ,
net/bluetooth/mgmt.c line 80
Quoted 10 lines
net/bluetooth/mgmt.c +10
-0+MGMT_OP_START_DISCOVERY , +MGMT_OP_STOP_DISCOVERY , +MGMT_OP_CONFIRM_NAME , +MGMT_OP_BLOCK_DEVICE , + MGMT_OP_UNBLOCK_DEVICE, +}; + +static u16 mgmt_events[] = { +MGMT_EV_CMD_COMPLETE , + MGMT_EV_CMD_STATUS,
I think you want to leave the two event above out. The specification states that they are not included, because always mandatory. They are actually implicit anyway. Without it you are lost.
And I think you can make both arrays const.
Other than that, looks good.
Regards
Marcel