extern int utc_bluetooth_bt_mesh_model_get_subscription_list_p(void);
extern int utc_bluetooth_bt_mesh_model_set_publication_p(void);
extern int utc_bluetooth_bt_mesh_model_get_publication_p(void);
+extern int utc_bluetooth_bt_mesh_node_reset_p(void);
+extern int utc_bluetooth_bt_mesh_network_destroy_p(void);
+extern int utc_bluetooth_bt_mesh_node_get_primary_address_p(void);
+extern int utc_bluetooth_bt_mesh_model_send_msg_p(void);
+extern int utc_bluetooth_bt_mesh_group_send_msg_p(void);
extern int utc_bluetooth_bt_mesh_model_send_msg_n(void);
extern int utc_bluetooth_bt_mesh_appkey_get_netkey_p(void);
extern int utc_bluetooth_bt_mesh_group_send_msg_n(void);
{"utc_bluetooth_bt_mesh_model_get_subscription_list_p",utc_bluetooth_bt_mesh_model_get_subscription_list_p,utc_bluetooth_mesh_network_positive_startup,utc_bluetooth_mesh_network_positive_cleanup},
{"utc_bluetooth_bt_mesh_model_set_publication_p",utc_bluetooth_bt_mesh_model_set_publication_p,utc_bluetooth_mesh_network_positive_startup,utc_bluetooth_mesh_network_positive_cleanup},
{"utc_bluetooth_bt_mesh_model_get_publication_p",utc_bluetooth_bt_mesh_model_get_publication_p,utc_bluetooth_mesh_network_positive_startup,utc_bluetooth_mesh_network_positive_cleanup},
+ {"utc_bluetooth_bt_mesh_network_destroy_p",utc_bluetooth_bt_mesh_network_destroy_p,utc_bluetooth_mesh_network_positive_startup,utc_bluetooth_mesh_network_positive_cleanup},
+ {"utc_bluetooth_bt_mesh_node_get_primary_address_p",utc_bluetooth_bt_mesh_node_get_primary_address_p,utc_bluetooth_mesh_network_positive_startup,utc_bluetooth_mesh_network_positive_cleanup},
+ {"utc_bluetooth_bt_mesh_model_send_msg_p",utc_bluetooth_bt_mesh_model_send_msg_p,utc_bluetooth_mesh_network_positive_startup,utc_bluetooth_mesh_network_positive_cleanup},
+ {"utc_bluetooth_bt_mesh_group_send_msg_p",utc_bluetooth_bt_mesh_group_send_msg_p,utc_bluetooth_mesh_network_positive_startup,utc_bluetooth_mesh_network_positive_cleanup},
+ {"utc_bluetooth_bt_mesh_node_reset_p",utc_bluetooth_bt_mesh_node_reset_p,utc_bluetooth_mesh_network_positive_startup,utc_bluetooth_mesh_network_positive_cleanup},
+ {"utc_bluetooth_bt_mesh_node_reset_p",utc_bluetooth_bt_mesh_node_reset_p,utc_bluetooth_mesh_network_positive_startup,utc_bluetooth_mesh_network_positive_cleanup},
{"utc_bluetooth_bt_mesh_appkey_get_netkey_p",utc_bluetooth_bt_mesh_appkey_get_netkey_p,utc_bluetooth_mesh_network_positive_startup,utc_bluetooth_mesh_network_positive_cleanup},
{"utc_bluetooth_bt_mesh_deinitialize_n",utc_bluetooth_bt_mesh_deinitialize_n,utc_bluetooth_mesh_network_negative_startup,utc_bluetooth_mesh_network_negative_cleanup},
{"utc_bluetooth_bt_mesh_create_node_n",utc_bluetooth_bt_mesh_create_node_n,utc_bluetooth_mesh_network_negative_startup,utc_bluetooth_mesh_network_negative_cleanup},
static bt_mesh_model_h model_h = NULL;
static bt_mesh_netkey_h netkey_h = NULL;
static bt_mesh_appkey_h appkey_h = NULL;
+static bt_mesh_node_h g_remote_node = NULL;
+static bt_mesh_group_h group_h = NULL;
+
+#define MESH_OPCODE_MODEL_GENERIC_ONOFF_GET 0x8201
static bool __bt_mesh_elem_foreach_model_cb(int result, bt_mesh_element_h element, int total,
bt_mesh_model_h model, bt_mesh_model_id_s *model_id, void *user_data)
static void __bt_mesh_node_discover_status_cb(int result, bt_mesh_network_h network,
bt_mesh_node_h node_param, void *user_data)
{
+ g_remote_node = node_param;
+
if (mainloop)
g_main_loop_quit(mainloop);
}
g_main_loop_quit(mainloop);
}
+void __bt_mesh_model_msg_cb(int result, bt_mesh_element_h element, bt_mesh_appkey_h appkey,
+ bt_mesh_model_msg_params_s *msg, void *user_data)
+{
+ if (mainloop)
+ g_main_loop_quit(mainloop);
+}
+
static void wait_for_async()
{
mainloop = g_main_loop_new(NULL, FALSE);
{
int ret = BT_ERROR_NONE;
bt_mesh_model_pub_params_s param;
- bt_mesh_group_h group_h = NULL;
uint16_t group_addr = 0xc001;
bt_mesh_node_key_configuration_e config = 0;
return 0;
}
+
+int utc_bluetooth_bt_mesh_node_reset_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ bt_mesh_node_h node_local = 0;
+ bt_mesh_node_features_s features;
+ bt_mesh_model_id_s mod_id;
+ bt_mesh_model_h model_local = NULL;
+ bt_mesh_element_h elem_local = NULL;
+ bt_mesh_network_h network_local = NULL;
+ char *network_name_local = "local-mesh";
+ static char *token_local = NULL;
+ bt_mesh_scan_params_s scan_params;
+ char *dev_uuid = "abababababababababababababababab";
+
+ if (mesh_supported) {
+ assert_eq(startup_flag, BT_ERROR_NONE);
+
+ features.features = BT_MESH_FEATURE_RELAY;
+ features.features |= BT_MESH_FEATURE_LOWPOWER;
+ ret = bt_mesh_node_create(&features, &node_local);
+ ret = bt_mesh_node_create_element(node_local, &elem_local);
+
+ mod_id.model_id = BT_MESH_MODEL_ID_GEN_LEVEL_SRV;
+ mod_id.company_id = 0xFFFF;
+ ret = bt_mesh_element_create_model(elem_local, &mod_id, &model_local);
+ ret = bt_mesh_network_create(node_local, (const char*)network_name_local, &network_local, &token_local);
+ ret = bt_mesh_network_unprovisioned_device_scan(network_local, &scan_params,
+ __bt_mesh_network_scan_unprovisioned_device_result_cb_p, NULL);
+ wait_for_async();
+
+ ret = bt_mesh_network_provision_device(network_local, dev_uuid,
+ __bt_mesh_network_device_provision_cb, NULL);
+ wait_for_async();
+
+ ret = bt_mesh_network_discover_node(network_local, (const char*)dev_uuid,
+ __bt_mesh_node_discover_status_cb, NULL);
+ wait_for_async();
+ ret = bt_mesh_node_reset(g_remote_node);
+ assert_eq(ret, BT_ERROR_NONE);
+
+ /*cleanup */
+ bt_mesh_network_destroy(network_local);
+ g_remote_node = NULL;
+ } else {
+ ret = bt_mesh_node_reset(node_local);
+ assert_eq(ret, BT_ERROR_NOT_SUPPORTED);
+ }
+
+ return 0;
+}
+
+
+int utc_bluetooth_bt_mesh_network_destroy_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ bt_mesh_node_h node_local = 0;
+ bt_mesh_node_features_s features;
+ bt_mesh_model_id_s mod_id;
+ bt_mesh_model_h model_local = NULL;
+ bt_mesh_element_h elem_local = NULL;
+ bt_mesh_network_h network_local = NULL;
+ char *network_name_local = "local-mesh";
+ static char *token_local = NULL;
+
+ if (mesh_supported) {
+ assert_eq(startup_flag, BT_ERROR_NONE);
+
+ features.features = BT_MESH_FEATURE_RELAY;
+ features.features |= BT_MESH_FEATURE_LOWPOWER;
+ ret = bt_mesh_node_create(&features, &node_local);
+ ret = bt_mesh_node_create_element(node_local, &elem_local);
+
+ mod_id.model_id = BT_MESH_MODEL_ID_GEN_LEVEL_SRV;
+ mod_id.company_id = 0xFFFF;
+ ret = bt_mesh_element_create_model(elem_local, &mod_id, &model_local);
+ ret = bt_mesh_network_create(node_local, (const char*)network_name_local, &network_local, &token_local);
+
+ bt_mesh_network_destroy(network_local);
+ assert_eq(ret, BT_ERROR_NONE);
+ } else {
+ bt_mesh_network_destroy(network_local);
+ assert_eq(ret, BT_ERROR_NOT_SUPPORTED);
+ }
+
+ return 0;
+}
+
+int utc_bluetooth_bt_mesh_node_get_primary_address_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ uint16_t primary_address;
+
+ if (mesh_supported) {
+ assert_eq(startup_flag, BT_ERROR_NONE);
+
+ ret = bt_mesh_node_get_primary_address(node_h, &primary_address);
+ assert_eq(ret, BT_ERROR_NONE);
+ } else {
+ ret = bt_mesh_node_get_primary_address(node_h, &primary_address);
+ assert_eq(ret, BT_ERROR_NOT_SUPPORTED);
+ }
+
+ return 0;
+}
+
+
+int utc_bluetooth_bt_mesh_group_send_msg_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ bt_mesh_model_msg_params_s *msg_params = NULL;
+
+ if (mesh_supported) {
+ assert_eq(startup_flag, BT_ERROR_NONE);
+
+ msg_params = g_malloc0(sizeof(bt_mesh_model_msg_params_s));
+ msg_params->opcode = MESH_OPCODE_MODEL_GENERIC_ONOFF_GET;
+ msg_params->data = "0101010101010101010101010100101010";
+
+ ret = bt_mesh_group_send_msg(group_h, appkey_h, msg_params,
+ __bt_mesh_model_msg_cb, NULL);
+ assert_eq(ret, BT_ERROR_NONE);
+ wait_for_async();
+ } else {
+ ret = bt_mesh_group_send_msg(group_h, appkey_h, msg_params,
+ __bt_mesh_model_msg_cb, NULL);
+ assert_eq(ret, BT_ERROR_NOT_SUPPORTED);
+ }
+
+ return 0;
+}
+
+
+int utc_bluetooth_bt_mesh_model_send_msg_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ bt_mesh_model_msg_params_s *msg_params = NULL;
+
+ if (mesh_supported) {
+ assert_eq(startup_flag, BT_ERROR_NONE);
+
+ msg_params = g_malloc0(sizeof(bt_mesh_model_msg_params_s));
+ msg_params->opcode = MESH_OPCODE_MODEL_GENERIC_ONOFF_GET;
+ msg_params->data = "0101010101010101010101010100101010";
+
+ ret = bt_mesh_model_send_msg(model_h, appkey_h, msg_params,
+ __bt_mesh_model_msg_cb, NULL);
+ assert_eq(ret, BT_ERROR_NONE);
+ wait_for_async();
+ } else {
+ ret = bt_mesh_model_send_msg(model_h, appkey_h, msg_params,
+ __bt_mesh_model_msg_cb, NULL);
+ assert_eq(ret, BT_ERROR_NOT_SUPPORTED);
+ }
+
+ return 0;
+}