Implement missing PAN interface and notifications
cover Implement missing PAN interface and notifications
v2: Fixed wrong number of opcode values as per Johan's comments.
v1: Patch set implements missing cleanup interface and adds event structs
to hal-msg.h and implements connection and control state notifications.
Ravi kumar Veeramally (4):
android/pan: Add PAN related defines and event struct to hsl-msg
header
android/pan: Add PAN cleanup interface implementation android/pan: Add notify method to PAN notifications android/pan: Handle connection and control state notifications
android/hal-msg.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ android/hal-pan.c | 46 +++++++++++++++++++++++++++++++++++++++++++--- android/hal.h | 1 + 3 files changed, 88 insertions(+), 3 deletions(-)
Signature · 1 line
1.8.3.2
PATCH 1/4 android/pan: Add PAN related defines and event struct to hsl-msg header
--- android/hal-msg.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
android/hal-msg.h +44 -0
@@ -317,6 +317,33 @@ struct hal_cmd_a2dp_disconnect {/* PAN HAL API */ +/* PAN Roles */ +#define HAL_PAN_ROLE_NONE 0x00 +#define HAL_PAN_ROLE_NAP 0x01 +#define HAL_PAN_ROLE_PANU 0x02 + +/* PAN Control states */ +#define HAL_PAN_CTRL_ENABLED 0x00 +#define HAL_PAN_CTRL_DISABLED 0x01 + +/* PAN Connection states */ +#define HAL_PAN_STATE_CONNECTED 0x00 +#define HAL_PAN_STATE_CONNECTING 0x01 +#define HAL_PAN_STATE_DISCONNECTED 0x02 +#define HAL_PAN_STATE_DISCONNECTING 0x03 + +/* PAN status values */ +#define HAL_PAN_STATUS_FAIL 0x01 +#define HAL_PAN_STATUS_NOT_READY 0x02 +#define HAL_PAN_STATUS_NO_MEMORY 0x03 +#define HAL_PAN_STATUS_BUSY 0x04 +#define HAL_PAN_STATUS_DONE 0x05 +#define HAL_PAN_STATUS_UNSUPORTED 0x06 +#define HAL_PAN_STATUS_INVAL 0x07 +#define HAL_PAN_STATUS_UNHANDLED 0x08 +#define HAL_PAN_STATUS_AUTH_FAILED 0x09 +#define HAL_PAN_STATUS_DEVICE_DOWN 0x0A +#define HAL_OP_PAN_ENABLE 0x01struct hal_cmd_pan_enable {uint8_t local_role;
@@ -486,6 +513,23 @@ struct hal_ev_hidhost_virtual_unplug {uint8_t status; } __attribute__((packed)); +#define HAL_EV_PAN_CTRL_STATE 0x81 +struct hal_ev_pan_ctrl_state { +uint8_t state; +uint8_t status; +uint8_t local_role; +uint8_t name[17 ]; +} __attribute__((packed)); + +#define HAL_EV_PAN_CONN_STATE 0x82 +struct hal_ev_pan_conn_state { +uint8_t state; +uint8_t status; +uint8_t bdaddr[6 ]; +uint8_t local_role; +uint8_t remote_role; +} __attribute__((packed)); +#define HAL_EV_A2DP_CONNECTION_STATE 0x81struct hal_ev_a2dp_connection_state {uint8_t state;
Signature · 1 line
1.8.3.2
PATCH 2/4 android/pan: Add PAN cleanup interface implementation
In reply to Ravi kumar Veeramally--- android/hal-pan.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
android/hal-pan.c +6 -3
@@ -114,16 +114,19 @@ static bt_status_t pan_init(const btpan_callbacks_t *callbacks)static void pan_cleanup () { +struct hal_cmd_register_module cmd; +DBG ("" );if (!interface_ready ())return ; -/* TODO: disable service */ + cbs =NULL ; -/* TODO: stop PAN thread */ + cmd.service_id =HAL_SERVICE_ID_PAN ; - cbs =NULL ; +hal_ipc_cmd (HAL_SERVICE_ID_CORE ,HAL_OP_UNREGISTER_MODULE , +sizeof (cmd), &cmd,0 ,NULL ,NULL ); }static btpan_interface_t pan_if = {
Signature · 1 line
1.8.3.2
PATCH 3/4 android/pan: Add notify method to PAN notifications
In reply to Ravi kumar Veeramally--- android/hal-pan.c | 6 ++++++ android/hal.h | 1 + 2 files changed, 7 insertions(+)
android/hal-pan.c +6 -0
@@ -31,6 +31,12 @@ static bool interface_ready(void)return cbs !=NULL ; } +void bt_notify_pan (uint16_t opcode,void *buf,uint16_t len) +{ +if (!interface_ready ()) +return ; +} +static bt_status_t pan_enable (int local_role) {struct hal_cmd_pan_enable cmd;
android/hal.h +1 -0
@@ -31,3 +31,4 @@ void bt_thread_associate(void);void bt_thread_disassociate (void );void bt_notify_hidhost (uint16_t opcode,void *buf,uint16_t len);void bt_notify_a2dp (uint16_t opcode,void *buf,uint16_t len); +void bt_notify_pan (uint16_t opcode,void *buf,uint16_t len);
Signature · 1 line
1.8.3.2
Re: [PATCH_v2 3/4] android/pan: Add notify method to PAN notifications
Hi Ravi,
Quoted 4 lines · Ravi kumar Veeramally
--- android/hal-pan.c | 6 ++++++ android/hal.h | 1 + 2 files changed, 7 insertions(+)
I've applied the first two patches, but there's one issue with this one:
android/hal-pan.c static bool interface_ready(void) · line 38
Quoted 5 lines
android/hal-pan.c +5
-0+void bt_notify_pan (uint16_t opcode,void *buf,uint16_t len) +{ +if (!interface_ready ()) +return ; +}
Why is opcode uint16_t instead of uint8_t? Haven't we defined it as uint8_t in our IPC document?
Johan
Re: [PATCH_v2 3/4] android/pan: Add notify method to PAN notifications
Hi Johan,
Quoted 9 lines · Johan Hedberg
Hi Ravi,
Quoted 4 lines · Ravi kumar Veeramally
--- android/hal-pan.c | 6 ++++++ android/hal.h | 1 + 2 files changed, 7 insertions(+)I've applied the first two patches, but there's one issue with this one:
Quoted 8 lines
android/hal-pan.c static bool interface_ready(void) · line 38
Quoted 5 lines
android/hal-pan.c +5
-0+void bt_notify_pan (uint16_t opcode,void *buf,uint16_t len) +{ +if (!interface_ready ()) +return ; +}Why is opcode
uint16_tinstead ofuint8_t? Haven't we defined it asuint8_tin our IPC document?
There are few other places like adapter and hid it is declared as uint16_t. I will fix that too and send you v3 of these two.
Thanks,
Ravi.
PATCH 4/4 android/pan: Handle connection and control state notifications
In reply to Ravi kumar Veeramally--- android/hal-pan.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
android/hal-pan.c +31 -0
@@ -31,10 +31,41 @@ static bool interface_ready(void)return cbs !=NULL ; } +static void handle_conn_state (void *buf) +{ +struct hal_ev_pan_conn_state *ev = buf; + +if (cbs->connection_state_cb) + cbs->connection_state_cb (ev->state, ev->status, + (bt_bdaddr_t *) ev->bdaddr, + ev->local_role, ev->remote_role); +} + +static void handle_ctrl_state (void *buf) +{ +struct hal_ev_pan_ctrl_state *ev = buf; + +if (cbs->control_state_cb) + cbs->control_state_cb (ev->state, ev->status, + ev->local_role, (char *)ev->name); +} +void bt_notify_pan (uint16_t opcode,void *buf,uint16_t len) {if (!interface_ready ())return ; + +switch (opcode) { +case HAL_EV_PAN_CONN_STATE : +handle_conn_state (buf); +break ; +case HAL_EV_PAN_CTRL_STATE : +handle_ctrl_state (buf); +break ; +default : +DBG ("Unhandled callback opcode=0x%x" , opcode); +break ; + } }static bt_status_t pan_enable (int local_role)
Signature · 1 line
1.8.3.2