This patch handles following issues
- Remove double free of Subscription list
- Fix Wrong sync event index for Model List Callback
- Minor code refactoring in Model Subscription List API
Change-Id: I9a6dbf5d34f7ecb387eda7a2868ee788dc4fd215
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
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_NODE_KEY_CONFIGURED:
case BLUETOOTH_EVENT_MESH_NODE_TTL_CONFIGURED:
case BLUETOOTH_EVENT_MESH_MODEL_APPKEY_LIST:
+ case BLUETOOTH_EVENT_MESH_MODEL_SUBSCRIPTION_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_APPKEY_BIND:
case BLUETOOTH_EVENT_MESH_MODEL_SUBSCRIPTION_CONFGURED:
case BLUETOOTH_EVENT_MESH_MODEL_VIRTUAL_SUBSCRIPTION_CONFGURED:
bluetooth_mesh_model_configure_t *res = NULL;
bt_mesh_network_s *network_s = NULL;
bt_mesh_node_s *node_s = NULL;
bluetooth_mesh_model_configure_t *res = NULL;
bt_mesh_network_s *network_s = NULL;
bt_mesh_node_s *node_s = NULL;
+ bt_mesh_model_s *model_s;
+ bt_mesh_element_s *element_s;
GSList *sublist = NULL;
int total = 0;
res = (bluetooth_mesh_model_configure_t *)(param->param_data);
GSList *sublist = NULL;
int total = 0;
res = (bluetooth_mesh_model_configure_t *)(param->param_data);
res->primary_unicast);
if (!node_s)
break;
res->primary_unicast);
if (!node_s)
break;
- bt_mesh_model_s *model_s;
- bt_mesh_element_s *element_s;
element_s = _bt_mesh_get_element_from_index(node_s, res->elem_index);
if (!element_s)
element_s = _bt_mesh_get_element_from_index(node_s, res->elem_index);
if (!element_s)
if (!model_s)
break;
total = res->sublist_count;
if (!model_s)
break;
total = res->sublist_count;
+ BT_INFO("Total Subscription in the model [%d]", total);
for (int i = 0; i < total; i++) {
bt_mesh_group_s *group_s;
group_s = _bt_mesh_network_get_group(network_s, *res->sub_list[i]);
for (int i = 0; i < total; i++) {
bt_mesh_group_s *group_s;
group_s = _bt_mesh_network_get_group(network_s, *res->sub_list[i]);
+ if (!group_s) {
+ BT_INFO("Mesh: Subscription address [0x%2.2x]", *res->sub_list[i]);
+ break;
+ }
sublist = g_slist_append(sublist, group_s);
sublist = g_slist_append(sublist, group_s);
- g_free(res->sub_list[i]);
}
((bt_mesh_model_subscription_list_cb)
bt_event_slot_container[event_index].callback)
}
((bt_mesh_model_subscription_list_cb)
bt_event_slot_container[event_index].callback)
l = g_slist_find_custom(network_s->groups, GUINT_TO_POINTER(group_addr),
(GCompareFunc) __compare_network_group_address);
if (!l) {
l = g_slist_find_custom(network_s->groups, GUINT_TO_POINTER(group_addr),
(GCompareFunc) __compare_network_group_address);
if (!l) {
+
+ BT_INFO("Mesh: Group not available in Network: Addr[0x%2.2x]",
+ group_addr);
group_s = g_malloc0(sizeof(bt_mesh_group_s));
group_s->addr = group_addr;
if (!BT_MESH_IS_GROUP(group_addr))
group_s = g_malloc0(sizeof(bt_mesh_group_s));
group_s->addr = group_addr;
if (!BT_MESH_IS_GROUP(group_addr))
int bt_mesh_model_configure_group_subscription(bt_mesh_model_subscription_op_e model_op,
bt_mesh_model_h model, bt_mesh_group_h group,
bt_mesh_model_subscription_op_cb callback, void *user_data)
int bt_mesh_model_configure_group_subscription(bt_mesh_model_subscription_op_e model_op,
bt_mesh_model_h model, bt_mesh_group_h group,
bt_mesh_model_subscription_op_cb callback, void *user_data)
BT_CHECK_INPUT_PARAMETER(callback);
model_s = (bt_mesh_model_s*) model;
BT_CHECK_INPUT_PARAMETER(callback);
model_s = (bt_mesh_model_s*) model;
- element_s = (bt_mesh_element_s*) model_s->parent;
- node_s = (bt_mesh_node_s*) element_s->parent;
- network_s = (bt_mesh_network_s*) node_s->parent;
+ BT_MESH_VALIDATE_HANDLE(model_s, model_list);
- BT_CHECK_INPUT_PARAMETER(model_s);
+ element_s = (bt_mesh_element_s*) model_s->parent;
BT_CHECK_INPUT_PARAMETER(element_s);
BT_CHECK_INPUT_PARAMETER(element_s);
- BT_CHECK_INPUT_PARAMETER(node_s);
- BT_CHECK_INPUT_PARAMETER(network_s);
-
- BT_MESH_VALIDATE_HANDLE(model_s, model_list);
BT_MESH_VALIDATE_HANDLE(element_s, element_list);
BT_MESH_VALIDATE_HANDLE(element_s, element_list);
+
+ node_s = (bt_mesh_node_s*) element_s->parent;
+ BT_CHECK_INPUT_PARAMETER(node_s);
BT_MESH_VALIDATE_HANDLE(node_s, node_list);
BT_MESH_VALIDATE_HANDLE(node_s, node_list);
+
+ network_s = (bt_mesh_network_s*) node_s->parent;
+ BT_CHECK_INPUT_PARAMETER(network_s);
BT_MESH_VALIDATE_HANDLE(network_s, networks);
/* Return error, if node is not attached */
BT_MESH_VALIDATE_HANDLE(network_s, networks);
/* Return error, if node is not attached */
- _bt_set_cb(BT_EVENT_MESH_NODE_MODEL_APPKEY_LIST, callback, user_data);
+ _bt_set_cb(BT_EVENT_MESH_NODE_MODEL_SUB_LIST, callback, user_data);