return bt_hh_cbacks != NULL;
}
+static void handle_conn_state(void *buf)
+{
+ struct hal_ev_hid_conn_state *ev = buf;
+
+ if (bt_hh_cbacks->connection_state_cb)
+ bt_hh_cbacks->connection_state_cb((bt_bdaddr_t *) ev->bdaddr,
+ ev->state);
+}
+
+/* will be called from notification thread context */
+void bt_notify_hh(uint16_t opcode, void *buf, uint16_t len)
+{
+ if (!interface_ready())
+ return;
+
+ switch (opcode) {
+ case HAL_EV_HID_CONN_STATE:
+ handle_conn_state(buf);
+ break;
+ default:
+ DBG("Unhandled callback opcode=0x%x", opcode);
+ break;
+ }
+}
+
static bt_status_t hh_connect(bt_bdaddr_t *bd_addr)
{
struct hal_cmd_hid_connect cmd;
Opcode 0x81 - Connection State notification
Notification parameters: Remote address (6 octets)
+ Connection State (1 octets)
Valid connection states: 0x00 = Connected
0x01 = Connecting
case HAL_SERVICE_ID_BLUETOOTH:
bt_notify_adapter(msg->opcode, msg->payload, msg->len);
break;
+ case HAL_SERVICE_ID_HIDHOST:
+ bt_notify_hh(msg->opcode, msg->payload, msg->len);
+ break;
case HAL_SERVICE_ID_A2DP:
bt_notify_av(msg->opcode, msg->payload, msg->len);
break;
uint16_t num_packets;
} __attribute__((packed));
+#define HAL_HID_STATE_CONNECTED 0x00
+#define HAL_HID_STATE_CONNECTING 0x01
+#define HAL_HID_STATE_DISCONNECTED 0x02
+#define HAL_HID_STATE_DISCONNECTING 0x03
+#define HAL_HID_STATE_NO_HID 0x07
+#define HAL_HID_STATE_FAILED 0x08
+#define HAL_HID_STATE_UNKNOWN 0x09
+
+#define HAL_EV_HID_CONN_STATE 0x81
+struct hal_ev_hid_conn_state {
+ uint8_t bdaddr[6];
+ uint8_t state;
+} __attribute__((packed));
+
#define HAL_EV_AV_CONNECTION_STATE 0x81
struct hal_ev_av_connection_state {
uint8_t state;
void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len);
void bt_thread_associate(void);
void bt_thread_disassociate(void);
+void bt_notify_hh(uint16_t opcode, void *buf, uint16_t len);
void bt_notify_av(uint16_t opcode, void *buf, uint16_t len);