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;
}
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,
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;
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 Get Request");
__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);
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];
BT_INFO("Subscr Addr\t%4.4x\n", addr);
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);
*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, 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));
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 */
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)
{