Mesh: Add support for Node Reset in OAL & HAL 88/240988/1
authorAnupam Roy <anupam.r@samsung.com>
Thu, 13 Aug 2020 10:10:08 +0000 (15:40 +0530)
committerAnupam Roy <anupam.r@samsung.com>
Thu, 13 Aug 2020 10:30:37 +0000 (16:00 +0530)
This patch adds HAL & OAL API's for remote
node reset functionality.

Change-Id: I6805c62e1edd1c3c1e9f1ec6c302df796a114986
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
bt-oal/bluez_hal/src/bt-hal-mesh-dbus-handler.c
bt-oal/bluez_hal/src/bt-hal-mesh-dbus-handler.h
bt-oal/bluez_hal/src/bt-hal-mesh.c
bt-oal/hardware/bt_mesh.h
bt-oal/include/oal-mesh.h
bt-oal/oal-mesh.c

index 5f995b42bd30fcdbf3d6a2f7d76a8e12a05ff1df..e1d12b09aef1d6b0ad963060f25bb2695851b75f 100644 (file)
@@ -99,6 +99,11 @@ struct mesh_provision_auth_action {
        bt_hal_mesh_auth_variant_e auth_type;
 };
 
+struct mesh_remote_node_info {
+       uint16_t unicast;
+       uint8_t num_elements;
+};
+
 static struct mesh_provision_auth_action auth_table[] = {
        { "blink", BT_HAL_MESH_AUTH_REQ_BLINK_COUNT_INPUT},
        { "beep", BT_HAL_MESH_AUTH_REQ_BEEP_COUNT_INPUT},
@@ -2295,6 +2300,63 @@ bt_status_t _bt_hal_mesh_network_scan(bt_uuid_t *net_uuid,
        return BT_STATUS_SUCCESS;
 }
 
+static void __bt_hal_mesh_delete_node_setup(struct l_dbus_message *msg,
+               void *user_data)
+{
+       struct mesh_remote_node_info *node_info = \
+               (struct mesh_remote_node_info*) user_data;
+
+       l_dbus_message_set_arguments(msg, "qy",
+               node_info->unicast, node_info->num_elements);
+       INFO("Mesh: Delete Remote Node Setup params passed");
+       g_free(node_info);
+}
+
+static void __bt_hal_mesh_delete_node_reply(
+               struct l_dbus_proxy *proxy,
+                       struct l_dbus_message *msg, void *user_data)
+{
+       INFO("Mesh: Delete Remote Node Reply from DBUS");
+}
+
+bt_status_t _bt_hal_mesh_node_delete(bt_uuid_t *network,
+               uint16_t unicast, uint16_t num_elements)
+{
+       GSList *l;
+       meshcfg_app *app;
+       struct mesh_remote_node_info *node_info;
+       INFO("Mesh: Delete Remote Node");
+       l = g_slist_find_custom(mesh_apps, network->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: Delete Remote Node Unicast [0x%2.2x] Num els [%u]",
+                       unicast, num_elements);
+
+               /* Delete Remote Node Request */
+               node_info = g_malloc0(sizeof(struct mesh_remote_node_info));
+               node_info->unicast = unicast;
+               node_info->num_elements = num_elements;
+
+               if (!l_dbus_proxy_method_call(app->mgmt_proxy, "DeleteRemoteNode",
+                                       __bt_hal_mesh_delete_node_setup,
+                                       __bt_hal_mesh_delete_node_reply, node_info,
+                                       l_free)) {
+                       ERR("Mesh: Delete Remote Node Request failed!!");
+                       g_free(node_info);
+                       return BT_STATUS_FAIL;
+               }
+       } else {
+               ERR("Mesh: App not found!!");
+               return BT_STATUS_PARM_INVALID;
+       }
+       INFO("Mesh: Delete Remote Node Call issued successfully!!");
+       return BT_STATUS_SUCCESS;
+}
+
 bt_status_t _bt_hal_mesh_network_destroy(bt_uuid_t *net_uuid)
 {
        GSList *l;
index 19d2cde760880378aa60b0053ad5588bd0a5564e..2f27671935a95bd6a63af1873385fe5dd90d4ed4 100644 (file)
@@ -49,6 +49,9 @@ bt_status_t _bt_hal_mesh_create_network(bt_hal_mesh_node_t *node,
 
 bt_status_t _bt_hal_mesh_network_destroy(bt_uuid_t *net_uuid);
 
+bt_status_t _bt_hal_mesh_node_delete(bt_uuid_t *network,
+               uint16_t unicast, uint16_t num_elements);
+
 bt_status_t _bt_hal_mesh_network_scan(bt_uuid_t *net_uuid,
                bt_hal_mesh_scan_param_t *param);
 
index a0e4467cc95fef7d5e4ae4f1946513b7ef803c36..0bac7ade9a557360cfc0349be83d3dd2e3e7b706 100644 (file)
@@ -246,6 +246,13 @@ static bt_status_t mesh_destroy_network(bt_uuid_t *network)
        return _bt_hal_mesh_network_destroy(network);
 }
 
+static bt_status_t mesh_delete_node(bt_uuid_t *network, uint16_t unicast,
+                       uint16_t num_elements)
+{
+       DBG("");
+       return _bt_hal_mesh_node_delete(network, unicast, num_elements);
+}
+
 static bt_status_t mesh_scan(bt_uuid_t *network, bt_hal_mesh_scan_param_t *param)
 {
        DBG("");
@@ -373,6 +380,7 @@ static btmesh_interface_t mesh_if = {
        .init = init,
        .create = mesh_create_network,
        .destroy = mesh_destroy_network,
+       .delete_node = mesh_delete_node,
        .scan = mesh_scan,
        .scan_cancel = mesh_scan_cancel,
        .capability = mesh_set_prov_caps,
index a965f1ba2233864f80f10b3e7bbd3613cb533374..a8b6d6247bddc5e2bfb6c50abf08d7e6dab2c406 100644 (file)
@@ -204,6 +204,8 @@ typedef struct {
        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 (*delete_node)(bt_uuid_t *network, uint16_t unicast,
+               uint16_t elem_cnt);
        bt_status_t (*scan)(bt_uuid_t *network,
                bt_hal_mesh_scan_param_t *param);
        bt_status_t (*scan_cancel)(bt_uuid_t *network);
index 1edbb354bb218f47d94bb0055029f1e775056ff1..eeeb2e2e4f8dda24633a5568c1c0a9f8547f01ed 100644 (file)
@@ -271,6 +271,18 @@ oal_status_t mesh_register_node(oal_mesh_node_t *node,
  */
 oal_status_t mesh_network_destroy(oal_uuid_t* network_uuid);
 
+/**
+ * @brief Delete Remote Node configuration
+ *
+ * @remarks Stack will remove the Remote node entry
+ *
+ * @pre OAl API should be enabled with mesh_enable().
+ *
+ * @see  mesh_enable()
+ */
+oal_status_t mesh_delete_remote_node(oal_uuid_t* network_uuid,
+               uint16_t unicast, uint16_t num_elements);
+
 /**
  * @brief UnRegister the BLE Mesh Node
  *
index 1e476dac7805b39b57630a43d61b3de02e36955f..0e47904b4c41b2334c127f472480289d4cc74922 100644 (file)
@@ -382,6 +382,22 @@ oal_status_t mesh_network_destroy(oal_uuid_t* network_uuid)
        return OAL_STATUS_SUCCESS;
 }
 
+oal_status_t mesh_delete_remote_node(oal_uuid_t* network_uuid,
+               uint16_t unicast, uint16_t num_elements)
+{
+       int ret = BT_STATUS_SUCCESS;
+       API_TRACE();
+       CHECK_OAL_MESH_ENABLED();
+
+       ret = mesh_api->delete_node((bt_uuid_t*)network_uuid, unicast, num_elements);
+       if (ret != BT_STATUS_SUCCESS) {
+               BT_ERR("Mesh: Remote Node Deletion failed: %s", status2string(ret));
+               return convert_to_oal_status(ret);
+       }
+
+       return OAL_STATUS_SUCCESS;
+}
+
 oal_status_t mesh_network_start_scan(oal_uuid_t* network_uuid,
                oal_mesh_scan_params_t *params)
 {