char *app_uuid_path;
const meshcfg_app *app = (meshcfg_app*) data;
char *path = (char *) user_data;
- INFO("Mesh: proxy path compare: path [%s]", path);
- INFO("Mesh: App Path path [%s]", app->path);
if (!path)
return -1;
app_uuid_path = l_util_hexstring(app->uuid, 16);
- INFO("Mesh:App UUID string [%s]", app_uuid_path);
char **strings = g_strsplit(path, "node", 2);
- INFO("Mesh:String 0 [%s]", strings[0]);
- INFO("Mesh:String 1 [%s]", strings[1]);
ret = g_strcmp0(strings[1], app_uuid_path);
g_free(strings[0]);
g_free(strings[1]);
l_dbus_destroy(dbus);
dbus = NULL;
}
+ INFO("Mesh: Number of meshapps present in memory [%d]",
+ g_slist_length(mesh_apps));
}
/* To send stack event to hal-mesh handler */
INFO("Mesh: Leave Network Setup app path [%s]", app->path);
}
+static void __bt_hal_mesh_release_net_reply(
+ struct l_dbus_proxy *proxy,
+ struct l_dbus_message *msg, void *user_data)
+{
+ meshcfg_app *app;
+ app = (meshcfg_app*) user_data;
+
+ INFO("Mesh:Release Network Reply from Meshd: app path [%s]", app->path);
+ if (l_dbus_message_is_error(msg)) {
+ const char *name;
+
+ l_dbus_message_get_error(msg, &name, NULL);
+ ERR("Mesh: Failed to Release network: %s", name);
+
+ } else {
+ INFO("Mesh: Release Network: Success, cleanup app after proxy removed");
+ }
+}
+
+static void __bt_hal_mesh_release_net_setup(struct l_dbus_message *msg,
+ void *user_data)
+{
+ meshcfg_app *app = (meshcfg_app*) user_data;
+
+ l_dbus_message_set_arguments(msg, "t", l_get_be64(app->token.u8));
+ INFO("Mesh: Release Network Setup app path [%s]", app->path);
+}
+
static void __bt_hal_mesh_create_net_reply(
struct l_dbus_proxy *proxy,
struct l_dbus_message *msg, void *user_data)
return BT_STATUS_SUCCESS;
}
+bt_status_t _bt_hal_mesh_network_release(bt_uuid_t *net_uuid)
+{
+ GSList *l;
+ meshcfg_app *app;
+ INFO("Mesh: Release Network");
+ l = g_slist_find_custom(mesh_apps, net_uuid->uu, __mesh_compare_network_uuid);
+ if (l) {
+ app = l->data;
+ if (!__bt_mesh_proxy_check(app)) {
+ ERR("Mesh: Proxy check failed!!");
+ return BT_STATUS_FAIL;
+ }
+ INFO("Mesh: Release Network");
+ /* Create CFG Network */
+ if (!l_dbus_proxy_method_call(net_proxy, "Release",
+ __bt_hal_mesh_release_net_setup,
+ __bt_hal_mesh_release_net_reply, app,
+ NULL)) {
+ ERR("Mesh: Network Release failed!!");
+ return BT_STATUS_FAIL;
+ }
+ } else {
+ ERR("Mesh: App not found!!");
+ return BT_STATUS_PARM_INVALID;
+ }
+ INFO("Mesh: Network Release Call issued successfully!!");
+ return BT_STATUS_SUCCESS;
+}
+
bt_status_t _bt_hal_mesh_network_destroy(bt_uuid_t *net_uuid)
{
GSList *l;
bt_status_t _bt_hal_mesh_network_destroy(bt_uuid_t *net_uuid);
+bt_status_t _bt_hal_mesh_network_release(bt_uuid_t *net_uuid);
+
bt_status_t _bt_hal_mesh_node_delete(bt_uuid_t *network,
uint16_t unicast, uint16_t num_elements);
return _bt_hal_mesh_create_network(node, models, is_prov);
}
+static bt_status_t mesh_release_network(bt_uuid_t *network)
+{
+ DBG("");
+ return _bt_hal_mesh_network_release(network);
+}
+
static bt_status_t mesh_destroy_network(bt_uuid_t *network)
{
DBG("");
.init = init,
.create = mesh_create_network,
.destroy = mesh_destroy_network,
+ .release = mesh_release_network,
.delete_node = mesh_delete_node,
.scan = mesh_scan,
.scan_cancel = mesh_scan_cancel,
bt_status_t (*create)(bt_hal_mesh_node_t *node,
GSList *model_list, bool is_prov);
bt_status_t (*destroy)(bt_uuid_t *network);
+ bt_status_t (*release)(bt_uuid_t *network);
bt_status_t (*delete_node)(bt_uuid_t *network, uint16_t unicast,
uint16_t elem_cnt);
bt_status_t (*scan)(bt_uuid_t *network,
oal_status_t mesh_network_destroy(oal_uuid_t* network_uuid);
/**
+ * @brief Request Stack to release Network resources
+ *
+ * @remarks Stack will remove only yhe DBUS resources of local node
+ *
+ * @pre OAl API should be enabled with mesh_enable().
+ *
+ * @see mesh_enable()
+ * @see mesh_register_node()
+ */
+oal_status_t mesh_network_release(oal_uuid_t* network_uuid);
+
+/**
* @brief Delete Remote Node configuration
*
* @remarks Stack will remove the Remote node entry
return OAL_STATUS_SUCCESS;
}
+oal_status_t mesh_network_release(oal_uuid_t* network_uuid)
+{
+ int ret = BT_STATUS_SUCCESS;
+ API_TRACE();
+ CHECK_OAL_MESH_ENABLED();
+
+ BT_INFO("Mesh: Send Release Network request to stack");
+ ret = mesh_api->release((bt_uuid_t*)network_uuid);
+ if (ret != BT_STATUS_SUCCESS) {
+ BT_ERR("MESH: Network Leave failed: %s", status2string(ret));
+ return convert_to_oal_status(ret);
+ }
+
+ return OAL_STATUS_SUCCESS;
+}
+
oal_status_t mesh_network_destroy(oal_uuid_t* network_uuid)
{
int ret = BT_STATUS_SUCCESS;
const char *sender, bluetooth_mesh_network_t *network)
{
GSList *l;
- uint8_t net_uuid[16];
+ oal_uuid_t net_uuid;
_bt_mesh_cdb_t *cdb_cfg;
+ int ret = OAL_STATUS_SUCCESS;
BT_INFO("Mesh: Unload Network Configuration");
/* If Scanning is going on */
}
_bt_mesh_util_convert_string_to_hex(network->uuid,
- strlen(network->uuid), net_uuid, 16);
+ strlen(network->uuid), net_uuid.uuid, 16);
+
+ /* Release Mesh Network */
+ ret = mesh_network_release(&net_uuid);
+ if (ret != OAL_STATUS_SUCCESS) {
+ BT_ERR("ret: %d", ret);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ BT_INFO("Mesh: Network released");
/* Find CDB */
- l = g_slist_find_custom(cdb_list, net_uuid,
+ l = g_slist_find_custom(cdb_list, net_uuid.uuid,
__mesh_compare_app_network_uuid);
if (!l) {
BT_ERR("Mesh: Could not find Network Entry: unexpected!!");