OSDN Git Service

android/hal-msg: Reduce length of defines and struct names
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 23 Oct 2013 11:14:09 +0000 (14:14 +0300)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 24 Oct 2013 07:46:24 +0000 (10:46 +0300)
The current defines and struct names are way too big and sometimes
incosistent.

android/adapter.c
android/hal-bluetooth.c
android/hal-hidhost.c
android/hal-ipc.c
android/hal-msg.h
android/hid.c
android/ipc.c
android/main.c

index 6b0fab2..88ac19f 100644 (file)
@@ -76,16 +76,15 @@ static void mgmt_local_name_changed_event(uint16_t index, uint16_t length,
 
 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)
@@ -340,7 +339,7 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
        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;
@@ -352,7 +351,7 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
                        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;
index 52c7c68..6e28c91 100644 (file)
@@ -29,7 +29,7 @@ static const bt_callbacks_t *bt_hal_cbacks = NULL;
 
 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);
@@ -42,7 +42,7 @@ void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len)
                return;
 
        switch (opcode) {
-       case HAL_MSG_EV_BT_ADAPTER_STATE_CHANGED:
+       case HAL_EV_ADAPTER_STATE_CHANGED:
                handle_adapter_state_changed(buf);
                break;
        default:
@@ -58,7 +58,7 @@ static bool interface_ready(void)
 
 static int init(bt_callbacks_t *callbacks)
 {
-       struct hal_msg_cmd_register_module cmd;
+       struct hal_cmd_register_module cmd;
        int status;
 
        DBG("");
@@ -73,7 +73,7 @@ static int init(bt_callbacks_t *callbacks)
 
        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");
@@ -82,7 +82,7 @@ static int init(bt_callbacks_t *callbacks)
 
        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");
@@ -104,8 +104,8 @@ static int enable(void)
        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)
@@ -115,8 +115,8 @@ 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)
index a7af27a..032e961 100644 (file)
@@ -33,7 +33,7 @@ static bool interface_ready(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("");
 
@@ -45,13 +45,13 @@ static bt_status_t hh_connect(bt_bdaddr_t *bd_addr)
 
        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("");
 
@@ -63,13 +63,13 @@ static bt_status_t hh_disconnect(bt_bdaddr_t *bd_addr)
 
        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("");
 
@@ -81,13 +81,13 @@ static bt_status_t hh_virtual_unplug(bt_bdaddr_t *bd_addr)
 
        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("");
 
@@ -107,14 +107,14 @@ static bt_status_t hh_set_info(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid_info)
        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("");
 
@@ -128,25 +128,25 @@ static bt_status_t hh_get_protocol(bt_bdaddr_t *bd_addr,
 
        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("");
 
@@ -160,18 +160,18 @@ static bt_status_t hh_set_protocol(bt_bdaddr_t *bd_addr,
 
        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);
 }
 
@@ -180,7 +180,7 @@ static bt_status_t hh_get_report(bt_bdaddr_t *bd_addr,
                                                uint8_t reportId,
                                                int bufferSize)
 {
-       struct hal_msg_cmd_bt_hid_get_report cmd;
+       struct hal_cmd_hid_get_report cmd;
 
        DBG("");
 
@@ -195,17 +195,17 @@ static bt_status_t hh_get_report(bt_bdaddr_t *bd_addr,
 
        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);
 }
 
@@ -213,7 +213,7 @@ static bt_status_t hh_set_report(bt_bdaddr_t *bd_addr,
                                                bthh_report_type_t reportType,
                                                char *report)
 {
-       struct hal_msg_cmd_bt_hid_set_report cmd;
+       struct hal_cmd_hid_set_report cmd;
 
        DBG("");
 
@@ -227,24 +227,23 @@ static bt_status_t hh_set_report(bt_bdaddr_t *bd_addr,
 
        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("");
 
@@ -256,13 +255,13 @@ static bt_status_t hh_send_data(bt_bdaddr_t *bd_addr, char *data)
 
        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("");
 
@@ -271,7 +270,7 @@ static bt_status_t hh_init(bthh_callbacks_t *callbacks)
 
        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);
 }
 
index 8f13e88..6566ebb 100644 (file)
@@ -43,7 +43,7 @@ static pthread_mutex_t cmd_sk_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 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:
@@ -63,7 +63,7 @@ static void *notification_handler(void *data)
        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;
 
@@ -72,7 +72,7 @@ static void *notification_handler(void *data)
                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;
@@ -97,19 +97,19 @@ static void *notification_handler(void *data)
                        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);
@@ -127,7 +127,7 @@ static void *notification_handler(void *data)
                        }
                }
 
-               notification_dispatch(hal_msg, fd);
+               notification_dispatch(ev, fd);
        }
 
        close(notif_sk);
@@ -261,9 +261,9 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param,
        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) {
@@ -278,14 +278,14 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param,
        }
 
        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;
@@ -303,10 +303,10 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param,
        }
 
        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;
@@ -330,30 +330,30 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param,
 
        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;
        }
 
@@ -374,7 +374,7 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param,
        }
 
        if (rsp_len)
-               *rsp_len = hal_msg.len;
+               *rsp_len = cmd.len;
 
        return BT_STATUS_SUCCESS;
 }
index 2840a92..854e9b8 100644 (file)
 
 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
@@ -60,145 +60,145 @@ struct hal_msg_hdr {
 #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;
@@ -210,96 +210,96 @@ struct hal_msg_cmd_bt_hid_set_info {
        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];
@@ -307,29 +307,29 @@ struct hal_msg_ev_bt_ssp_request {
        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));
index 2c74352..988e319 100644 (file)
@@ -39,9 +39,9 @@ void bt_hid_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf, uint16_t len)
        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);
index 1a867fb..17005e1 100644 (file)
@@ -39,19 +39,19 @@ void ipc_send(GIOChannel *io, uint8_t service_id, uint8_t opcode, uint16_t len,
 {
        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;
@@ -80,9 +80,9 @@ void ipc_send(GIOChannel *io, uint8_t service_id, uint8_t opcode, uint16_t 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);
 }
index 1721df8..9879f05 100644 (file)
@@ -77,7 +77,7 @@ static bool services[HAL_SERVICE_ID_MAX + 1] = { false };
 
 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])
@@ -106,7 +106,7 @@ static void service_register(void *buf, uint16_t len)
 
        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);
@@ -117,7 +117,7 @@ error:
 
 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;
@@ -141,7 +141,7 @@ static void service_unregister(void *buf, uint16_t len)
 
        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);
@@ -153,10 +153,10 @@ error:
 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:
@@ -170,7 +170,7 @@ static gboolean cmd_watch_cb(GIOChannel *io, GIOCondition cond,
                                                        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;