Mesh: Implement Mesh Node Role API's
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-mesh.c
index a1e2920..2d64020 100644 (file)
@@ -224,6 +224,58 @@ BT_EXPORT_API int bluetooth_mesh_network_load(
        return result;
 }
 
+BT_EXPORT_API int bluetooth_mesh_network_join(
+               bluetooth_mesh_node_t *node, uint16_t total_models,
+                       bluetooth_mesh_model_t **models)
+{
+       int result;
+
+       BT_CHECK_PARAMETER(node, return);
+       BT_CHECK_PARAMETER(models, return);
+
+       BT_INIT_PARAMS();
+       BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       g_array_append_vals(in_param1, node,  sizeof(bluetooth_mesh_node_t));
+
+       for (int i = 0; i < total_models; i++)
+               g_array_append_vals(in_param2, models[i],
+                               sizeof(bluetooth_mesh_model_t));
+
+       result = _bt_send_request(BT_BLUEZ_SERVICE,
+                       BT_MESH_NETWORK_JOIN,
+                               in_param1, in_param2, in_param3,
+                                       in_param4, &out_param);
+       if (result == BLUETOOTH_ERROR_NONE) {
+               *node = g_array_index(out_param,
+                               bluetooth_mesh_node_t, 0);
+       }
+
+       BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       return result;
+}
+
+BT_EXPORT_API int bluetooth_mesh_cancel_join(
+               bluetooth_mesh_node_info_t *node)
+{
+       int result;
+
+       BT_CHECK_PARAMETER(node, return);
+
+       BT_INIT_PARAMS();
+       BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+       g_array_append_vals(in_param1, node,  sizeof(bluetooth_mesh_node_info_t));
+
+       BT_INFO("Mesh: Cancel Ongoing Join");
+       BT_INFO("Mesh: Node UUID [%s]", node->net_uuid);
+       result = _bt_send_request(BT_BLUEZ_SERVICE, BT_MESH_CANCEL_JOIN,
+                       in_param1, in_param2, in_param3, in_param4, &out_param);
+       BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       return result;
+}
+
 BT_EXPORT_API int bluetooth_mesh_network_scan(
                        bluetooth_mesh_network_t *network,
                                bluetooth_mesh_scan_param_t *scan_param)