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));
return result;
}
+BT_EXPORT_API int bluetooth_mesh_network_load(
+ const char *token,
+ bluetooth_mesh_network_t *network)
+{
+ int result;
+ char token_string[BLUETOOTH_MESH_TOKEN_STRING_MAX + 1];
+
+ BT_CHECK_PARAMETER(token, return);
+ BT_CHECK_PARAMETER(network, return);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_strlcpy(token_string, token, sizeof(token_string));
+ g_array_append_vals(in_param1, token_string, BLUETOOTH_MESH_TOKEN_STRING_MAX);
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_MESH_NETWORK_LOAD,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ if (result == BLUETOOTH_ERROR_NONE) {
+ *network = g_array_index(out_param,
+ bluetooth_mesh_network_t, 0);
+ }
+
+ 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)
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;
return result;
}
-BT_EXPORT_API int bluetooth_mesh_network_get_all_netkey(
- bluetooth_mesh_network_t *network,
- GPtrArray **netkeys)
+BT_EXPORT_API int bluetooth_mesh_network_get_all_nodes(
+ bluetooth_mesh_network_t *network,
+ GPtrArray **nodes)
{
int result = BLUETOOTH_ERROR_NONE;
guint size;
int i;
+ bluetooth_mesh_node_info_t *info;
BT_CHECK_PARAMETER(network, return);
- BT_CHECK_PARAMETER(netkeys, return);
+ BT_CHECK_PARAMETER(nodes, 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));
- result = _bt_send_request(BT_BLUEZ_SERVICE, BT_MESH_NETWORK_GET_NETKEYS,
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_MESH_NETWORK_GET_NODES,
in_param1, in_param2, in_param3, in_param4, &out_param);
if (result == BLUETOOTH_ERROR_NONE) {
BT_ERR("Mesh: out_param is NULL");
result = BLUETOOTH_ERROR_INTERNAL;
} else {
- size = (out_param->len) / sizeof(guint16);
-
- if (size == 0) {
- BT_ERR("Mesh: No netkeys created for the network");
- result = BLUETOOTH_ERROR_NOT_FOUND;
- }
+ size = (out_param->len) / sizeof(bluetooth_mesh_node_info_t);
for (i = 0; i < size; i++) {
- uint16_t netkey_index;
- uint16_t *netkey_idx = NULL;
+ bluetooth_mesh_node_info_t *data;
- netkey_index = g_array_index(out_param,
- guint16, i);
+ info = &g_array_index(out_param,
+ bluetooth_mesh_node_info_t, i);
- netkey_idx = g_memdup(&netkey_index, sizeof(guint16));
- g_ptr_array_add(*netkeys, (gpointer)netkey_idx);
+ data = g_memdup(info, sizeof(bluetooth_mesh_node_info_t));
+ g_ptr_array_add(*nodes, (gpointer)data);
}
}
}
return result;
}
-BT_EXPORT_API int bluetooth_mesh_netkey_get_all_appkey(
- bluetooth_mesh_network_t *network,
- uint16_t netkey_idx,
- GPtrArray **appkeys)
+BT_EXPORT_API int bluetooth_mesh_element_get_all_models(
+ bluetooth_mesh_network_t *network,
+ uint16_t node_addr, int elem_idx,
+ GPtrArray **models)
{
int result = BLUETOOTH_ERROR_NONE;
guint size;
int i;
BT_CHECK_PARAMETER(network, return);
- BT_CHECK_PARAMETER(appkeys, 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, network, sizeof(bluetooth_mesh_network_t));
- g_array_append_vals(in_param2, &netkey_idx, sizeof(guint16));
+ g_array_append_vals(in_param2, &node_addr, sizeof(guint16));
+ g_array_append_vals(in_param3, &elem_idx, sizeof(int));
- result = _bt_send_request(BT_BLUEZ_SERVICE, BT_MESH_NETWORK_GET_APPKEYS,
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_MESH_ELEMENT_GET_MODELS,
in_param1, in_param2, in_param3, in_param4, &out_param);
if (result == BLUETOOTH_ERROR_NONE) {
BT_ERR("Mesh: out_param is NULL");
result = BLUETOOTH_ERROR_INTERNAL;
} else {
- size = (out_param->len) / sizeof(guint16);
-
- if (size == 0) {
- BT_ERR("Mesh: No Appkeys created for the NetKey in the network");
- result = BLUETOOTH_ERROR_NOT_FOUND;
- }
+ size = (out_param->len) / sizeof(guint32);
+ BT_INFO("Mesh: Total Models found in Element [%d]", size);
for (i = 0; i < size; i++) {
- uint16_t appkey_index;
- uint16_t *appkey_idx = NULL;
+ uint32_t model_obj;
+ uint32_t *model_ptr = NULL;
- appkey_index = g_array_index(out_param,
- guint16, i);
+ model_obj = g_array_index(out_param,
+ guint32, i);
- appkey_idx = g_memdup(&appkey_index, sizeof(guint16));
- g_ptr_array_add(*appkeys, (gpointer)appkey_idx);
+ model_ptr = g_memdup(&model_obj, sizeof(guint32));
+ g_ptr_array_add(*models, (gpointer)model_ptr);
}
}
}
return result;
}
+
+BT_EXPORT_API int bluetooth_mesh_node_browse_vendor_features(
+ bluetooth_mesh_node_features_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_node_features_t));
+
+ BT_INFO("Mesh: Browse Vendor features of Node");
+ result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_MESH_NODE_GET_VENDOR_FEATURES,
+ 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_browse_remote_node(
+ bluetooth_mesh_node_discover_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_node_discover_t));
+
+ BT_INFO("Mesh: Browse remote Node");
+ result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_MESH_NODE_BROWSE,
+ 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_ttl_execute(
+ bluetooth_mesh_node_ttl_info_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_node_ttl_info_t));
+
+ BT_INFO("Mesh: Node TTL Execute");
+ result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_MESH_NODE_TTL_EXECUTE,
+ 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_model_configure_appkey(
+ bluetooth_mesh_model_configure_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_configure_t));
+
+ BT_INFO("Mesh: Node Model Configure AppKey");
+ result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_MESH_MODEL_CONFIGURE_APPKEY,
+ 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_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)
+{
+ 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_key_configure_t));
+
+ BT_INFO("Mesh:BTAPI: Node Key Configure");
+ result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_MESH_NODE_CONFIGURE_KEY,
+ 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_network_get_all_groups(
+ bluetooth_mesh_network_t *network,
+ GPtrArray **groups)
+{
+ int result = BLUETOOTH_ERROR_NONE;
+ bluetooth_mesh_network_group_info_t *info;
+ guint size;
+ int i;
+
+ BT_CHECK_PARAMETER(network, return);
+ BT_CHECK_PARAMETER(groups, 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));
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_MESH_NETWORK_GET_GROUPS,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ if (result == BLUETOOTH_ERROR_NONE) {
+ if (out_param == NULL) {
+ BT_ERR("Mesh: out_param is NULL");
+ result = BLUETOOTH_ERROR_INTERNAL;
+ } else {
+ size = (out_param->len) / sizeof(bluetooth_mesh_network_group_info_t);
+
+ 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++) {
+ bluetooth_mesh_network_group_info_t *grp_info = NULL;
+
+ 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);
+ }
+ }
+ }
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
+BT_EXPORT_API int bluetooth_mesh_network_get_all_netkey(
+ bluetooth_mesh_network_t *network,
+ GPtrArray **netkeys)
+{
+ int result = BLUETOOTH_ERROR_NONE;
+ guint size;
+ int i;
+
+ BT_CHECK_PARAMETER(network, return);
+ BT_CHECK_PARAMETER(netkeys, 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));
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_MESH_NETWORK_GET_NETKEYS,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ if (result == BLUETOOTH_ERROR_NONE) {
+ if (out_param == NULL) {
+ BT_ERR("Mesh: out_param is NULL");
+ result = BLUETOOTH_ERROR_INTERNAL;
+ } else {
+ size = (out_param->len) / sizeof(guint16);
+
+ if (size == 0) {
+ BT_ERR("Mesh: No netkeys created for the network");
+ result = BLUETOOTH_ERROR_NOT_FOUND;
+ }
+
+ for (i = 0; i < size; i++) {
+ uint16_t netkey_index;
+ uint16_t *netkey_idx = NULL;
+
+ netkey_index = g_array_index(out_param,
+ guint16, i);
+
+ netkey_idx = g_memdup(&netkey_index, sizeof(guint16));
+ g_ptr_array_add(*netkeys, (gpointer)netkey_idx);
+ }
+ }
+ }
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
+BT_EXPORT_API int bluetooth_mesh_netkey_get_all_appkey(
+ bluetooth_mesh_network_t *network,
+ uint16_t netkey_idx,
+ GPtrArray **appkeys)
+{
+ int result = BLUETOOTH_ERROR_NONE;
+ guint size;
+ int i;
+
+ BT_CHECK_PARAMETER(network, return);
+ BT_CHECK_PARAMETER(appkeys, 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, &netkey_idx, sizeof(guint16));
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_MESH_NETWORK_GET_APPKEYS,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ if (result == BLUETOOTH_ERROR_NONE) {
+ if (out_param == NULL) {
+ BT_ERR("Mesh: out_param is NULL");
+ result = BLUETOOTH_ERROR_INTERNAL;
+ } else {
+ size = (out_param->len) / sizeof(guint16);
+
+ 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;
+ uint16_t *appkey_idx = NULL;
+
+ appkey_index = g_array_index(out_param,
+ guint16, i);
+
+ appkey_idx = g_memdup(&appkey_index, sizeof(guint16));
+ g_ptr_array_add(*appkeys, (gpointer)appkey_idx);
+ }
+ }
+ }
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
+BT_EXPORT_API int bluetooth_mesh_node_get_all_netkeys(
+ bluetooth_mesh_node_discover_t *node,
+ GPtrArray **netkeys)
+{
+ int result = BLUETOOTH_ERROR_NONE;
+ guint size;
+ int i;
+
+ BT_CHECK_PARAMETER(node, return);
+ BT_CHECK_PARAMETER(netkeys, 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_discover_t));
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_MESH_NODE_GET_NETKEYS,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ if (result == BLUETOOTH_ERROR_NONE) {
+ if (out_param == NULL) {
+ BT_ERR("Mesh: out_param is NULL");
+ result = BLUETOOTH_ERROR_INTERNAL;
+ } else {
+ size = (out_param->len) / sizeof(guint16);
+
+ for (i = 0; i < size; i++) {
+ uint16_t netkey_index;
+ uint16_t *netkey_idx = NULL;
+
+ netkey_index = g_array_index(out_param,
+ guint16, i);
+
+ netkey_idx = g_memdup(&netkey_index, sizeof(guint16));
+ g_ptr_array_add(*netkeys, (gpointer)netkey_idx);
+ }
+ }
+ }
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
+BT_EXPORT_API int bluetooth_mesh_node_get_all_appkeys(
+ bluetooth_mesh_node_discover_t *req, GPtrArray **appkeys)
+{
+ int result = BLUETOOTH_ERROR_NONE;
+ guint size;
+ int i;
+
+ BT_CHECK_PARAMETER(req, return);
+ BT_CHECK_PARAMETER(appkeys, return);
+
+ 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_node_discover_t));
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_MESH_NODE_GET_APPKEYS,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ if (result == BLUETOOTH_ERROR_NONE) {
+ if (out_param == NULL) {
+ BT_ERR("Mesh: out_param is NULL");
+ result = BLUETOOTH_ERROR_INTERNAL;
+ } else {
+ size = (out_param->len) / sizeof(guint16);
+
+ for (i = 0; i < size; i++) {
+ uint16_t appkey_index;
+ uint16_t *appkey_idx = NULL;
+
+ appkey_index = g_array_index(out_param,
+ guint16, i);
+
+ appkey_idx = g_memdup(&appkey_index, sizeof(guint16));
+ g_ptr_array_add(*appkeys, (gpointer)appkey_idx);
+ }
+ }
+ }
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
+BT_EXPORT_API int bluetooth_mesh_model_get_all_appkeys(
+ bluetooth_mesh_model_configure_t *req)
+{
+ int result = 0;
+ 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_configure_t));
+
+ BT_INFO("Mesh:Node Model Get AppKey List ");
+ result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_MESH_MODEL_GET_APPKEY_LIST,
+ 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_model_set_publication(
+ bluetooth_mesh_model_configure_t *req)
+{
+ int result = 0;
+ 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_configure_t));
+
+ BT_INFO("Mesh: Model Set Publication");
+ result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_MESH_MODEL_SET_PUBLICATION,
+ 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_model_get_publication(
+ bluetooth_mesh_model_configure_t *req)
+{
+ int result = 0;
+ 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_configure_t));
+
+ BT_INFO("Mesh:BTAPI: Model Get Publication");
+ result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_MESH_MODEL_GET_PUBLICATION,
+ 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_model_get_subscriptopn_list(
+ bluetooth_mesh_model_configure_t *req)
+{
+ int result = 0;
+ 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_configure_t));
+
+ BT_INFO("Mesh:BTAPI: Model Get Subscription List ");
+ result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_MESH_MODEL_GET_SUBSCRIPTION_LIST,
+ 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_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)
+{
+ int result;
+
+ BT_CHECK_PARAMETER(network, return);
+ BT_CHECK_PARAMETER(info, 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, &is_virtual, sizeof(gboolean));
+ g_array_append_vals(in_param3, &grp_addr, sizeof(guint16));
+
+ BT_INFO("Mesh: Create Group Request");
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_MESH_NETWORK_CREATE_GROUP,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ if (result == BLUETOOTH_ERROR_NONE) {
+ *info = g_array_index(out_param,
+ bluetooth_mesh_network_group_info_t, 0);
+ }
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
+BT_EXPORT_API int bluetooth_mesh_model_configure_group_sub(
+ bluetooth_mesh_model_configure_t *req)
+{
+ int result = 0;
+ 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_configure_t));
+
+ BT_INFO("Mesh:Model Group Subscription Request");
+ result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_MESH_MODEL_CONFIG_GROUP_SUB,
+ 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_model_configure_virtual_group_sub(
+ bluetooth_mesh_model_configure_t *req)
+{
+ int result = 0;
+ 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_configure_t));
+
+ BT_INFO("Mesh: Model Virtual Group Subscription Request");
+ result = _bt_send_request_async(BT_BLUEZ_SERVICE,
+ BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB,
+ 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;
+}