/* TODO Reset the remote node, as no response is expected on reset command */
- switch(req->cmd->opcode) {
+ switch (req->cmd->opcode) {
case MESH_OPCODE_DEV_COMP_GET: {
- /* Send event with timeout */
+ /* Send event with timeout for Vendor Features */
+ bluetooth_mesh_node_features_t *vendor_event = \
+ g_malloc0(sizeof(bluetooth_mesh_node_features_t));
+
+ _bt_mesh_util_convert_hex_to_string((uint8_t *) req->net_uuid, 16,
+ vendor_event->net_uuid,
+ BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
+ vendor_event->unicast = req->addr;
+ __bt_mesh_handle_pending_dev_config_request_info(
+ BLUETOOTH_ERROR_TIMEOUT, BT_MESH_NODE_GET_VENDOR_FEATURES,
+ vendor_event, sizeof(bluetooth_mesh_node_features_t));
+ g_free(vendor_event);
+
+ /* Send event with timeout for Node Browse */
event_mesh_devkey_message_t *event = \
g_malloc0(sizeof(event_mesh_devkey_message_t));
memcpy(event->net_uuid.uuid, req->net_uuid, 16);
event->source = req->addr;
+
__bt_mesh_handle_pending_dev_config_request_info(
BLUETOOTH_ERROR_TIMEOUT, BT_MESH_NODE_BROWSE,
event, sizeof(event_mesh_devkey_message_t));
+
g_free(event);
break;
}
+ case MESH_OPCODE_CONFIG_MODEL_SUB_GET:
+ case MESH_OPCODE_CONFIG_VEND_MODEL_SUB_GET:
+ BT_INFO("Mesh: Command TimedOut: Model Subscription list get");
+ /* Send event with timeout */
+ __bt_mesh_handle_pending_dev_config_request_info(
+ BLUETOOTH_ERROR_TIMEOUT,
+ BT_MESH_MODEL_GET_SUBSCRIPTION_LIST, req->data,
+ sizeof(bluetooth_mesh_model_configure_t));
+ break;
case MESH_OPCODE_NETKEY_ADD:
case MESH_OPCODE_NETKEY_UPDATE:
case MESH_OPCODE_NETKEY_DELETE:
BT_MESH_NODE_TTL_EXECUTE, req->data,
sizeof(bluetooth_mesh_node_ttl_info_t));
break;
+ case MESH_OPCODE_CONFIG_MODEL_SUB_ADD:
+ case MESH_OPCODE_CONFIG_MODEL_SUB_DELETE:
+ case MESH_OPCODE_CONFIG_MODEL_SUB_OVERWRITE:
+ /* Send event with timeout */
+ __bt_mesh_handle_pending_dev_config_request_info(
+ BLUETOOTH_ERROR_TIMEOUT,
+ BT_MESH_MODEL_CONFIG_GROUP_SUB, req->data,
+ sizeof(bluetooth_mesh_model_configure_t));
+ break;
+ case MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_ADD:
+ case MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_DELETE:
+ case MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_OVERWRITE:
+ /* Send event with timeout */
+ __bt_mesh_handle_pending_dev_config_request_info(
+ BLUETOOTH_ERROR_TIMEOUT,
+ BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB, req->data,
+ sizeof(bluetooth_mesh_model_configure_t));
+ break;
+ case MESH_OPCODE_CONFIG_MODEL_SUB_DELETE_ALL:
+ /* Send event with timeout */
+ __bt_mesh_handle_pending_dev_config_request_info(
+ BLUETOOTH_ERROR_TIMEOUT,
+ BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB, req->data,
+ sizeof(bluetooth_mesh_model_configure_t));
+ /* Send event with timeout */
+ __bt_mesh_handle_pending_dev_config_request_info(
+ BLUETOOTH_ERROR_TIMEOUT,
+ BT_MESH_MODEL_CONFIG_GROUP_SUB, req->data,
+ sizeof(bluetooth_mesh_model_configure_t));
+ break;
+ case MESH_OPCODE_CONFIG_MODEL_PUB_GET:
+ /* Send event with timeout */
+ __bt_mesh_handle_pending_dev_config_request_info(
+ BLUETOOTH_ERROR_TIMEOUT,
+ BT_MESH_MODEL_GET_PUBLICATION, req->data,
+ sizeof(bluetooth_mesh_model_configure_t));
+ break;
+ case MESH_OPCODE_CONFIG_MODEL_PUB_SET:
+ /* Send event with timeout */
+ __bt_mesh_handle_pending_dev_config_request_info(
+ BLUETOOTH_ERROR_TIMEOUT,
+ BT_MESH_MODEL_SET_PUBLICATION, req->data,
+ sizeof(bluetooth_mesh_model_configure_t));
+ break;
+ case MESH_OPCODE_MODEL_APP_BIND:
+ case MESH_OPCODE_MODEL_APP_UNBIND:
+ /* Send event with timeout */
+ __bt_mesh_handle_pending_dev_config_request_info(
+ BLUETOOTH_ERROR_TIMEOUT,
+ BT_MESH_MODEL_CONFIGURE_APPKEY, req->data,
+ sizeof(bluetooth_mesh_model_configure_t));
+ break;
default:
break;
}
+ BT_INFO("Mesh: Number of pending requests [%u] Remove the req",
+ l_queue_length(pending_requests));
l_queue_remove(pending_requests, req);
__mesh_request_remove(req);
}
{
struct mesh_pending_request *req;
const struct mesh_config_cmd *cmd;
+ char uuid_str[33];
cmd = __mesh_get_command(opcode);
if (!cmd)
return;
+ _bt_mesh_util_convert_hex_to_string((uint8_t *) net_uuid, 16, uuid_str,
+ BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
+ BT_INFO("Mesh: Net UUID[%s]", uuid_str);
+ BT_INFO("Mesh: Adding command opcode [0x%2.2x] response [0x%2.2x]",
+ cmd->opcode, cmd->response);
req = l_new(struct mesh_pending_request, 1);
req->cmd = cmd;
req->addr = dest;
memcpy(req->net_uuid, net_uuid, 16);
req->timer = l_timeout_create(MESH_DEFAULT_RESPONSE_TIMEOUT,
__bt_mesh_wait_response_timeout, req, NULL);
+
+ if (!pending_requests)
+ pending_requests = l_queue_new();
l_queue_push_tail(pending_requests, req);
+ BT_INFO("Mesh: Number of pending requests [%u]", l_queue_length(pending_requests));
}
static struct mesh_pending_request *__bt_mesh_get_request_by_response(
uint32_t response)
{
const struct l_queue_entry *entry;
+ char uuid_str[33];
+ char uuid_str1[33];
+ BT_INFO("Mesh: Number of pending requests [%u]", l_queue_length(pending_requests));
entry = l_queue_get_entries(pending_requests);
for (; entry; entry = entry->next) {
struct mesh_pending_request *req = entry->data;
+ /* Test */
+ BT_INFO("Mesh: Req addr [0x%2.2x] req opcode [0x%2.2x] res [0x%2.2x]", req->addr, req->cmd->opcode, req->cmd->response);
+ BT_INFO("Mesh: Current req addr [0x%2.2x] res [0x%2.2x]", addr, response);
+ _bt_mesh_util_convert_hex_to_string((uint8_t *) net_uuid, 16, uuid_str,
+ BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
+ BT_INFO("Mesh: Net UUID[%s]", uuid_str);
+
+ _bt_mesh_util_convert_hex_to_string((uint8_t *) req->net_uuid, 16, uuid_str1,
+ BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
+ BT_INFO("Mesh: Net UUID1[%s]", uuid_str1);
if (!memcmp(net_uuid, req->net_uuid, 16) &&
req->addr == addr &&
req->cmd->response == response)
GArray *info = NULL;
if (BLUETOOTH_ERROR_NONE == result) {
+ BT_INFO("Mesh: Model ID [0x%4.4x]", evt->model);
+ BT_INFO("Mesh: Model Publication Address [0x%2.2x]", evt->pub_addr);
/* Send event */
info = g_array_new(FALSE, FALSE, sizeof(gchar));
- g_array_append_vals(info, &evt,
+ g_array_append_vals(info, evt,
sizeof(bluetooth_mesh_model_configure_t));
out_var = g_variant_new_from_data((const GVariantType *)"ay",
if (BLUETOOTH_ERROR_NONE == result) {
/* Send event */
info = g_array_new(FALSE, FALSE, sizeof(gchar));
- g_array_append_vals(info, &evt,
+ g_array_append_vals(info, evt,
sizeof(bluetooth_mesh_model_configure_t));
out_var = g_variant_new_from_data((const GVariantType *)"ay",
GVariant *param = NULL;
GVariantBuilder *builder = NULL;
int i;
+ char *net_uuid;
if (BLUETOOTH_ERROR_NONE == result) {
- if (evt->sublist_count) {
- builder = g_variant_builder_new(G_VARIANT_TYPE("aq"));
- for (i = 0; i < evt->sublist_count; i++)
- g_variant_builder_add(builder, "q", *evt->sub_list[i]);
+ BT_INFO("Mesh: Total Subscriptions bound to model [%d]",
+ evt->sublist_count);
+ BT_INFO("Mesh: Network [%s]", evt->net_uuid);
+ builder = g_variant_builder_new(G_VARIANT_TYPE("aq"));
+ for (i = 0; i < evt->sublist_count; i++) {
+ BT_INFO("Mesh: Subscription Address [0x%2.2x]",
+ *evt->sub_list[i]);
+ g_variant_builder_add(builder, "q", *evt->sub_list[i]);
+ }
- param = g_variant_new("(isqiui(aq))", result, evt->net_uuid,
- evt->primary_unicast, evt->elem_index, evt->model,
- evt->sublist_count, builder);
+ net_uuid = g_strdup(evt->net_uuid);
+ param = g_variant_new("(isqiui(aq))", result, net_uuid,
+ evt->primary_unicast, evt->elem_index, evt->model,
+ evt->sublist_count, builder);
+
+ g_variant_builder_unref(builder);
- g_variant_builder_unref(builder);
- }
/* Send event */
_bt_send_event(BT_MESH_EVENT,
BLUETOOTH_EVENT_MESH_MODEL_SUBSCRIPTION_LIST,
g_free(evt->sub_list[i]);
g_free(evt->sub_list);
}
+ g_free(net_uuid);
+ BT_INFO("freed net uuid");
}
}
{
GVariant *param = NULL;
GVariantBuilder *builder = NULL;
+ char *net_uuid;
int i;
if (BLUETOOTH_ERROR_NONE == result) {
-
- if (evt->appkeylist_count) {
- builder = g_variant_builder_new(G_VARIANT_TYPE("aq"));
- for (i = 0; i < evt->appkeylist_count; i++)
- g_variant_builder_add(builder, "q", *evt->appkey_list[i]);
-
- param = g_variant_new("(isqiui(aq))", result, evt->net_uuid,
- evt->primary_unicast, evt->elem_index, evt->model,
- evt->appkeylist_count, builder);
-
- g_variant_builder_unref(builder);
- }
+ builder = g_variant_builder_new(G_VARIANT_TYPE("aq"));
+ BT_INFO("Mesh: Total AppKeys bound to model [%d]",
+ evt->appkeylist_count);
+ BT_INFO("Mesh: Network [%s]", evt->net_uuid);
+ for (i = 0; i < evt->appkeylist_count; i++)
+ g_variant_builder_add(builder, "q", *evt->appkey_list[i]);
+ net_uuid = g_strdup(evt->net_uuid);
+ param = g_variant_new("(isqiui(aq))", result, net_uuid,
+ evt->primary_unicast, evt->elem_index, evt->model,
+ evt->appkeylist_count, builder);
+
+ g_variant_builder_unref(builder);
/* Send event */
_bt_send_event(BT_MESH_EVENT,
param);
if (evt->appkeylist_count) {
- /* Free List data */
for (int i = 0; i < evt->appkeylist_count; i++)
g_free(evt->appkey_list[i]);
+
g_free(evt->appkey_list);
}
+ /* Free List data */
+ g_free(net_uuid);
}
}
if (BLUETOOTH_ERROR_NONE == result) {
/* Send event */
info = g_array_new(FALSE, FALSE, sizeof(gchar));
- g_array_append_vals(info, &evt, sizeof(bluetooth_mesh_model_configure_t));
+ g_array_append_vals(info, evt, sizeof(bluetooth_mesh_model_configure_t));
out_var = g_variant_new_from_data((const GVariantType *)"ay",
info->data, info->len,
param = g_variant_new("(iv)", result, out_var);
_bt_send_event(BT_MESH_EVENT,
- BLUETOOTH_EVENT_MESH_NODE_MODEL_APPKEY_BIND,
+ BLUETOOTH_EVENT_MESH_MODEL_APPKEY_BIND,
param);
}
}
if (BLUETOOTH_ERROR_NONE == result) {
/* Send event */
info = g_array_new(FALSE, FALSE, sizeof(gchar));
- g_array_append_vals(info, &ttl_evt,
+ g_array_append_vals(info, ttl_evt,
sizeof(bluetooth_mesh_node_ttl_info_t));
out_var = g_variant_new_from_data((const GVariantType *)"ay",
if (BLUETOOTH_ERROR_NONE == result) {
/* Send event */
info = g_array_new(FALSE, FALSE, sizeof(gchar));
- g_array_append_vals(info, &key_evt,
+ g_array_append_vals(info, key_evt,
sizeof(bluetooth_mesh_key_configure_t));
out_var = g_variant_new_from_data((const GVariantType *)"ay",
if (BLUETOOTH_ERROR_NONE == result) {
/* Send event */
info = g_array_new(FALSE, FALSE, sizeof(gchar));
- g_array_append_vals(info, &features_evt,
+ g_array_append_vals(info, features_evt,
sizeof(bluetooth_mesh_node_features_t));
out_var = g_variant_new_from_data((const GVariantType *)"ay",
if (BLUETOOTH_ERROR_NONE == result) {
/* Send event */
info = g_array_new(FALSE, FALSE, sizeof(gchar));
- g_array_append_vals(info, &browse_evt,
+ g_array_append_vals(info, browse_evt,
sizeof(bluetooth_mesh_node_discover_t));
out_var = g_variant_new_from_data((const GVariantType *)"ay",
event->unicast = req->unicast;
event->elem_count = req->elem_count;
+ /* Send Event */
+ __bt_mesh_send_node_get_vendor_features_event(result, event);
+
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(out_param, event, sizeof(bluetooth_mesh_node_features_t));
/* Return DBUS Invocation*/
_bt_service_method_return(req_info->context, out_param, result);
_bt_free_info_from_invocation_list(req_info);
- g_free(req_info->user_data);
g_array_free(out_param, TRUE);
-
- /* Send Event */
- __bt_mesh_send_node_get_vendor_features_event(result, event);
}
break;
}
event = (event_mesh_devkey_message_t*) param;
node = (bluetooth_mesh_node_discover_t*)req_info->user_data;
+ BT_INFO("Mesh: Request Node UUID [%s]", node->dev_uuid);
+ BT_INFO("Mesh: Request Network UUID [%s]", node->net_uuid);
_bt_mesh_util_convert_hex_to_string((uint8_t *) event->net_uuid.uuid, 16, net_uuid,
BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
BT_DBG("Request Sender: [%s]", req_info->sender);
/* Match Network and Remote Node unicast*/
if (!g_strcmp0(node->net_uuid, net_uuid) && remote_addr == event->source) {
- out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
- g_array_append_vals(out_param, node, sizeof(bluetooth_mesh_node_discover_t));
-
_bt_mesh_node_get_element_count(event->net_uuid.uuid, remote_addr, &elem_count);
node->unicast = event->source;
node->count = elem_count;
+ BT_INFO("Mesh: Browse event for Node: Unicast [0x%2.2x] Element Count [%d]",
+ node->unicast, elem_count);
+ /* Send Event */
+ __bt_mesh_send_node_browsed_event(result, node);
+
+ out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
+ g_array_append_vals(out_param, node, sizeof(bluetooth_mesh_node_discover_t));
/* Return DBUS Invocation*/
_bt_service_method_return(req_info->context, out_param, result);
_bt_free_info_from_invocation_list(req_info);
- g_free(req_info->user_data);
g_array_free(out_param, TRUE);
- /* Send Event */
- __bt_mesh_send_node_browsed_event(result, node);
}
}
break;
if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
req->primary_unicast == event->primary_unicast &&
req->is_netkey == event->is_netkey) {
+ /* Send Event */
+ __bt_mesh_send_node_key_configuration_event(result, event);
+
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(out_param, event, sizeof(bluetooth_mesh_key_configure_t));
/* Return DBUS Invocation*/
_bt_service_method_return(req_info->context, out_param, result);
_bt_free_info_from_invocation_list(req_info);
- g_free(req_info->user_data);
g_array_free(out_param, TRUE);
-
- /* Send Event */
- __bt_mesh_send_node_key_configuration_event(result, event);
- }
+ }
break;
}
case BT_MESH_NODE_TTL_EXECUTE: {
if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
req->unicast == event->unicast) {
+ /* Send Event */
+ __bt_mesh_send_node_ttl_configuration_event(result, req);
+
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(out_param, req, sizeof(bluetooth_mesh_node_ttl_info_t));
/* Return DBUS Invocation*/
_bt_service_method_return(req_info->context, out_param, result);
_bt_free_info_from_invocation_list(req_info);
- g_free(req_info->user_data);
g_array_free(out_param, TRUE);
-
- /* Send Event */
- __bt_mesh_send_node_ttl_configuration_event(result, req);
}
break;
}
if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
req->primary_unicast == event->primary_unicast) {
+ /* Send Event */
+ __bt_mesh_send_model_configure_appkey_event(result, req);
+
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(out_param, req, sizeof(bluetooth_mesh_model_configure_t));
/* Return DBUS Invocation*/
_bt_service_method_return(req_info->context, out_param, result);
_bt_free_info_from_invocation_list(req_info);
- g_free(req_info->user_data);
g_array_free(out_param, TRUE);
-
- /* Send Event */
- __bt_mesh_send_model_configure_appkey_event(result, req);
}
break;
if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
req->primary_unicast == event->primary_unicast) {
+ /* Send Event */
+ __bt_mesh_send_model_get_appkey_list_event(result, event);
+
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(out_param, req, sizeof(bluetooth_mesh_model_configure_t));
/* Return DBUS Invocation*/
_bt_service_method_return(req_info->context, out_param, result);
_bt_free_info_from_invocation_list(req_info);
- g_free(req_info->user_data);
g_array_free(out_param, TRUE);
-
- /* Send Event */
- __bt_mesh_send_model_get_appkey_list_event(result, event);
}
break;
}
bluetooth_mesh_model_configure_t *event;
bluetooth_mesh_model_configure_t *req;
+ BT_INFO("Mesh: Handle event for BT_MESH_MODEL_GET_SUBSCRIPTION_LIST");
event = (bluetooth_mesh_model_configure_t*) param;
req = (bluetooth_mesh_model_configure_t*)req_info->user_data;
if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
req->primary_unicast == event->primary_unicast) {
+ /* Send Event */
+ __bt_mesh_send_model_get_subscription_list_event(result, event);
+
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(out_param, req, sizeof(bluetooth_mesh_model_configure_t));
/* Return DBUS Invocation*/
_bt_service_method_return(req_info->context, out_param, result);
_bt_free_info_from_invocation_list(req_info);
- g_free(req_info->user_data);
g_array_free(out_param, TRUE);
-
- /* Send Event */
- __bt_mesh_send_model_get_subscription_list_event(result, event);
}
break;
}
event = (bluetooth_mesh_model_configure_t*) param;
req = (bluetooth_mesh_model_configure_t*)req_info->user_data;
+ BT_INFO("Mesh: Event Network [%s] Req Network [%s]",
+ event->net_uuid, req->net_uuid);
+
+ BT_INFO("Mesh: Event Unicast [0x%4.4x] Req Unicast [0x%4.4x]",
+ event->primary_unicast, req->primary_unicast);
if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
req->primary_unicast == event->primary_unicast) {
req->sub_addr = event->sub_addr;
+ BT_INFO("Mesh: Send event for Model Subscription");
+ /* Send Event */
+ __bt_mesh_send_model_subscription_configure_event(
+ BLUETOOTH_EVENT_MESH_MODEL_SUBSCRIPTION_CONFGURED,
+ result, req);
+
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(out_param, req, sizeof(bluetooth_mesh_model_configure_t));
/* Return DBUS Invocation*/
_bt_service_method_return(req_info->context, out_param, result);
_bt_free_info_from_invocation_list(req_info);
- g_free(req_info->user_data);
g_array_free(out_param, TRUE);
-
- /* Send Event */
- __bt_mesh_send_model_subscription_configure_event( \
- BLUETOOTH_EVENT_MESH_MODEL_SUBSCRIPTION_CONFGURED, \
- result, req);
}
break;
}
event = (bluetooth_mesh_model_configure_t*) param;
req = (bluetooth_mesh_model_configure_t*)req_info->user_data;
+ BT_INFO("Mesh: Event Network [%s] Req Network [%s]",
+ event->net_uuid, req->net_uuid);
+ BT_INFO("Mesh: Event Unicast [0x%4.4x] Req Unicast [0x%4.4x]",
+ event->primary_unicast, req->primary_unicast);
if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
req->primary_unicast == event->primary_unicast) {
+ /* Send Event */
+ __bt_mesh_send_model_subscription_configure_event( \
+ BLUETOOTH_EVENT_MESH_MODEL_VIRTUAL_SUBSCRIPTION_CONFGURED, \
+ result, req);
+
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(out_param, req, sizeof(bluetooth_mesh_model_configure_t));
/* Return DBUS Invocation*/
_bt_service_method_return(req_info->context, out_param, result);
_bt_free_info_from_invocation_list(req_info);
- g_free(req_info->user_data);
g_array_free(out_param, TRUE);
- /* Send Event */
- __bt_mesh_send_model_subscription_configure_event( \
- BLUETOOTH_EVENT_MESH_MODEL_VIRTUAL_SUBSCRIPTION_CONFGURED, \
- result, req);
}
break;
}
case BT_MESH_MODEL_GET_PUBLICATION: {
+ BT_INFO("Mesh: Event for Model Get Publication Request");
bluetooth_mesh_model_configure_t *event;
bluetooth_mesh_model_configure_t *req;
req = (bluetooth_mesh_model_configure_t*)req_info->user_data;
if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
- req->primary_unicast == event->primary_unicast) {
+ req->primary_unicast == event->primary_unicast) {
+ /* Send Event */
+ BT_INFO("Mesh: Send Model Publication status for Get Request");
+ __bt_mesh_send_model_publication_status_event( \
+ BLUETOOTH_EVENT_MESH_MODEL_PUBLICATION_STATUS, \
+ result, event);
+
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(out_param, req, sizeof(bluetooth_mesh_model_configure_t));
/* Return DBUS Invocation*/
_bt_service_method_return(req_info->context, out_param, result);
_bt_free_info_from_invocation_list(req_info);
- g_free(req_info->user_data);
g_array_free(out_param, TRUE);
-
- /* Send Event */
- __bt_mesh_send_model_publication_status_event( \
- BLUETOOTH_EVENT_MESH_MODEL_PUBLICATION_STATUS, \
- result, event);
- }
+ }
break;
}
case BT_MESH_MODEL_SET_PUBLICATION: {
+ BT_INFO("Mesh: Event for Model Set Publication Request");
bluetooth_mesh_model_configure_t *event;
bluetooth_mesh_model_configure_t *req;
if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
req->primary_unicast == event->primary_unicast) {
+ /* Send Event */
+ BT_INFO("Mesh: Send Model Publication status for Set Request");
+ __bt_mesh_send_model_publication_status_event( \
+ BLUETOOTH_EVENT_MESH_MODEL_PUBLICATION_STATUS, \
+ result, req);
+
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(out_param, req, sizeof(bluetooth_mesh_model_configure_t));
/* Return DBUS Invocation*/
_bt_service_method_return(req_info->context, out_param, result);
_bt_free_info_from_invocation_list(req_info);
- g_free(req_info->user_data);
g_array_free(out_param, TRUE);
-
- /* Send Event */
- __bt_mesh_send_model_publication_status_event( \
- BLUETOOTH_EVENT_MESH_MODEL_PUBLICATION_STATUS, \
- result, req);
- }
+ }
break;
}
default:
bluetooth_mesh_model_configure_t *param,
const struct mesh_config_cmd *cmd)
{
+ BT_INFO("Mesh: Model Subscription Event: Request [%d]", cmd->opcode);
switch (cmd->opcode) {
/* Fall through */
case MESH_OPCODE_CONFIG_MODEL_SUB_ADD:
case MESH_OPCODE_CONFIG_MODEL_SUB_DELETE:
case MESH_OPCODE_CONFIG_MODEL_SUB_OVERWRITE:
- case MESH_OPCODE_CONFIG_MODEL_SUB_DELETE_ALL:
/* Model Bind/UnBind Event */
+ BT_INFO("Mesh: Handle Event for Request: BT_MESH_MODEL_CONFIG_GROUP_SUB");
__bt_mesh_handle_pending_dev_config_request_info(result,
- BT_MESH_MODEL_CONFIG_GROUP_SUB, ¶m,
+ BT_MESH_MODEL_CONFIG_GROUP_SUB, param,
sizeof(bluetooth_mesh_model_configure_t));
break;
case MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_ADD:
case MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_DELETE:
case MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_OVERWRITE:
+ BT_INFO("Mesh: Handle Event for Request: BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB");
+ __bt_mesh_handle_pending_dev_config_request_info(result,
+ BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB, param,
+ sizeof(bluetooth_mesh_model_configure_t));
+ break;
+ case MESH_OPCODE_CONFIG_MODEL_SUB_DELETE_ALL:
+ BT_INFO("Mesh: Handle Event for Request: MESH_OPCODE_CONFIG_MODEL_SUB_DELETE_ALL");
+ __bt_mesh_handle_pending_dev_config_request_info(result,
+ BT_MESH_MODEL_CONFIG_GROUP_SUB, param,
+ sizeof(bluetooth_mesh_model_configure_t));
__bt_mesh_handle_pending_dev_config_request_info(result,
- BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB, ¶m,
+ BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB, param,
sizeof(bluetooth_mesh_model_configure_t));
break;
default:
struct mesh_pending_request *req;
if (_bt_mesh_util_opcode_get(data, data_len, &opcode, &n)) {
+ BT_INFO("Mesh: Opcode of response data [0x%2.2x], actual data len [%d]", opcode, n);
data_len -= n;
data += n;
} else
return;
- BT_INFO("Mesh: Received %s (len %u)",
- __mesh_get_opcode_string(opcode), data_len);
+ BT_INFO("Mesh: Received %s (len %u) opcode [0x%2.2x]",
+ __mesh_get_opcode_string(opcode), data_len, opcode);
req = __bt_mesh_get_request_by_response(event->source,
event->net_uuid.uuid, (opcode & ~MESH_OPCODE_UNRELIABLE));
if (req) {
+ BT_INFO("Mesh: Got Config Request");
cmd = req->cmd;
__mesh_request_remove(req);
l_queue_remove(pending_requests, req);
switch (opcode & ~MESH_OPCODE_UNRELIABLE) {
- default:
- return;
+ default:
+ return;
case MESH_OPCODE_CONFIG_MODEL_PUB_STATUS: {
if (data_len != 12 && data_len != 14)
break;
event->source, __mesh_status_to_string(data[0]));
if (data[0] != MESH_STATUS_SUCCESS)
- break;
+ result = BLUETOOTH_ERROR_INTERNAL;
/* Extract Element Address */
ele_addr = l_get_le16(data + 1);
mod_id = MESH_VENDOR_ID_MASK | mod_id;
}
+ param.model = mod_id;
+ BT_INFO("Model ID\t%4.4x\n", mod_id);
+
param.primary_unicast = event->source;
param.elem_index = ele_addr - event->source;
/* Extract Publish Address */
param.pub_addr = l_get_le16(data + 3);
+ BT_INFO("Mesh: Pub Address [0x%2.2x]", param.pub_addr);
/* Extract Appkey Index */
param.appkey_idx = l_get_le16(data + 5);
+ BT_INFO("Mesh: AppKey Idx [0x%2.2x]", param.appkey_idx);
/* Extract TTL */
param.ttl = data[6];
+ BT_INFO("Mesh: TTL [0x%x]", param.ttl);
/* Extract Period */
param.period = data[7];
+ if (!cmd)
+ break;
if (cmd->opcode == MESH_OPCODE_CONFIG_MODEL_PUB_GET)
__bt_mesh_handle_pending_dev_config_request_info(result,
BT_INFO("\nNode %4.4x Subscription status %s\n",
event->source, __mesh_status_to_string(data[0]));
+ if (data[0] != MESH_STATUS_SUCCESS)
+ result = BLUETOOTH_ERROR_INTERNAL;
+
+ if (!cmd) {
+ BT_INFO("Mesh: Command not found!!");
+ break;
+ }
+
ele_addr = l_get_le16(data + 1);
addr = l_get_le16(data + 3);
BT_INFO("Element Addr\t%4.4x\n", ele_addr);
+ BT_INFO("Message Source Addr\t%4.4x\n", event->source);
if (data_len == 9) {
/* vendor Model */
param.sub_addr = addr;
param.model = mod_id;
BT_INFO("Subscr Addr\t%4.4x\n", addr);
- __mesh_handle_model_subscription_event(result, ¶m, cmd);
+ BT_INFO("Model ID\t%4.4x\n", mod_id);
+
+ if (data[0] == MESH_STATUS_SUCCESS) {
+ /* Update cdb */
+ switch (cmd->opcode) {
+ case MESH_OPCODE_CONFIG_MODEL_SUB_ADD:
+ case MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_ADD:
+ if (!_bt_mesh_network_add_model_subscription(
+ event->net_uuid.uuid, event->source,
+ ele_addr - event->source, mod_id, addr)) {
+ BT_INFO("Failed to add model subscription!");
+ }
+ break;
+ case MESH_OPCODE_CONFIG_MODEL_SUB_DELETE:
+ case MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_DELETE:
+ if (!_bt_mesh_network_delete_model_subscription(
+ event->net_uuid.uuid, event->source,
+ ele_addr - event->source, mod_id, addr)) {
+ BT_INFO("Failed to delete model subscription!");
+ }
+ break;
+ case MESH_OPCODE_CONFIG_MODEL_SUB_DELETE_ALL:
+ if (!_bt_mesh_network_delete_all_model_subscription(
+ event->net_uuid.uuid, event->source,
+ ele_addr - event->source, mod_id)) {
+ BT_INFO("Failed to delete all model subscription!");
+ }
+ break;
+ case MESH_OPCODE_CONFIG_MODEL_SUB_OVERWRITE:
+ case MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_OVERWRITE:
+ if (!_bt_mesh_network_overwrite_model_subscription(
+ event->net_uuid.uuid, event->source,
+ ele_addr - event->source, mod_id, addr)) {
+ BT_INFO("Failed to overwrite model subscription!");
+ }
+ break;
+ }
+ }
+
+ if (cmd)
+ __mesh_handle_model_subscription_event(result, ¶m, cmd);
+
break;
}
case MESH_OPCODE_CONFIG_DEFAULT_TTL_STATUS: {
BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
BT_INFO("Node %4.4x: Model App status %s\n", event->source,
__mesh_status_to_string(data[0]));
+
+ if (data[0] != MESH_STATUS_SUCCESS)
+ result = BLUETOOTH_ERROR_INTERNAL;
+
elem_addr = l_get_le16(data + 1);
app_idx = l_get_le16(data + 3);
param.primary_unicast = event->source;
param.elem_index = elem_addr - event->source;
param.model = mod_id;
-
- total = data_len - 5;
+ BT_INFO("Mesh: Data length of All Models Together [%d]", data_len - 5);
+ total = (data_len - 5)/2;
param.sublist_count = total;
+ BT_INFO("Mesh: Total Number of subscriptions [%d]", total);
if (total) {
param.sub_list = (uint16_t **)g_malloc0(sizeof(uint16_t*) * total);
i = 5;
- for (; i < data_len; i += 2) {
- BT_INFO("Subscription Addr \t\t%4.4x\n ", l_get_le16(data + i));
- param.sub_list[i] = g_malloc(sizeof(uint16_t));
- *param.sub_list[i] = l_get_le16(data + i);
+ for (int k = 0; i < data_len; k++, i += 2) {
+ BT_INFO("Mesh: Subscription Addr \t\t%4.4x\n ", l_get_le16(data + i));
+ param.sub_list[k] = g_malloc(sizeof(uint16_t));
+ *param.sub_list[k] = l_get_le16(data + i);
}
}
+
+ /* <TO-DO> Update model sub in cdb */
+
__bt_mesh_handle_pending_dev_config_request_info(result,
BT_MESH_MODEL_GET_SUBSCRIPTION_LIST, ¶m,
sizeof(bluetooth_mesh_model_configure_t));
(uint8_t *) event->net_uuid.uuid, 16, param.net_uuid,
BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
- BT_INFO("\nNode %4.4x BT SIG Model Subscription List status %s\n",
+ BT_INFO("\nNode %4.4x Vendor Model Subscription List status %s\n",
event->source, __mesh_status_to_string(data[0]));
BT_INFO("Element Addr\t%4.4x\n", l_get_le16(data + 1));
param.elem_index = elem_addr - event->source;
param.model = mod_id;
- total = data_len - 7;
+ BT_INFO("Mesh: Data length of All Models Together [%d]", data_len - 7);
+ total = (data_len - 7)/2;
param.sublist_count = total;
+
+ BT_INFO("Mesh: Total Number of subscriptions [%d]", total);
if (total) {
param.sub_list = (uint16_t **)g_malloc0(sizeof(uint16_t*) * total);
i = 7;
- for (; i < data_len; i += 2) {
- BT_INFO("Subscription Addr \t\t%4.4x\n ", l_get_le16(data + i));
- param.sub_list[i] = g_malloc(sizeof(uint16_t));
- *param.sub_list[i] = l_get_le16(data + i);
+ for (int k = 0; i < data_len; k++, i += 2) {
+ BT_INFO("Mesh: Subscription Addr \t\t%4.4x\n ", l_get_le16(data + i));
+ param.sub_list[k] = g_malloc(sizeof(uint16_t));
+ *param.sub_list[k] = l_get_le16(data + i);
}
}
__bt_mesh_handle_pending_dev_config_request_info(result,
break;
bluetooth_mesh_node_features_t features;
memset(&features, 0x00, sizeof(bluetooth_mesh_node_features_t));
-
+ BT_INFO("Mesh: Got Response for Device Composition Data");
__bt_mesh_print_device_composition_data(data, data_len);
if (!_bt_mesh_network_save_remote_node_composition(
(uint8_t *) event->net_uuid.uuid, 16, features.net_uuid,
BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
features.unicast = event->source;
- _bt_mesh_node_get_vendor_features(event->net_uuid.uuid,
- event->source, &features);
-
+ BT_INFO("Mesh: Net UUID [%s]", features.net_uuid);
+
+ BT_INFO("Mesh: Composition status for node unicast [0x%2.2x]",
+ event->source);
+ if (!_bt_mesh_node_get_vendor_features(event->net_uuid.uuid,
+ event->source, &features)) {
+ BT_ERR("Mesh: Failed to get Vendor Specific Infor for [0x%2.2x]",
+ event->source);
+ result = BLUETOOTH_ERROR_INTERNAL;
+ } else {
+ BT_INFO("Mesh: Got Feature informations for [0x%2.2x]",
+ event->source);
+ }
__bt_mesh_handle_pending_dev_config_request_info(result,
BT_MESH_NODE_GET_VENDOR_FEATURES, &features,
sizeof(bluetooth_mesh_node_features_t));
BT_INFO("\tNetKey %u (0x%3.3x)", net_idx, net_idx);
if (data[0] != 0)
- break;
+ result = BLUETOOTH_ERROR_INTERNAL;
if (!cmd)
break;
param.netkey_idx = net_idx;
param.is_netkey = true;
+ BT_INFO("Mesh: Resp recvd from node unicast [0x%4.4x]", event->source);
if (cmd->opcode == MESH_OPCODE_NETKEY_ADD) {
BT_INFO("Mesh: Resp recvd: MESH_OPCODE_NETKEY_ADD");
- if (_bt_mesh_network_save_remote_node_netkey(
- event->net_uuid.uuid, event->source, net_idx)) {
- result = BLUETOOTH_ERROR_INTERNAL;
- BT_INFO("Failed to save node Netkey!");
+ if (result == BLUETOOTH_ERROR_NONE) {
+ if (!_bt_mesh_network_save_remote_node_netkey(
+ event->net_uuid.uuid, event->source, net_idx)) {
+ result = BLUETOOTH_ERROR_INTERNAL;
+ BT_INFO("Failed to save node Netkey!");
+ }
}
param.op = BLUETOOTH_MESH_NODE_KEY_ADD;
} else if (cmd->opcode == MESH_OPCODE_NETKEY_DELETE) {
- if (_bt_mesh_network_delete_remote_node_netkey(
- event->net_uuid.uuid, event->source, net_idx)) {
- result = BLUETOOTH_ERROR_INTERNAL;
- BT_INFO("Failed to delete node Netkey!");
+ BT_INFO("Mesh: Resp recvd: MESH_OPCODE_NETKEY_DELETE");
+ if (result == BLUETOOTH_ERROR_NONE) {
+ if (!_bt_mesh_network_delete_remote_node_netkey(
+ event->net_uuid.uuid, event->source, net_idx)) {
+ result = BLUETOOTH_ERROR_INTERNAL;
+ BT_INFO("Failed to delete node Netkey!");
+ }
}
param.op = BLUETOOTH_MESH_NODE_KEY_DELETE;
} else if (cmd->opcode == MESH_OPCODE_NETKEY_UPDATE) {
BT_INFO("AppKey\t%u (0x%3.3x)\n", app_idx, app_idx);
if (data[0] != MESH_STATUS_SUCCESS)
- break;
+ result = BLUETOOTH_ERROR_INTERNAL;
if (!cmd)
break;
if (cmd->opcode == MESH_OPCODE_APPKEY_ADD) {
BT_INFO("Mesh: Resp recvd: MESH_OPCODE_APPKEY_ADD");
- if (_bt_mesh_network_save_remote_node_appkey(
- event->net_uuid.uuid, event->source,
- net_idx, app_idx)) {
- result = BLUETOOTH_ERROR_INTERNAL;
- BT_INFO("Failed to save node Appkey!");
+ if (result == BLUETOOTH_ERROR_NONE) {
+ if (!_bt_mesh_network_save_remote_node_appkey(
+ event->net_uuid.uuid, event->source,
+ net_idx, app_idx)) {
+ result = BLUETOOTH_ERROR_INTERNAL;
+ BT_INFO("Failed to save node Appkey!");
+ }
}
param.op = BLUETOOTH_MESH_NODE_KEY_ADD;
} else if (cmd->opcode == MESH_OPCODE_APPKEY_DELETE) {
BT_INFO("Mesh: Resp recvd: MESH_OPCODE_APPKEY_DELETE");
- if (_bt_mesh_network_delete_remote_node_appkey(
- event->net_uuid.uuid, event->source,
- net_idx, app_idx)) {
- result = BLUETOOTH_ERROR_INTERNAL;
- BT_INFO("Failed to delete node Appkey!");
+ if (result == BLUETOOTH_ERROR_NONE) {
+ if (!_bt_mesh_network_delete_remote_node_appkey(
+ event->net_uuid.uuid, event->source,
+ net_idx, app_idx)) {
+ result = BLUETOOTH_ERROR_INTERNAL;
+ BT_INFO("Failed to delete node Appkey!");
+ }
}
param.op = BLUETOOTH_MESH_NODE_KEY_DELETE;
} else if (cmd->opcode == MESH_OPCODE_APPKEY_UPDATE) {
oal_uuid_t net_uuid;
uint8_t buffer[MESH_CONFIG_BUFFER_MAX_LEN];
+ BT_INFO("Mesh: Vendor features for Network UUID [%s]", req->net_uuid);
_bt_mesh_util_convert_string_to_hex(req->net_uuid,
strlen(req->net_uuid), net_uuid.uuid, 16);
/* Check if Node's vendor features are already svaed or not */
if (_bt_mesh_node_get_vendor_features(net_uuid.uuid, req->unicast, req)) {
+ BT_INFO("Mesh: Vendor Features already available for Node: Unicast [0x%.2x]",
+ req->unicast);
/* Schedule event ot Application */
bluetooth_mesh_node_features_t *event = \
g_memdup(req, sizeof(bluetooth_mesh_node_features_t));
strlen(req->net_uuid), net_uuid.uuid, 16);
dest = req->unicast;
+ BT_INFO("Mesh: Get Vendor Features for Remote Node Unicast [0x%2.2x]", dest);
/* Check pending request */
if (_bt_mesh_check_pending_request(MESH_OPCODE_DEV_COMP_GET,
return BLUETOOTH_ERROR_DEVICE_BUSY;
}
+ BT_INFO("Mesh: Browse Remote Node: Unicast [0x%2.2x]", dest);
/* Get Subnet index of the rmeote node for TX encryption */
netkey_idx = _bt_mesh_node_get_subnet_idx(net_uuid.uuid, dest);
if (netkey_idx == MESH_NET_IDX_INVALID)
_bt_mesh_util_convert_string_to_hex(req->dev_uuid,
strlen(req->dev_uuid), dev_uuid.uuid, 16);
+ BT_INFO("Mesh: Browse Node UUID [%s]", req->dev_uuid);
+
/* Get Remote Node unicast address from Dev UUID */
if (!_bt_mesh_node_get_unicast_from_dev_uuid(net_uuid.uuid,
dev_uuid.uuid, &dest))
return BLUETOOTH_ERROR_INTERNAL;
+ BT_INFO("Mesh: Browse Remote Node: Unicast [0x%2.2x]", dest);
/* Check pending request */
if (_bt_mesh_check_pending_request(MESH_OPCODE_DEV_COMP_GET,
dest, net_uuid.uuid)) {
return BLUETOOTH_ERROR_DEVICE_BUSY;
}
+ BT_INFO("Mesh: group Subscription Req: [%d]", req->op);
if (req->op != BLUETOOTH_MESH_MODEL_SUB_DELETE_ALL) {
+ BT_INFO("Mesh: group Subscription Addr [0x%2.2x]", req->sub_addr);
+
/* Subscriptio address sanity check */
- if ((!MESH_IS_GROUP(req->sub_addr) ||
- MESH_IS_ALL_NODES(req->sub_addr)) ||
+ if (!MESH_IS_GROUP(req->sub_addr) ||
MESH_IS_VIRTUAL(req->sub_addr)) {
- BT_ERR("Mesh: Bad subscription address %x\n",
+ BT_ERR("Mesh: Bad subscription address [0x%2.2x\n]",
req->sub_addr);
return BLUETOOTH_ERROR_INVALID_PARAM;
}
- }
+ } else
+ BT_INFO("Mesh: group Subscription Req: Delete All");
+ _bt_mesh_util_convert_string_to_hex(req->net_uuid,
+ strlen(req->net_uuid), net_uuid.uuid, 16);
/* Get Subnet index of the remote node for TX encryption */
netkey_idx = _bt_mesh_node_get_subnet_idx(net_uuid.uuid,
req->primary_unicast);
if (netkey_idx == MESH_NET_IDX_INVALID)
return BLUETOOTH_ERROR_INTERNAL;
- _bt_mesh_util_convert_string_to_hex(req->net_uuid,
- strlen(req->net_uuid), net_uuid.uuid, 16);
if (req->op == BLUETOOTH_MESH_MODEL_SUB_ADD)
opcode = MESH_OPCODE_CONFIG_MODEL_SUB_ADD;
data_len = _bt_mesh_util_opcode_set(opcode, buffer);
+ BT_INFO("Mesh: Group Subscription Primary unicast [0x%2.2x]",
+ req->primary_unicast);
/* Element Address */
l_put_le16((req->primary_unicast + req->elem_index),
buffer + data_len);
data_len += 2;
}
+ BT_INFO("Mesh: Group Subscription Model ID [0x%4.4x]", req->model);
/* Insert Model ID */
if (req->model >= 0xFFFF0000) {
/* 1st 2 octet Company ID is 0xFFFF means, it is BT SIG Model*/
return BLUETOOTH_ERROR_INTERNAL;
}
+ BT_INFO("Mesh: Group Subscription Command sent successfully");
/* Queue the request with timeout */
__bt_mesh_add_request(opcode, req->primary_unicast,
net_uuid.uuid,
_bt_mesh_util_convert_string_to_hex(req->net_uuid,
strlen(req->net_uuid), net_uuid.uuid, 16);
+ BT_INFO("Mesh: Virtual Group Subscription Req: [%d] Group Addr [0x%2.2x]",
+ req->op, req->sub_addr);
+
if (req->op != BLUETOOTH_MESH_MODEL_SUB_DELETE_ALL) {
/* Subscription address sanity check */
- if ((MESH_IS_GROUP(req->sub_addr) ||
- MESH_IS_ALL_NODES(req->sub_addr)) ||
+ if (MESH_IS_GROUP(req->sub_addr) ||
!(MESH_IS_VIRTUAL(req->sub_addr))) {
- BT_ERR("Mesh: Bad Virtual subscription address %x\n",
+ BT_ERR("Mesh: Bad Virtual Group subscription address [0x%2.2x\n]",
req->sub_addr);
return BLUETOOTH_ERROR_INVALID_PARAM;
}
- }
+ } else
+ BT_INFO("Mesh: Virtual Group Subscription Req: Delete All");
/* Get Subnet index of the remote node for TX encryption */
netkey_idx = _bt_mesh_node_get_subnet_idx(net_uuid.uuid,
return BLUETOOTH_ERROR_INTERNAL;
if (req->op == BLUETOOTH_MESH_MODEL_SUB_ADD)
- opcode = MESH_OPCODE_CONFIG_MODEL_SUB_ADD;
+ opcode = MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_ADD;
else if (req->op == BLUETOOTH_MESH_MODEL_SUB_DELETE)
- opcode = MESH_OPCODE_CONFIG_MODEL_SUB_DELETE;
+ opcode = MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_DELETE;
+ else if (req->op == BLUETOOTH_MESH_MODEL_SUB_OVERWRITE)
+ opcode = MESH_OPCODE_CONFIG_MODEL_SUB_VIRT_OVERWRITE;
else if (req->op == BLUETOOTH_MESH_MODEL_SUB_DELETE_ALL)
opcode = MESH_OPCODE_CONFIG_MODEL_SUB_DELETE_ALL;
- else if (req->op == BLUETOOTH_MESH_MODEL_SUB_OVERWRITE)
- opcode = MESH_OPCODE_CONFIG_MODEL_SUB_OVERWRITE;
/* Check pending request */
if (_bt_mesh_check_pending_request(opcode,
data_len += 16;
}
+ BT_INFO("Mesh: Virtual Group Subscription Model ID [0x%4.4x]", req->model);
/* Insert Model ID */
if (req->model >= 0xFFFF0000) {
/* 1st 2 octet Company ID is 0xFFFF means, it is BT SIG Model*/
return BLUETOOTH_ERROR_INTERNAL;
}
+ BT_INFO("Mesh: Virtual Group Subscription Command sent successfully");
/* Queue the request with timeout */
__bt_mesh_add_request(opcode, req->primary_unicast,
net_uuid.uuid,
_bt_mesh_util_convert_string_to_hex(req->net_uuid, strlen(req->net_uuid), net_uuid.uuid, 16);
- if (req->pub_addr > MESH_ALL_NODES_ADDRESS)
- return BLUETOOTH_ERROR_INVALID_PARAM;
-
+ if (req->pub_addr == MESH_ALL_NODES_ADDRESS)
+ BT_INFO("Mesh: Setting Publication to ALL Node Address");
if (!MESH_IS_GROUP(req->pub_addr) && !MESH_IS_VIRTUAL(req->pub_addr) &&
req->pub_addr != MESH_UNASSIGNED_ADDRESS) {
if (req->pub_addr != MESH_UNASSIGNED_ADDRESS) {
if (MESH_IS_VIRTUAL(req->pub_addr)) {
- if(!_bt_mesh_network_get_label_uuid_from_sub_addr(
+ if (!_bt_mesh_network_get_label_uuid_from_sub_addr(
net_uuid.uuid, req->pub_addr, label_uuid))
return BLUETOOTH_ERROR_INVALID_PARAM;
opcode = MESH_OPCODE_CONFIG_MODEL_PUB_VIRT_SET;
l_put_le16((req->primary_unicast + req->elem_index), buffer + data_len);
data_len += 2;
-
/* Insert Model ID */
if (opcode == MESH_OPCODE_CONFIG_MODEL_SUB_GET) {
+ BT_INFO("Mesh: Get Subscription List for BT SIG Model");
/* 1st 2 octet Company ID is 0xFFFF means, it is BT SIG Model*/
l_put_le16(req->model & 0x0000FFFF, buffer + data_len);
data_len += 2;
} else {
+ BT_INFO("Mesh: Get Subscription List for Vendor Model");
/* Vendor Model, 1st 2 octetes: Company ID, next 2 octets: Vendor Model ID */
l_put_le16(req->model & 0xFFFF0000, buffer + data_len);
data_len += 2;
return BLUETOOTH_ERROR_NONE;
}
+int _bt_mesh_network_reset_node(const char *app_cred, const char *sender,
+ bluetooth_mesh_node_info_t *node)
+{
+ int ret = OAL_STATUS_SUCCESS;
+ uint16_t netkey_idx;
+ oal_uuid_t net_uuid;
+ uint16_t data_len;
+ uint8_t buffer[MESH_CONFIG_BUFFER_MAX_LEN];
+
+ /* If Scanning is going on */
+ if (_bt_mesh_is_provisioning() ||
+ _bt_mesh_is_scanning()) {
+ BT_ERR("Device is buzy..");
+ return BLUETOOTH_ERROR_DEVICE_BUSY;
+ }
+
+ _bt_mesh_util_convert_string_to_hex(node->net_uuid,
+ strlen(node->net_uuid), net_uuid.uuid, 16);
+
+ /* Check pending request */
+ if (_bt_mesh_check_pending_request(MESH_OPCODE_NODE_RESET,
+ node->primary_unicast, net_uuid.uuid)) {
+ BT_ERR("Device is buzy..");
+ return BLUETOOTH_ERROR_DEVICE_BUSY;
+ }
+ BT_INFO("Mesh: Reset a remote Node [0x%2.2x] Elem Cnt [0x%2.2x]",
+ node->primary_unicast, node->num_elements);
+ /* Get Subnet index of the remote node for TX encryption */
+ netkey_idx = _bt_mesh_node_get_subnet_idx(net_uuid.uuid, node->primary_unicast);
+ if (netkey_idx == MESH_NET_IDX_INVALID)
+ return BLUETOOTH_ERROR_INTERNAL;
+
+ data_len = _bt_mesh_util_opcode_set(MESH_OPCODE_NODE_RESET, buffer);
+
+ /* Send Node Reset command 5 times to ensure reliability */
+ for (int i = 0; i < 5; i++)
+ ret = mesh_conf_send_message(&net_uuid, node->primary_unicast,
+ true, netkey_idx, buffer, data_len);
+
+ if (ret != OAL_STATUS_SUCCESS) {
+ BT_ERR("Mesh: Node Reset Failed!: %d", ret);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ BT_INFO("Mesh: Node reset Done, Send Delete req: Unicast[0x%2.2x]",
+ node->primary_unicast);
+
+ ret = mesh_delete_remote_node(&net_uuid, node->primary_unicast,
+ node->num_elements);
+ if (ret != OAL_STATUS_SUCCESS) {
+ BT_ERR("Mesh: Remote Node Deletion Failed!: %d", ret);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ return _bt_mesh_network_remove_node_configuration(node);
+}
+
int _bt_mesh_node_model_appkey_execute(const char *app_cred, const char *sender,
bluetooth_mesh_model_configure_t *req)
{
const struct mesh_config_cmd *cmd;
if (is_netkey) {
- switch(op) {
+ switch (op) {
case BLUETOOTH_MESH_NODE_KEY_ADD:
cmd = __mesh_get_command(MESH_OPCODE_NETKEY_ADD);
if (!cmd)
return false;
}
} else {
- switch(op) {
+ switch (op) {
case BLUETOOTH_MESH_NODE_KEY_ADD:
cmd = __mesh_get_command(MESH_OPCODE_APPKEY_ADD);
if (!cmd)
_bt_mesh_util_convert_string_to_hex(req->net_uuid, strlen(req->net_uuid), net_uuid.uuid, 16);
- if (req->is_netkey && _bt_mesh_keys_subnet_exists(net_uuid.uuid, req->netkey_idx)) {
+ if (req->is_netkey && !_bt_mesh_keys_subnet_exists(net_uuid.uuid, req->netkey_idx)) {
BT_ERR("Local Subnet not found..");
return BLUETOOTH_ERROR_INVALID_PARAM;
}
/* Handle Key (App/Net) Update & Add Commands: Key Config message */
update = (opcode == MESH_OPCODE_NETKEY_UPDATE || opcode == MESH_OPCODE_APPKEY_UPDATE);
ret = mesh_conf_send_key_message(&net_uuid, req->primary_unicast, req->is_netkey,
- update, req->is_netkey? req->netkey_idx: req->appkey_idx, netkey_idx);
+ update, req->is_netkey ? req->netkey_idx : req->appkey_idx, netkey_idx);
}
if (ret != OAL_STATUS_SUCCESS) {
BT_ERR("ret: %d", ret);