diff options
Diffstat (limited to 'src/bluetooth-common.c')
-rw-r--r-- | src/bluetooth-common.c | 76 |
1 files changed, 60 insertions, 16 deletions
diff --git a/src/bluetooth-common.c b/src/bluetooth-common.c index a2f45d9..e553f3f 100644 --- a/src/bluetooth-common.c +++ b/src/bluetooth-common.c @@ -292,7 +292,7 @@ static bt_event2index_table_t event2index[] = { { BLUETOOTH_EVENT_MESH_NODE_VENDOR_FEATURES, BT_EVENT_MESH_NODE_VENDOR_FEATURES }, { BLUETOOTH_EVENT_MESH_NODE_KEY_CONFIGURED, BT_EVENT_MESH_NODE_KEY_CONFIGURATION_COMPLETED }, { BLUETOOTH_EVENT_MESH_NODE_TTL_CONFIGURED, BT_EVENT_MESH_NODE_TTL_EXECUTE_COMPLETED }, - { BLUETOOTH_EVENT_MESH_NODE_MODEL_APPKEY_BIND, BT_EVENT_MESH_NODE_MODEL_BIND_APPKEY_COMPLETED }, + { BLUETOOTH_EVENT_MESH_MODEL_APPKEY_BIND, BT_EVENT_MESH_NODE_MODEL_BIND_APPKEY_COMPLETED }, { BLUETOOTH_EVENT_MESH_MODEL_APPKEY_LIST, BT_EVENT_MESH_NODE_MODEL_APPKEY_LIST }, { BLUETOOTH_EVENT_MESH_MODEL_SUBSCRIPTION_LIST, BT_EVENT_MESH_NODE_MODEL_SUB_LIST }, { BLUETOOTH_EVENT_MESH_MODEL_SUBSCRIPTION_CONFGURED, BT_EVENT_MESH_NODE_MODEL_GROUP_SUB }, @@ -1425,6 +1425,7 @@ static bool __bt_need_to_handle(int event) case BLUETOOTH_EVENT_MESH_NODE_KEY_CONFIGURED: case BLUETOOTH_EVENT_MESH_NODE_TTL_CONFIGURED: case BLUETOOTH_EVENT_MESH_MODEL_APPKEY_LIST: + case BLUETOOTH_EVENT_MESH_MODEL_APPKEY_BIND: case BLUETOOTH_EVENT_MESH_MODEL_SUBSCRIPTION_CONFGURED: case BLUETOOTH_EVENT_MESH_MODEL_VIRTUAL_SUBSCRIPTION_CONFGURED: case BLUETOOTH_EVENT_MESH_MODEL_PUBLICATION_STATUS: @@ -3872,6 +3873,49 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us bt_event_slot_container[event_index].user_data); break; } + case BLUETOOTH_EVENT_MESH_MODEL_APPKEY_BIND: { + BT_INFO("BLUETOOTH_EVENT_MESH_MODEL_APPKEY_BIND"); + bluetooth_mesh_model_configure_t *res = NULL; + bt_mesh_model_s *model_s = NULL; + bt_mesh_appkey_s *appkey_s = NULL; + bt_mesh_network_s *network_s = NULL; + res = (bluetooth_mesh_model_configure_t *)(param->param_data); + + network_s = _bt_mesh_get_network_handle_info(res->net_uuid); + if (!network_s) + break; + + BT_INFO("Mesh: Model AppKey %s Result", res->is_bind? "Bind" : "UnBind"); + model_s = _bt_mesh_get_node_get_model_from_element(res->net_uuid, + res->primary_unicast, res->elem_index, res->model); + if (!model_s) + break; + + appkey_s = _bt_mesh_network_get_appkey_from_index(network_s, res->appkey_idx); + if (!appkey_s) + break; + + if (_bt_get_error_code(param->result) == BT_ERROR_NONE) + BT_INFO("Mesh: Model AppKey Configuration: SUCCESS"); + else + BT_INFO("Mesh: Model AppKey Configuration: FAILED"); + + if (res->is_bind) + ((bt_mesh_model_bind_cb) + bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), + (bt_mesh_model_h) model_s, + (bt_mesh_appkey_h) appkey_s, + bt_event_slot_container[event_index].user_data); + else + ((bt_mesh_model_unbind_cb) + bt_event_slot_container[event_index].callback) + (_bt_get_error_code(param->result), + (bt_mesh_model_h) model_s, + (bt_mesh_appkey_h)appkey_s, + bt_event_slot_container[event_index].user_data); + break; + } /* Fall through */ case BLUETOOTH_EVENT_MESH_MODEL_SUBSCRIPTION_CONFGURED: case BLUETOOTH_EVENT_MESH_MODEL_VIRTUAL_SUBSCRIPTION_CONFGURED: { @@ -3981,42 +4025,42 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us bluetooth_mesh_model_configure_t *res = NULL; bt_mesh_network_s *info = NULL; bt_mesh_node_s *node_s = NULL; + bt_mesh_model_s *model_s; + bt_mesh_element_s *element_s; GSList *appkeylist = NULL; int total = 0; res = (bluetooth_mesh_model_configure_t *)(param->param_data); + BT_INFO("Mesh: Model AppKey List result for Network [%s]", + res->net_uuid); info = _bt_mesh_get_network_handle_info(res->net_uuid); if (!info) break; + model_s = _bt_mesh_get_node_get_model_from_element(res->net_uuid, + res->primary_unicast, res->elem_index, res->model); + if (!model_s) + break; + + element_s = model_s->parent; + node_s = element_s->parent; if (_bt_get_error_code(param->result) == BT_ERROR_NONE) BT_INFO("Mesh: Node Model AppKeyList: SUCCESS"); else BT_INFO("Mesh: Node Model AppKeyList : FAILED"); - node_s = _bt_mesh_get_node_from_unicast(res->net_uuid, - res->primary_unicast); - if (!node_s) - break; - bt_mesh_model_s *model_s; - bt_mesh_element_s *element_s; total = res->appkeylist_count; + BT_INFO("Mesh: Total Appkeys Bound to Model [%d]", total); for (int i = 0; i < total; i++) { bt_mesh_appkey_s *appkey; appkey = _bt_mesh_node_get_appkey(node_s, *res->appkey_list[i]); - if (appkey) + if (appkey) { + BT_INFO("Mesh: AppKey found for Index [%d]", *res->appkey_list[i]); appkeylist = g_slist_append(appkeylist, appkey); - /* Free memory */ - g_free(res->appkey_list[i]); + } } - element_s = _bt_mesh_get_element_from_index(node_s, res->elem_index); - if (!element_s) - break; - model_s = _bt_mesh_get_model_from_modelid(element_s, res->model); - if (!model_s) - break; ((bt_mesh_model_appkey_list_cb) bt_event_slot_container[event_index].callback) (_bt_get_error_code(param->result), (bt_mesh_model_h) model_s, |