static void settings_changed_powered(struct bt_adapter *adapter)
{
- struct hal_msg_ev_bt_adapter_state_changed ev;
+ struct hal_ev_adapter_state_changed ev;
ev.state = (adapter->current_settings & MGMT_SETTING_POWERED) ?
- HAL_BT_ADAPTER_STATE_ON : HAL_BT_ADAPTER_STATE_OFF;
+ HAL_POWER_ON : HAL_POWER_OFF;
DBG("%u", ev.state);
ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
- HAL_MSG_EV_BT_ADAPTER_STATE_CHANGED,
- sizeof(ev), &ev, -1);
+ HAL_EV_ADAPTER_STATE_CHANGED, sizeof(ev), &ev, -1);
}
static void settings_changed_connectable(struct bt_adapter *adapter)
uint8_t status = HAL_ERROR_FAILED;
switch (opcode) {
- case HAL_MSG_OP_BT_ENABLE:
+ case HAL_OP_ENABLE:
if (default_adapter->current_settings & MGMT_SETTING_POWERED) {
status = HAL_ERROR_DONE;
break;
return;
}
break;
- case HAL_MSG_OP_BT_DISABLE:
+ case HAL_OP_DISABLE:
if (!(default_adapter->current_settings & MGMT_SETTING_POWERED)) {
status = HAL_ERROR_DONE;
break;
static void handle_adapter_state_changed(void *buf)
{
- struct hal_msg_ev_bt_adapter_state_changed *ev = buf;
+ struct hal_ev_adapter_state_changed *ev = buf;
if (bt_hal_cbacks->adapter_state_changed_cb)
bt_hal_cbacks->adapter_state_changed_cb(ev->state);
return;
switch (opcode) {
- case HAL_MSG_EV_BT_ADAPTER_STATE_CHANGED:
+ case HAL_EV_ADAPTER_STATE_CHANGED:
handle_adapter_state_changed(buf);
break;
default:
static int init(bt_callbacks_t *callbacks)
{
- struct hal_msg_cmd_register_module cmd;
+ struct hal_cmd_register_module cmd;
int status;
DBG("");
cmd.service_id = HAL_SERVICE_ID_BLUETOOTH;
- status = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_MSG_OP_REGISTER_MODULE,
+ status = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
sizeof(cmd), &cmd, NULL, NULL, NULL);
if (status != BT_STATUS_SUCCESS) {
error("Failed to register 'bluetooth' service");
cmd.service_id = HAL_SERVICE_ID_SOCK;
- status = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_MSG_OP_REGISTER_MODULE,
+ status = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
sizeof(cmd), &cmd, NULL, NULL, NULL);
if (status != BT_STATUS_SUCCESS) {
error("Failed to register 'socket' service");
if (!interface_ready())
return BT_STATUS_NOT_READY;
- return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_MSG_OP_BT_ENABLE, 0,
- NULL, 0, NULL, NULL);
+ return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_ENABLE, 0, NULL, 0,
+ NULL, NULL);
}
static int disable(void)
if (!interface_ready())
return BT_STATUS_NOT_READY;
- return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_MSG_OP_BT_DISABLE, 0,
- NULL, 0, NULL, NULL);
+ return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_DISABLE, 0, NULL, 0,
+ NULL, NULL);
}
static void cleanup(void)
static bt_status_t hh_connect(bt_bdaddr_t *bd_addr)
{
- struct hal_msg_cmd_bt_hid_connect cmd;
+ struct hal_cmd_hid_connect cmd;
DBG("");
memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
- return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_MSG_OP_BT_HID_CONNECT,
+ return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HID_CONNECT,
sizeof(cmd), &cmd, 0, NULL, NULL);
}
static bt_status_t hh_disconnect(bt_bdaddr_t *bd_addr)
{
- struct hal_msg_cmd_bt_hid_disconnect cmd;
+ struct hal_cmd_hid_disconnect cmd;
DBG("");
memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
- return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_MSG_OP_BT_HID_DISCONNECT,
+ return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HID_DISCONNECT,
sizeof(cmd), &cmd, 0, NULL, NULL);
}
static bt_status_t hh_virtual_unplug(bt_bdaddr_t *bd_addr)
{
- struct hal_msg_cmd_bt_hid_vp cmd;
+ struct hal_cmd_hid_vp cmd;
DBG("");
memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
- return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_MSG_OP_BT_HID_VP,
+ return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HID_VP,
sizeof(cmd), &cmd, 0, NULL, NULL);
}
static bt_status_t hh_set_info(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid_info)
{
- struct hal_msg_cmd_bt_hid_set_info cmd;
+ struct hal_cmd_hid_set_info cmd;
DBG("");
cmd.descr_len = hid_info.dl_len;
memcpy(cmd.descr, hid_info.dsc_list, cmd.descr_len);
- return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_MSG_OP_BT_HID_SET_INFO,
+ return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HID_SET_INFO,
sizeof(cmd), &cmd, 0, NULL, NULL);
}
static bt_status_t hh_get_protocol(bt_bdaddr_t *bd_addr,
bthh_protocol_mode_t protocolMode)
{
- struct hal_msg_cmd_bt_hid_get_protocol cmd;
+ struct hal_cmd_hid_get_protocol cmd;
DBG("");
switch (protocolMode) {
case BTHH_REPORT_MODE:
- cmd.mode = HAL_MSG_BT_HID_REPORT_PROTOCOL;
+ cmd.mode = HAL_HID_REPORT_PROTOCOL;
break;
case BTHH_BOOT_MODE:
- cmd.mode = HAL_MSG_BT_HID_BOOT_PROTOCOL;
+ cmd.mode = HAL_HID_BOOT_PROTOCOL;
break;
case BTHH_UNSUPPORTED_MODE:
- cmd.mode = HAL_MSG_BT_HID_UNSUPPORTED_PROTOCOL;
+ cmd.mode = HAL_HID_UNSUPPORTED_PROTOCOL;
break;
}
return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST,
- HAL_MSG_OP_BT_HID_GET_PROTOCOL,
+ HAL_OP_HID_GET_PROTOCOL,
sizeof(cmd), &cmd, 0, NULL, NULL);
}
static bt_status_t hh_set_protocol(bt_bdaddr_t *bd_addr,
bthh_protocol_mode_t protocolMode)
{
- struct hal_msg_cmd_bt_hid_set_protocol cmd;
+ struct hal_cmd_hid_set_protocol cmd;
DBG("");
switch (protocolMode) {
case BTHH_REPORT_MODE:
- cmd.mode = HAL_MSG_BT_HID_REPORT_PROTOCOL;
+ cmd.mode = HAL_HID_REPORT_PROTOCOL;
break;
case BTHH_BOOT_MODE:
- cmd.mode = HAL_MSG_BT_HID_BOOT_PROTOCOL;
+ cmd.mode = HAL_HID_BOOT_PROTOCOL;
break;
case BTHH_UNSUPPORTED_MODE:
- cmd.mode = HAL_MSG_BT_HID_UNSUPPORTED_PROTOCOL;
+ cmd.mode = HAL_HID_UNSUPPORTED_PROTOCOL;
break;
}
return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST,
- HAL_MSG_OP_BT_HID_SET_PROTOCOL,
+ HAL_OP_HID_SET_PROTOCOL,
sizeof(cmd), &cmd, 0, NULL, NULL);
}
uint8_t reportId,
int bufferSize)
{
- struct hal_msg_cmd_bt_hid_get_report cmd;
+ struct hal_cmd_hid_get_report cmd;
DBG("");
switch (reportType) {
case BTHH_INPUT_REPORT:
- cmd.type = HAL_MSG_BT_HID_INPUT_REPORT;
+ cmd.type = HAL_HID_INPUT_REPORT;
break;
case BTHH_OUTPUT_REPORT:
- cmd.type = HAL_MSG_BT_HID_OUTPUT_REPORT;
+ cmd.type = HAL_HID_OUTPUT_REPORT;
break;
case BTHH_FEATURE_REPORT:
- cmd.type = HAL_MSG_BT_HID_FEATURE_REPORT;
+ cmd.type = HAL_HID_FEATURE_REPORT;
break;
}
- return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_MSG_OP_BT_HID_GET_REPORT,
+ return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HID_GET_REPORT,
sizeof(cmd), &cmd, 0, NULL, NULL);
}
bthh_report_type_t reportType,
char *report)
{
- struct hal_msg_cmd_bt_hid_set_report cmd;
+ struct hal_cmd_hid_set_report cmd;
DBG("");
switch (reportType) {
case BTHH_INPUT_REPORT:
- cmd.type = HAL_MSG_BT_HID_INPUT_REPORT;
+ cmd.type = HAL_HID_INPUT_REPORT;
break;
case BTHH_OUTPUT_REPORT:
- cmd.type = HAL_MSG_BT_HID_OUTPUT_REPORT;
+ cmd.type = HAL_HID_OUTPUT_REPORT;
break;
case BTHH_FEATURE_REPORT:
- cmd.type = HAL_MSG_BT_HID_FEATURE_REPORT;
+ cmd.type = HAL_HID_FEATURE_REPORT;
break;
}
- return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST,
- HAL_MSG_OP_BT_HID_SET_REPORT,
+ return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HID_SET_REPORT,
sizeof(cmd), &cmd, 0, NULL, NULL);
}
static bt_status_t hh_send_data(bt_bdaddr_t *bd_addr, char *data)
{
- struct hal_msg_cmd_bt_hid_send_data cmd;
+ struct hal_cmd_hid_send_data cmd;
DBG("");
memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
- return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_MSG_OP_BT_HID_SEND_DATA,
+ return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HID_SEND_DATA,
sizeof(cmd), &cmd, 0, NULL, NULL);
}
static bt_status_t hh_init(bthh_callbacks_t *callbacks)
{
- struct hal_msg_cmd_register_module cmd;
+ struct hal_cmd_register_module cmd;
DBG("");
cmd.service_id = HAL_SERVICE_ID_HIDHOST;
- return hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_MSG_OP_REGISTER_MODULE,
+ return hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
sizeof(cmd), &cmd, 0, NULL, NULL);
}
static pthread_t notif_th = 0;
-static void notification_dispatch(struct hal_msg_hdr *msg, int fd)
+static void notification_dispatch(struct hal_hdr *msg, int fd)
{
switch (msg->service_id) {
case HAL_SERVICE_ID_BLUETOOTH:
struct cmsghdr *cmsg;
char cmsgbuf[CMSG_SPACE(sizeof(int))];
char buf[BLUEZ_HAL_MTU];
- struct hal_msg_hdr *hal_msg = (void *) buf;
+ struct hal_hdr *ev = (void *) buf;
ssize_t ret;
int fd;
memset(buf, 0, sizeof(buf));
memset(cmsgbuf, 0, sizeof(cmsgbuf));
- iv.iov_base = hal_msg;
+ iv.iov_base = ev;
iv.iov_len = sizeof(buf);
msg.msg_iov = &iv;
exit(EXIT_FAILURE);
}
- if (ret < (ssize_t) sizeof(*hal_msg)) {
+ if (ret < (ssize_t) sizeof(*ev)) {
error("Too small notification (%zd bytes), aborting",
ret);
exit(EXIT_FAILURE);
}
- if (hal_msg->opcode < HAL_MSG_MINIMUM_EVENT) {
+ if (ev->opcode < HAL_MINIMUM_EVENT) {
error("Invalid notification (0x%x), aborting",
- hal_msg->opcode);
+ ev->opcode);
exit(EXIT_FAILURE);
}
- if (ret != (ssize_t) (sizeof(*hal_msg) + hal_msg->len)) {
+ if (ret != (ssize_t) (sizeof(*ev) + ev->len)) {
error("Malformed notification(%zd bytes), aborting",
ret);
exit(EXIT_FAILURE);
}
}
- notification_dispatch(hal_msg, fd);
+ notification_dispatch(ev, fd);
}
close(notif_sk);
ssize_t ret;
struct msghdr msg;
struct iovec iv[2];
- struct hal_msg_hdr hal_msg;
+ struct hal_hdr cmd;
char cmsgbuf[CMSG_SPACE(sizeof(int))];
- struct hal_msg_rsp_error err;
+ struct hal_error err;
size_t err_len = sizeof(err);
if (cmd_sk < 0) {
}
memset(&msg, 0, sizeof(msg));
- memset(&hal_msg, 0, sizeof(hal_msg));
+ memset(&cmd, 0, sizeof(cmd));
- hal_msg.service_id = service_id;
- hal_msg.opcode = opcode;
- hal_msg.len = len;
+ cmd.service_id = service_id;
+ cmd.opcode = opcode;
+ cmd.len = len;
- iv[0].iov_base = &hal_msg;
- iv[0].iov_len = sizeof(hal_msg);
+ iv[0].iov_base = &cmd;
+ iv[0].iov_len = sizeof(cmd);
iv[1].iov_base = param;
iv[1].iov_len = len;
}
memset(&msg, 0, sizeof(msg));
- memset(&hal_msg, 0, sizeof(hal_msg));
+ memset(&cmd, 0, sizeof(cmd));
- iv[0].iov_base = &hal_msg;
- iv[0].iov_len = sizeof(hal_msg);
+ iv[0].iov_base = &cmd;
+ iv[0].iov_len = sizeof(cmd);
iv[1].iov_base = rsp;
iv[1].iov_len = *rsp_len;
pthread_mutex_unlock(&cmd_sk_mutex);
- if (ret < (ssize_t) sizeof(hal_msg)) {
+ if (ret < (ssize_t) sizeof(cmd)) {
error("Too small response received(%zd bytes), aborting", ret);
exit(EXIT_FAILURE);
}
- if (hal_msg.service_id != service_id) {
+ if (cmd.service_id != service_id) {
error("Invalid service id (%u vs %u), aborting",
- hal_msg.service_id, service_id);
+ cmd.service_id, service_id);
exit(EXIT_FAILURE);
}
- if (ret != (ssize_t) (sizeof(hal_msg) + hal_msg.len)) {
+ if (ret != (ssize_t) (sizeof(cmd) + cmd.len)) {
error("Malformed response received(%zd bytes), aborting", ret);
exit(EXIT_FAILURE);
}
- if (hal_msg.opcode != opcode && hal_msg.opcode != HAL_MSG_OP_ERROR) {
+ if (cmd.opcode != opcode && cmd.opcode != HAL_OP_ERROR) {
error("Invalid opcode received (%u vs %u), aborting",
- hal_msg.opcode, opcode);
+ cmd.opcode, opcode);
exit(EXIT_FAILURE);
}
- if (hal_msg.opcode == HAL_MSG_OP_ERROR) {
- struct hal_msg_rsp_error *err = rsp;
+ if (cmd.opcode == HAL_OP_ERROR) {
+ struct hal_error *err = rsp;
return err->status;
}
}
if (rsp_len)
- *rsp_len = hal_msg.len;
+ *rsp_len = cmd.len;
return BT_STATUS_SUCCESS;
}
static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket";
-struct hal_msg_hdr {
+struct hal_hdr {
uint8_t service_id;
uint8_t opcode;
uint16_t len;
uint8_t payload[0];
} __attribute__((packed));
-#define HAL_MSG_MINIMUM_EVENT 0x81
+#define HAL_MINIMUM_EVENT 0x81
#define HAL_SERVICE_ID_CORE 0
#define HAL_SERVICE_ID_BLUETOOTH 1
#define HAL_ERROR_AUTH_FAILURE 0x09
#define HAL_ERROR_REMOTE_DEVICE_DOWN 0x0a
-#define HAL_MSG_OP_ERROR 0x00
-struct hal_msg_rsp_error {
+#define HAL_OP_ERROR 0x00
+struct hal_error {
uint8_t status;
} __attribute__((packed));
-#define HAL_MSG_OP_REGISTER_MODULE 0x01
-struct hal_msg_cmd_register_module {
+#define HAL_OP_REGISTER_MODULE 0x01
+struct hal_cmd_register_module {
uint8_t service_id;
} __attribute__((packed));
-struct hal_msg_rsp_register_module {
+struct hal_rsp_register_module {
uint8_t service_id;
} __attribute__((packed));
-#define HAL_MSG_OP_UNREGISTER_MODULE 0x02
-struct hal_msg_cmd_unregister_module {
+#define HAL_OP_UNREGISTER_MODULE 0x02
+struct hal_cmd_unregister_module {
uint8_t service_id;
} __attribute__((packed));
/* Bluetooth Core HAL API */
-#define HAL_MSG_OP_BT_ENABLE 0x01
+#define HAL_OP_ENABLE 0x01
-#define HAL_MSG_OP_BT_DISABLE 0x02
+#define HAL_OP_DISABLE 0x02
-#define HAL_MSG_OP_BT_GET_ADAPTER_PROPS 0x03
+#define HAL_OP_GET_ADAPTER_PROPS 0x03
-#define HAL_MSG_OP_BT_GET_ADAPTER_PROP 0x04
-struct hal_msg_cmd_bt_get_adapter_prop {
+#define HAL_OP_GET_ADAPTER_PROP 0x04
+struct hal_cmd_get_adapter_prop {
uint8_t type;
} __attribute__((packed));
-#define HAL_MSG_OP_BT_SET_ADAPTER_PROP 0x05
-struct hal_msg_cmd_bt_set_adapter_prop {
+#define HAL_OP_SET_ADAPTER_PROP 0x05
+struct hal_cmd_set_adapter_prop {
uint8_t type;
uint16_t len;
uint8_t val[0];
} __attribute__((packed));
-#define HAL_MSG_OP_BT_GET_REMOTE_DEVICE_PROPS 0x06
-struct hal_msg_cmd_bt_get_remote_device_props {
+#define HAL_OP_GET_REMOTE_DEVICE_PROPS 0x06
+struct hal_cmd_get_remote_device_props {
uint8_t bdaddr[6];
} __attribute__((packed));
-#define HAL_MSG_OP_BT_GET_REMOTE_DEVICE_PROP 0x07
-struct hal_msg_cmd_bt_get_remote_device_prop {
+#define HAL_OP_GET_REMOTE_DEVICE_PROP 0x07
+struct hal_cmd_get_remote_device_prop {
uint8_t bdaddr[6];
uint8_t type;
} __attribute__((packed));
-#define HAL_MSG_OP_BT_SET_REMOTE_DEVICE_PROP 0x08
-struct hal_msg_cmd_bt_set_remote_device_prop {
+#define HAL_OP_SET_REMOTE_DEVICE_PROP 0x08
+struct hal_cmd_set_remote_device_prop {
uint8_t bdaddr[6];
uint8_t type;
uint16_t len;
uint8_t val[0];
} __attribute__((packed));
-#define HAL_MSG_OP_BT_GET_REMOTE_SERVICE_REC 0x09
-struct hal_msg_cmd_bt_get_remote_service_rec {
+#define HAL_OP_GET_REMOTE_SERVICE_REC 0x09
+struct hal_cmd_get_remote_service_rec {
uint8_t bdaddr[6];
uint8_t uuid[16];
} __attribute__((packed));
-#define HAL_MSG_OP_BT_GET_REMOTE_SERVICE 0x0a
-struct hal_msg_cmd_bt_get_remote_service {
+#define HAL_OP_GET_REMOTE_SERVICE 0x0a
+struct hal_cmd_get_remote_service {
uint8_t bdaddr[6];
} __attribute__((packed));
-#define HAL_MSG_OP_BT_START_DISCOVERY 0x0b
+#define HAL_OP_START_DISCOVERY 0x0b
-#define HAL_MSG_OP_BT_CANCEL_DISCOVERY 0x0c
+#define HAL_OP_CANCEL_DISCOVERY 0x0c
-#define HAL_MSG_OP_BT_CREATE_BOND 0x0d
-struct hal_msg_cmd_bt_create_bond {
+#define HAL_OP_CREATE_BOND 0x0d
+struct hal_cmd_create_bond {
uint8_t bdaddr[6];
} __attribute__((packed));
-#define HAL_MSG_OP_BT_REMOVE_BOND 0x0d
-struct hal_msg_cmd_bt_remove_bond {
+#define HAL_OP_REMOVE_BOND 0x0d
+struct hal_cmd_remove_bond {
uint8_t bdaddr[6];
} __attribute__((packed));
-#define HAL_MSG_OP_BT_CANCEL_BOND 0x0f
-struct hal_msg_cmd_bt_cancel_bond {
+#define HAL_OP_CANCEL_BOND 0x0f
+struct hal_cmd_cancel_bond {
uint8_t bdaddr[6];
} __attribute__((packed));
-#define HAL_MSG_OP_BT_PIN_REPLY 0x10
-struct hal_msg_cmd_bt_pin_reply {
+#define HAL_OP_PIN_REPLY 0x10
+struct hal_cmd_pin_reply {
uint8_t bdaddr[6];
uint8_t accept;
uint8_t pin_len;
uint8_t pin_code[16];
} __attribute__((packed));
-#define HAL_MSG_OP_BT_SSP_REPLY 0x11
-struct hal_msg_cmd_bt_ssp_reply {
+#define HAL_OP_SSP_REPLY 0x11
+struct hal_cmd_ssp_reply {
uint8_t bdaddr[6];
uint8_t ssp_variant;
uint8_t accept;
uint32_t passkey;
} __attribute__((packed));
-#define HAL_MSG_OP_BT_DUT_MODE_CONF 0x12
-struct hal_msg_cmd_bt_dut_mode_conf {
+#define HAL_OP_DUT_MODE_CONF 0x12
+struct hal_cmd_dut_mode_conf {
uint8_t enable;
} __attribute__((packed));
-#define HAL_MSG_OP_BT_DUT_MODE_SEND 0x13
-struct hal_msg_cmd_bt_dut_mode_send {
+#define HAL_OP_DUT_MODE_SEND 0x13
+struct hal_cmd_dut_mode_send {
uint16_t opcode;
uint8_t len;
uint8_t data[0];
} __attribute__((packed));
-#define HAL_MSG_OP_BT_LE_TEST_MODE 0x14
-struct hal_msg_cmd_bt_le_test_mode {
+#define HAL_OP_LE_TEST_MODE 0x14
+struct hal_cmd_le_test_mode {
uint16_t opcode;
uint8_t len;
uint8_t data[0];
} __attribute__((packed));
-#define HAL_MSG_OP_BT_HID_CONNECT 0x01
-struct hal_msg_cmd_bt_hid_connect {
+#define HAL_OP_HID_CONNECT 0x01
+struct hal_cmd_hid_connect {
uint8_t bdaddr[6];
} __attribute__((packed));
-#define HAL_MSG_OP_BT_HID_DISCONNECT 0x02
-struct hal_msg_cmd_bt_hid_disconnect {
+#define HAL_OP_HID_DISCONNECT 0x02
+struct hal_cmd_hid_disconnect {
uint8_t bdaddr[6];
} __attribute__((packed));
-#define HAL_MSG_OP_BT_HID_VP 0x03
-struct hal_msg_cmd_bt_hid_vp {
+#define HAL_OP_HID_VP 0x03
+struct hal_cmd_hid_vp {
uint8_t bdaddr[6];
} __attribute__((packed));
-#define HAL_MSG_OP_BT_HID_SET_INFO 0x04
-struct hal_msg_cmd_bt_hid_set_info {
+#define HAL_OP_HID_SET_INFO 0x04
+struct hal_cmd_hid_set_info {
uint8_t bdaddr[6];
uint8_t attr;
uint8_t subclass;
uint8_t descr[0];
} __attribute__((packed));
-#define HAL_MSG_BT_HID_REPORT_PROTOCOL 0x00
-#define HAL_MSG_BT_HID_BOOT_PROTOCOL 0x01
-#define HAL_MSG_BT_HID_UNSUPPORTED_PROTOCOL 0xff
+#define HAL_HID_REPORT_PROTOCOL 0x00
+#define HAL_HID_BOOT_PROTOCOL 0x01
+#define HAL_HID_UNSUPPORTED_PROTOCOL 0xff
-#define HAL_MSG_OP_BT_HID_GET_PROTOCOL 0x05
-struct hal_msg_cmd_bt_hid_get_protocol {
+#define HAL_OP_HID_GET_PROTOCOL 0x05
+struct hal_cmd_hid_get_protocol {
uint8_t bdaddr[6];
uint8_t mode;
} __attribute__((packed));
-#define HAL_MSG_OP_BT_HID_SET_PROTOCOL 0x06
-struct hal_msg_cmd_bt_hid_set_protocol {
+#define HAL_OP_HID_SET_PROTOCOL 0x06
+struct hal_cmd_hid_set_protocol {
uint8_t bdaddr[6];
uint8_t mode;
} __attribute__((packed));
-#define HAL_MSG_BT_HID_INPUT_REPORT 0x01
-#define HAL_MSG_BT_HID_OUTPUT_REPORT 0x02
-#define HAL_MSG_BT_HID_FEATURE_REPORT 0x03
+#define HAL_HID_INPUT_REPORT 0x01
+#define HAL_HID_OUTPUT_REPORT 0x02
+#define HAL_HID_FEATURE_REPORT 0x03
-#define HAL_MSG_OP_BT_HID_GET_REPORT 0x07
-struct hal_msg_cmd_bt_hid_get_report {
+#define HAL_OP_HID_GET_REPORT 0x07
+struct hal_cmd_hid_get_report {
uint8_t bdaddr[6];
uint8_t type;
uint8_t id;
uint16_t buf;
} __attribute__((packed));
-#define HAL_MSG_OP_BT_HID_SET_REPORT 0x08
-struct hal_msg_cmd_bt_hid_set_report {
+#define HAL_OP_HID_SET_REPORT 0x08
+struct hal_cmd_hid_set_report {
uint8_t bdaddr[6];
uint8_t type;
} __attribute__((packed));
-#define HAL_MSG_OP_BT_HID_SEND_DATA 0x09
-struct hal_msg_cmd_bt_hid_send_data {
+#define HAL_OP_HID_SEND_DATA 0x09
+struct hal_cmd_hid_send_data {
uint8_t bdaddr[6];
} __attribute__((packed));
/* Notifications and confirmations */
-#define HAL_BT_ADAPTER_STATE_OFF 0x00
-#define HAL_BT_ADAPTER_STATE_ON 0x01
+#define HAL_POWER_OFF 0x00
+#define HAL_POWER_ON 0x01
-#define HAL_MSG_EV_BT_ADAPTER_STATE_CHANGED 0x81
-struct hal_msg_ev_bt_adapter_state_changed {
+#define HAL_EV_ADAPTER_STATE_CHANGED 0x81
+struct hal_ev_adapter_state_changed {
uint8_t state;
} __attribute__((packed));
-#define HAL_MSG_EV_BT_ADAPTER_PROPS_CHANGED 0x82
+#define HAL_EV_ADAPTER_PROPS_CHANGED 0x82
struct hal_property {
uint8_t type;
uint16_t len;
uint8_t val[0];
} __attribute__((packed));
-struct hal_msg_ev_bt_adapter_props_changed {
+struct hal_ev_adapter_props_changed {
uint8_t status;
uint8_t num_props;
struct hal_property props[0];
} __attribute__((packed));
-#define HAL_MSG_EV_BT_REMOTE_DEVICE_PROPS 0x83
-struct hal_msg_ev_bt_remote_device_props {
+#define HAL_EV_REMOTE_DEVICE_PROPS 0x83
+struct hal_ev_remote_device_props {
uint8_t status;
uint8_t bdaddr[6];
uint8_t num_props;
struct hal_property props[0];
} __attribute__((packed));
-#define HAL_MSG_EV_BT_DEVICE_FOUND 0x84
-struct hal_msg_ev_bt_device_found {
+#define HAL_EV_DEVICE_FOUND 0x84
+struct hal_ev_device_found {
uint8_t num_props;
struct hal_property props[0];
} __attribute__((packed));
-#define HAL_MSG_EV_BT_DISCOVERY_STATE_CHANGED 0x85
-struct hal_msg_ev_bt_discovery_state_changed {
+#define HAL_EV_DISCOVERY_STATE_CHANGED 0x85
+struct hal_ev_discovery_state_changed {
uint8_t state;
} __attribute__((packed));
-#define HAL_MSG_EV_BT_PIN_REQUEST 0x86
-struct hal_msg_ev_bt_pin_request {
+#define HAL_EV_PIN_REQUEST 0x86
+struct hal_ev_pin_request {
uint8_t bdaddr[6];
uint8_t name[249 - 1];
uint8_t class_of_dev[3];
} __attribute__((packed));
-#define HAL_MSG_EV_BT_SSP_REQUEST 0x87
-struct hal_msg_ev_bt_ssp_request {
+#define HAL_EV_SSP_REQUEST 0x87
+struct hal_ev_ssp_request {
uint8_t bdaddr[6];
uint8_t name[249 - 1];
uint8_t class_of_dev[3];
uint32_t passkey;
} __attribute__((packed));
-#define HAL_MSG_EV_BT_BOND_STATE_CHANGED 0x88
-struct hal_msg_ev_bt_bond_state_changed {
+#define HAL_EV_BOND_STATE_CHANGED 0x88
+struct hal_ev_bond_state_changed {
uint8_t status;
uint8_t bdaddr[6];
uint8_t state;
} __attribute__((packed));
-#define HAL_MSG_EV_BT_ACL_STATE_CHANGED 0x89
-struct hal_msg_ev_bt_acl_state_changed {
+#define HAL_EV_ACL_STATE_CHANGED 0x89
+struct hal_ev_acl_state_changed {
uint8_t status;
uint8_t bdaddr[6];
uint8_t state;
} __attribute__((packed));
-#define HAL_MSG_EV_BT_DUT_MODE_RECEIVE 0x8a
-struct hal_msg_ev_bt_dut_mode_receive {
+#define HAL_EV_DUT_MODE_RECEIVE 0x8a
+struct hal_ev_dut_mode_receive {
uint16_t opcode;
uint8_t len;
uint8_t data[0];
} __attribute__((packed));
-#define HAL_MSG_EV_BT_LE_TEST_MODE 0x8b
-struct hal_msg_ev_bt_le_test_mode {
+#define HAL_EV_LE_TEST_MODE 0x8b
+struct hal_ev_le_test_mode {
uint8_t status;
uint16_t num_packets;
} __attribute__((packed));
uint8_t status = HAL_ERROR_FAILED;
switch (opcode) {
- case HAL_MSG_OP_BT_HID_CONNECT:
+ case HAL_OP_HID_CONNECT:
break;
- case HAL_MSG_OP_BT_HID_DISCONNECT:
+ case HAL_OP_HID_DISCONNECT:
break;
default:
DBG("Unhandled command, opcode 0x%x", opcode);
{
struct msghdr msg;
struct iovec iv[2];
- struct hal_msg_hdr hal_msg;
+ struct hal_hdr m;
char cmsgbuf[CMSG_SPACE(sizeof(int))];
struct cmsghdr *cmsg;
memset(&msg, 0, sizeof(msg));
- memset(&hal_msg, 0, sizeof(hal_msg));
+ memset(&m, 0, sizeof(m));
- hal_msg.service_id = service_id;
- hal_msg.opcode = opcode;
- hal_msg.len = len;
+ m.service_id = service_id;
+ m.opcode = opcode;
+ m.len = len;
- iv[0].iov_base = &hal_msg;
- iv[0].iov_len = sizeof(hal_msg);
+ iv[0].iov_base = &m;
+ iv[0].iov_len = sizeof(m);
iv[1].iov_base = param;
iv[1].iov_len = len;
void ipc_send_error(GIOChannel *io, uint8_t service_id, uint8_t status)
{
- struct hal_msg_rsp_error err;
+ struct hal_error err;
err.status = status;
- ipc_send(io, service_id, HAL_MSG_OP_ERROR, sizeof(err), &err, -1);
+ ipc_send(io, service_id, HAL_OP_ERROR, sizeof(err), &err, -1);
}
static void service_register(void *buf, uint16_t len)
{
- struct hal_msg_cmd_register_module *m = buf;
+ struct hal_cmd_register_module *m = buf;
const bdaddr_t *adapter_bdaddr = bt_adapter_get_address();
if (m->service_id > HAL_SERVICE_ID_MAX || services[m->service_id])
services[m->service_id] = true;
- ipc_send(hal_cmd_io, HAL_SERVICE_ID_CORE, HAL_MSG_OP_REGISTER_MODULE, 0,
+ ipc_send(hal_cmd_io, HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE, 0,
NULL, -1);
info("Service ID=%u registered", m->service_id);
static void service_unregister(void *buf, uint16_t len)
{
- struct hal_msg_cmd_unregister_module *m = buf;
+ struct hal_cmd_unregister_module *m = buf;
if (m->service_id > HAL_SERVICE_ID_MAX || !services[m->service_id])
goto error;
services[m->service_id] = false;
- ipc_send(hal_cmd_io, HAL_SERVICE_ID_CORE, HAL_MSG_OP_UNREGISTER_MODULE,
+ ipc_send(hal_cmd_io, HAL_SERVICE_ID_CORE, HAL_OP_UNREGISTER_MODULE,
0, NULL, -1);
info("Service ID=%u unregistered", m->service_id);
static void handle_service_core(uint8_t opcode, void *buf, uint16_t len)
{
switch (opcode) {
- case HAL_MSG_OP_REGISTER_MODULE:
+ case HAL_OP_REGISTER_MODULE:
service_register(buf, len);
break;
- case HAL_MSG_OP_UNREGISTER_MODULE:
+ case HAL_OP_UNREGISTER_MODULE:
service_unregister(buf, len);
break;
default:
gpointer user_data)
{
char buf[BLUEZ_HAL_MTU];
- struct hal_msg_hdr *msg = (void *) buf;
+ struct hal_hdr *msg = (void *) buf;
ssize_t ret;
int fd;