BT_ERR("callback is NULL");
return BLUETOOTH_ERROR_INVALID_PARAM;
}
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ ret = _bt_send_request(BT_BLUEZ_SERVICE, BT_MESH_INIT,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ if (ret != BLUETOOTH_ERROR_NONE &&
+ ret != BLUETOOTH_ERROR_ALREADY_INITIALIZED) {
+ BT_ERR("Fail to init the mesh in bt-service");
+ return ret;
+ }
+
ret = _bt_init_event_handler();
if (ret != BLUETOOTH_ERROR_NONE &&
BT_EXPORT_API int bluetooth_mesh_deinit(void)
{
+ int ret;
+
_bt_unregister_event(BT_MESH_EVENT);
_bt_set_user_data(BT_MESH, NULL, NULL);
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ ret = _bt_send_request(BT_BLUEZ_SERVICE, BT_MESH_DEINIT,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ if (ret != BLUETOOTH_ERROR_NONE) {
+ BT_ERR("Fail to init the mesh in bt-service");
+ return ret;
+ }
+
return BLUETOOTH_ERROR_NONE;
}
+BT_EXPORT_API int bluetooth_mesh_network_unload(bluetooth_mesh_network_t *network)
+{
+ int result;
+
+ BT_CHECK_PARAMETER(network, return);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, network, sizeof(bluetooth_mesh_network_t));
+
+ BT_INFO("Mesh: Network Unload");
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_MESH_NETWORK_UNLOAD,
+ 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_destroy(bluetooth_mesh_network_t *network)
+{
+ int result;
+
+ BT_CHECK_PARAMETER(network, return);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, network, sizeof(bluetooth_mesh_network_t));
+
+ BT_INFO("Mesh: Network Destroy");
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_MESH_NETWORK_DESTROY,
+ 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_node_reset(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: Reset the Node");
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_MESH_NODE_RESET,
+ 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_create(
const char *net_name, bluetooth_mesh_node_t *node,
uint16_t total_models, bluetooth_mesh_model_t **models,
g_array_append_vals(in_param2, network_name,
BLUETOOTH_MESH_NETWORK_NAME_STRING_MAX);
- for(int i = 0; i < total_models; i++)
+ for (int i = 0; i < total_models; i++)
g_array_append_vals(in_param3, models[i],
sizeof(bluetooth_mesh_model_t));
BT_INFO("Mesh:Set Create Subnetwork key");
result = _bt_send_request(BT_BLUEZ_SERVICE, BT_MESH_NETWORK_ADD_NETKEY,
in_param1, in_param2, in_param3, in_param4, &out_param);
- if (result == BLUETOOTH_ERROR_NONE) {
+ if (result == BLUETOOTH_ERROR_NONE)
*netkey_idx = g_array_index(out_param, guint16, 0);
- }
BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
return result;
result = _bt_send_request(BT_BLUEZ_SERVICE, BT_MESH_NETWORK_ADD_APPKEY,
in_param1, in_param2, in_param3, in_param4, &out_param);
- if (result == BLUETOOTH_ERROR_NONE) {
+ if (result == BLUETOOTH_ERROR_NONE)
*appkey_index = g_array_index(out_param, guint16, 0);
- }
BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
return result;
info = &g_array_index(out_param,
bluetooth_mesh_node_info_t, i);
- data= g_memdup(info, sizeof(bluetooth_mesh_node_info_t));
+ data = g_memdup(info, sizeof(bluetooth_mesh_node_info_t));
g_ptr_array_add(*nodes, (gpointer)data);
}
}
BT_ERR("Mesh: out_param is NULL");
result = BLUETOOTH_ERROR_INTERNAL;
} else {
- size = (out_param->len) / sizeof(guint16);
+ size = (out_param->len) / sizeof(guint32);
+ BT_INFO("Mesh: Total Models found in Element [%d]", size);
for (i = 0; i < size; i++) {
uint32_t model_obj;
return result;
}
+BT_EXPORT_API int bluetooth_mesh_model_send_msg(
+ bluetooth_mesh_model_msg_t *req)
+{
+ int result;
+ bt_user_info_t *user_info;
+
+ BT_CHECK_PARAMETER(req, return);
+
+ user_info = _bt_get_user_data(BT_MESH);
+ retv_if(user_info->cb == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, req, sizeof(bluetooth_mesh_model_msg_t));
+
+ BT_INFO("Mesh: Node Model Send Msg");
+ result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_MESH_MODEL_EXECUTE_MSG,
+ in_param1, in_param2, in_param3, in_param4,
+ user_info->cb, user_info->user_data);
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
BT_EXPORT_API int bluetooth_mesh_node_configure_key(
bluetooth_mesh_key_configure_t *req)
{
GPtrArray **groups)
{
int result = BLUETOOTH_ERROR_NONE;
+ bluetooth_mesh_network_group_info_t *info;
guint size;
int i;
BT_ERR("Mesh: out_param is NULL");
result = BLUETOOTH_ERROR_INTERNAL;
} else {
- size = (out_param->len) / sizeof(guint16);
+ size = (out_param->len) / sizeof(bluetooth_mesh_network_group_info_t);
- if (size == 0) {
+ if (size == 0)
BT_INFO("Mesh: No Groups created for the network");
- }
+ BT_INFO("Mesh: Total groups [%d]", size);
for (i = 0; i < size; i++) {
- uint16_t group_addr;
- uint16_t *group_ptr = NULL;
-
- group_addr = g_array_index(out_param,
- guint16, i);
+ bluetooth_mesh_network_group_info_t *grp_info = NULL;
- group_ptr = g_memdup(&group_addr, sizeof(guint16));
- g_ptr_array_add(*groups, (gpointer)group_ptr);
+ info = &g_array_index(out_param,
+ bluetooth_mesh_network_group_info_t, i);
+ BT_INFO("Mesh: Group addr [0x%2.2x]", info->group_addr);
+ BT_INFO("Mesh: Group is Virtual [%s]", info->is_virtual ? "YES" : "NO");
+ BT_INFO("Mesh: Group net UUID[%s]", info->net_uuid);
+ if (info->is_virtual)
+ BT_INFO("Mesh: Virual Label UUID [%s]", info->label_uuid);
+ grp_info = g_memdup(info,
+ sizeof(bluetooth_mesh_network_group_info_t));
+ g_ptr_array_add(*groups, (gpointer)grp_info);
}
}
}
} else {
size = (out_param->len) / sizeof(guint16);
- if (size == 0) {
+ if (size == 0)
BT_ERR("Mesh: No Appkeys created for the NetKey in the network");
- }
for (i = 0; i < size; i++) {
uint16_t appkey_index;
return result;
}
+BT_EXPORT_API int bluetooth_mesh_network_remove_group(
+ bluetooth_mesh_network_t *network,
+ bluetooth_mesh_network_group_info_t *req)
+{
+ int result;
+
+ BT_CHECK_PARAMETER(network, return);
+ BT_CHECK_PARAMETER(req, return);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, network, sizeof(bluetooth_mesh_network_t));
+ g_array_append_vals(in_param2, req, sizeof(bluetooth_mesh_network_group_info_t));
+
+ BT_INFO("Mesh: Remove Group Request");
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_MESH_NETWORK_REMOVE_GROUP,
+ 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_create_group(
bluetooth_mesh_network_t *network, bool is_virtual,
uint16_t grp_addr, bluetooth_mesh_network_group_info_t *info)