static bt_status_t init(const btgatt_callbacks_t *callbacks) { struct hal_cmd_register_module cmd; int ret; DBG(""); if (interface_ready()) return BT_STATUS_DONE; cbs = callbacks; hal_ipc_register(HAL_SERVICE_ID_GATT, ev_handlers, sizeof(ev_handlers)/sizeof(ev_handlers[0])); cmd.service_id = HAL_SERVICE_ID_GATT; ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE, sizeof(cmd), &cmd, 0, NULL, NULL); if (ret != BT_STATUS_SUCCESS) { cbs = NULL; hal_ipc_unregister(HAL_SERVICE_ID_GATT); } return ret; }
static bt_status_t init(bthh_callbacks_t *callbacks) { struct hal_cmd_register_module cmd; int ret; DBG(""); if (interface_ready()) return BT_STATUS_DONE; /* store reference to user callbacks */ cbacks = callbacks; hal_ipc_register(HAL_SERVICE_ID_HIDHOST, ev_handlers, sizeof(ev_handlers)/sizeof(ev_handlers[0])); cmd.service_id = HAL_SERVICE_ID_HIDHOST; cmd.mode = HAL_MODE_DEFAULT; cmd.max_clients = 1; ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE, sizeof(cmd), &cmd, NULL, NULL, NULL); if (ret != BT_STATUS_SUCCESS) { cbacks = NULL; hal_ipc_unregister(HAL_SERVICE_ID_HIDHOST); } return ret; }
static bt_status_t init_real(bthf_callbacks_t *callbacks, int max_hf_clients) { struct hal_cmd_register_module cmd; int ret; DBG(""); if (interface_ready()) return BT_STATUS_DONE; cbs = callbacks; hal_ipc_register(HAL_SERVICE_ID_HANDSFREE, ev_handlers, sizeof(ev_handlers)/sizeof(ev_handlers[0])); cmd.service_id = HAL_SERVICE_ID_HANDSFREE; cmd.mode = get_mode(); cmd.max_clients = max_hf_clients; ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE, sizeof(cmd), &cmd, NULL, NULL, NULL); if (ret != BT_STATUS_SUCCESS) { cbs = NULL; hal_ipc_unregister(HAL_SERVICE_ID_HANDSFREE); } return ret; }
static bt_status_t pan_init(const btpan_callbacks_t *callbacks) { struct hal_cmd_register_module cmd; int ret; DBG(""); if (interface_ready()) return BT_STATUS_DONE; cbs = callbacks; hal_ipc_register(HAL_SERVICE_ID_PAN, ev_handlers, sizeof(ev_handlers)/sizeof(ev_handlers[0])); cmd.service_id = HAL_SERVICE_ID_PAN; cmd.mode = HAL_MODE_DEFAULT; cmd.max_clients = 1; ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE, sizeof(cmd), &cmd, NULL, NULL, NULL); if (ret != BT_STATUS_SUCCESS) { cbs = NULL; hal_ipc_unregister(HAL_SERVICE_ID_PAN); } return ret; }
static bt_status_t init(btmce_callbacks_t *callbacks) { struct hal_cmd_register_module cmd; int ret; DBG(""); /* * Interface ready check was removed because there is no cleanup * function to unregister and clear callbacks. MAP client testers may * restart bluetooth, unregister this profile and try to reuse it. * This situation make service unregistered but callbacks are still * set - interface is ready. On android devices there is no need to * re-init MAP client profile while bluetooth is loaded. */ cbs = callbacks; hal_ipc_register(HAL_SERVICE_ID_MAP_CLIENT, ev_handlers, sizeof(ev_handlers)/sizeof(ev_handlers[0])); cmd.service_id = HAL_SERVICE_ID_MAP_CLIENT; cmd.mode = HAL_MODE_DEFAULT; cmd.max_clients = 1; ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE, sizeof(cmd), &cmd, 0, NULL, NULL); if (ret != BT_STATUS_SUCCESS) { cbs = NULL; hal_ipc_unregister(HAL_SERVICE_ID_MAP_CLIENT); } return ret; }
static void cleanup(void) { DBG(""); if (!interface_ready()) return; hal_ipc_cleanup(); bt_hal_cbacks = NULL; hal_ipc_unregister(HAL_SERVICE_ID_BLUETOOTH); }
static int init(bt_callbacks_t *callbacks) { struct hal_cmd_register_module cmd; int status; DBG(""); if (interface_ready()) return BT_STATUS_DONE; bt_hal_cbacks = callbacks; hal_ipc_register(HAL_SERVICE_ID_BLUETOOTH, ev_handlers, sizeof(ev_handlers)/sizeof(ev_handlers[0])); if (!hal_ipc_init()) { bt_hal_cbacks = NULL; return BT_STATUS_FAIL; } cmd.service_id = HAL_SERVICE_ID_BLUETOOTH; 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"); goto fail; } cmd.service_id = HAL_SERVICE_ID_SOCK; 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"); goto fail; } return status; fail: hal_ipc_cleanup(); bt_hal_cbacks = NULL; hal_ipc_unregister(HAL_SERVICE_ID_BLUETOOTH); return status; }
static void cleanup(void) { struct hal_cmd_unregister_module cmd; DBG(""); if (!interface_ready()) return; cmd.service_id = HAL_SERVICE_ID_HIDHOST; hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_UNREGISTER_MODULE, sizeof(cmd), &cmd, NULL, NULL, NULL); hal_ipc_unregister(HAL_SERVICE_ID_HIDHOST); cbacks = NULL; }