static void service_register(const void *buf, uint16_t len) { const struct hal_cmd_register_module *m = buf; uint8_t status; if (m->service_id > HAL_SERVICE_ID_MAX || services[m->service_id]) { status = HAL_STATUS_FAILED; goto failed; } switch (m->service_id) { case HAL_SERVICE_ID_BLUETOOTH: bt_bluetooth_register(); break; case HAL_SERVICE_ID_SOCK: bt_socket_register(&adapter_bdaddr); break; case HAL_SERVICE_ID_HIDHOST: if (!bt_hid_register(&adapter_bdaddr)) { status = HAL_STATUS_FAILED; goto failed; } break; case HAL_SERVICE_ID_A2DP: if (!bt_a2dp_register(&adapter_bdaddr)) { status = HAL_STATUS_FAILED; goto failed; } break; case HAL_SERVICE_ID_PAN: if (!bt_pan_register(&adapter_bdaddr)) { status = HAL_STATUS_FAILED; goto failed; } break; default: DBG("service %u not supported", m->service_id); status = HAL_STATUS_FAILED; goto failed; } services[m->service_id] = true; status = HAL_STATUS_SUCCESS; info("Service ID=%u registered", m->service_id); failed: ipc_send_rsp(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE, status); }
static void service_register(const void *buf, uint16_t len) { const struct hal_cmd_register_module *m = buf; uint8_t status; if (m->service_id > HAL_SERVICE_ID_MAX || services[m->service_id]) { status = HAL_STATUS_FAILED; goto failed; } switch (m->service_id) { case HAL_SERVICE_ID_BLUETOOTH: if (!bt_bluetooth_register(hal_ipc, m->mode)) { status = HAL_STATUS_FAILED; goto failed; } break; case HAL_SERVICE_ID_SOCKET: bt_socket_register(hal_ipc, &adapter_bdaddr, m->mode); break; case HAL_SERVICE_ID_HIDHOST: if (!bt_hid_register(hal_ipc, &adapter_bdaddr, m->mode)) { status = HAL_STATUS_FAILED; goto failed; } break; case HAL_SERVICE_ID_A2DP: if (!bt_a2dp_register(hal_ipc, &adapter_bdaddr, m->mode)) { status = HAL_STATUS_FAILED; goto failed; } break; case HAL_SERVICE_ID_PAN: if (!bt_pan_register(hal_ipc, &adapter_bdaddr, m->mode)) { status = HAL_STATUS_FAILED; goto failed; } break; case HAL_SERVICE_ID_AVRCP: if (!bt_avrcp_register(hal_ipc, &adapter_bdaddr, m->mode)) { status = HAL_STATUS_FAILED; goto failed; } break; case HAL_SERVICE_ID_HANDSFREE: if (!bt_handsfree_register(hal_ipc, &adapter_bdaddr, m->mode, m->max_clients)) { status = HAL_STATUS_FAILED; goto failed; } break; case HAL_SERVICE_ID_GATT: if (!bt_gatt_register(hal_ipc, &adapter_bdaddr)) { status = HAL_STATUS_FAILED; goto failed; } break; case HAL_SERVICE_ID_HEALTH: if (!bt_health_register(hal_ipc, &adapter_bdaddr, m->mode)) { status = HAL_STATUS_FAILED; goto failed; } break; case HAL_SERVICE_ID_HANDSFREE_CLIENT: if (!bt_hf_client_register(hal_ipc, &adapter_bdaddr)) { status = HAL_STATUS_FAILED; goto failed; } break; case HAL_SERVICE_ID_MAP_CLIENT: if (!bt_map_client_register(hal_ipc, &adapter_bdaddr, m->mode)) { status = HAL_STATUS_FAILED; goto failed; } break; default: DBG("service %u not supported", m->service_id); status = HAL_STATUS_FAILED; goto failed; } services[m->service_id] = true; status = HAL_STATUS_SUCCESS; info("Service ID=%u registered", m->service_id); failed: if(status==HAL_STATUS_FAILED) error("Service ID=%u register failed", m->service_id); ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE, status); }