static bt_mesh_unit_test_table_e current_tc_table;
+static GSList *networks;
+
static bool need_to_set_params = false;
static int g_test_id = -1;
static tc_params_t g_test_param = {0,};
, BT_MESH_UNIT_TEST_FUNCTION_ELEMENT_FOREACH_MODELS},
{"bt_mesh_network_create"
, BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE},
- {"bt_mesh_network_create_in_loop"
- , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_IN_LOOP},
{"bt_mesh_network_destroy"
, BT_MESH_UNIT_TEST_FUNCTION_NETWORK_DESTROY},
+ {"bt_mesh_network_create_in_loop"
+ , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_IN_LOOP},
+ {"bt_mesh_network_destroy_all_networks"
+ , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_DESTROY_ALL_NETWORKS},
+ {"bt_mesh_network_create_and_destroy_in_loop"
+ , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_AND_DESTROY_IN_LOOP},
+ {"bt_mesh_network_init_deinit_in_loop"
+ , BT_MESH_UNIT_TEST_FUNCTION_NETWORK_INIT_AND_DEINIT_IN_LOOP},
{"bt_mesh_network_load"
, BT_MESH_UNIT_TEST_FUNCTION_NETWORK_LOAD},
{"bt_mesh_network_set_name"
break;
}
break;
+ case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_DESTROY:
+ param_count = 1;
+ TC_PRT("Input param(%d) (network_handle)\n",param_index + 1);
+ break;
+ case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_AND_DESTROY_IN_LOOP:
+ param_count = 1;
+ TC_PRT("Input param(%d) (Num networks to create & destroy)\n",param_index + 1);
+ break;
case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_IN_LOOP:
param_count = 1;
TC_PRT("Input param(%d) (Number of networks)\n",param_index + 1);
break;
- case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_DESTROY:
+ case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_INIT_AND_DEINIT_IN_LOOP:
param_count = 1;
- TC_PRT("Input param(%d) (network_handle)\n",param_index + 1);
+ TC_PRT("Input param(%d) (Number of networks)\n",param_index + 1);
break;
case BT_MESH_UNIT_TEST_FUNCTION_NODE_DESTROY:
param_count = 1;
g_free(network_name);
break;
}
+ case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_DESTROY: {
+ bt_mesh_network_h network_h;
+ if (g_test_param.param_count != 1) {
+ TC_PRT("Enter parameters first!");
+ break;
+ }
+ network_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16));
+ ret = bt_mesh_network_destroy(network_h);
+ TC_PRT("return %s\n", __bt_get_error_message(ret));
+ break;
+ }
case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_IN_LOOP: {
char* network_name = "Mesh Test Network";
int num = atoi(g_test_param.params[0]);
TC_PRT("Create [%d] Networks", num);
for (int i = 0; i < num; i++) {
+
/* Create Node */
bt_mesh_node_h node_h;
bt_mesh_node_features_s features;
ret = bt_mesh_node_create(&features, &node_h);
TC_PRT("return %s\n", __bt_get_error_message(ret));
if (ret == BT_ERROR_NONE) {
- print_node_handle(node_h);
} else {
TC_PRT("Node Creation Failed!");
break;
ret = bt_mesh_node_create_element(node_h, &elem_h);
TC_PRT("return %s\n", __bt_get_error_message(ret));
if (ret == BT_ERROR_NONE) {
- print_element_handle(elem_h);
} else {
TC_PRT("Element Creation Failed!");
break;
mod_id.model_id = 0x0003;
mod_id.company_id = 0xFFFF;
- TC_PRT("The model_id is [0x%2.2x]\n", mod_id.model_id);
ret = bt_mesh_element_create_model(elem_h, &mod_id, &model_h);
TC_PRT("return %s\n", __bt_get_error_message(ret));
if (ret == BT_ERROR_NONE) {
- print_model_handle(model_h);
} else {
TC_PRT("Model Creation Failed!");
break;
TC_PRT("return %s\n", __bt_get_error_message(ret));
if (ret == BT_ERROR_NONE) {
TC_PRT("Network Created, token [%s] Network Number[%d]", token, i);
- print_network_handle(network);
+ networks = g_slist_append(networks, net_h);
+ } else {
+ TC_PRT("Network Creation Failed!");
+ break;
+ }
+ g_free(network_name);
+
+ }
+ break;
+ }
+ case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_DESTROY_ALL_NETWORKS: {
+ bt_mesh_network_h net_h;
+ GSList *l;
+ TC_PRT("Mesh: Destroy ALL networks : total [%d]",
+ g_slist_length(networks));
+
+ /* Destroy Network */
+ for (l = networks; l != NULL;) {
+ net_h = l->data;
+ l = g_slist_next(l);
+ networks = g_slist_remove(networks, net_h);
+
+ ret = bt_mesh_network_destroy(net_h);
+ TC_PRT("return %s\n", __bt_get_error_message(ret));
+ if (ret == BT_ERROR_NONE) {
+ TC_PRT("Network Destroyed Successfully!");
+ } else {
+ TC_PRT("Network Destroy Failed!!....break out");
+ break;
+ }
+ }
+ break;
+ }
+ case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_CREATE_AND_DESTROY_IN_LOOP: {
+ char* network_name = "Mesh Test Network";
+
+ if (g_test_param.param_count != 1) {
+ TC_PRT("Enter Input parameter first.\n");
+ break;
+ }
+ int num = atoi(g_test_param.params[0]);
+ TC_PRT("Create [%d] Networks", num);
+ for (int i = 0; i < num; i++) {
+
+ /* Create Node */
+ bt_mesh_node_h node_h;
+ bt_mesh_node_features_s features;
+ features.features = BT_MESH_FEATURE_RELAY;
+ features.features |= BT_MESH_FEATURE_LOWPOWER;
+
+ ret = bt_mesh_node_create(&features, &node_h);
+ TC_PRT("return %s\n", __bt_get_error_message(ret));
+ if (ret == BT_ERROR_NONE) {
+ } else {
+ TC_PRT("Node Creation Failed!");
+ break;
+ }
+
+ /* Create Element */
+ bt_mesh_element_h elem_h;
+ ret = bt_mesh_node_create_element(node_h, &elem_h);
+ TC_PRT("return %s\n", __bt_get_error_message(ret));
+ if (ret == BT_ERROR_NONE) {
+ } else {
+ TC_PRT("Element Creation Failed!");
+ break;
+ }
+
+ /* Create Model */
+ bt_mesh_model_h model_h;
+ bt_mesh_model_id_s mod_id;
+ memset(&mod_id, 0x00, sizeof(bt_mesh_model_id_s));
+
+ mod_id.model_id = 0x0003;
+ mod_id.company_id = 0xFFFF;
+ ret = bt_mesh_element_create_model(elem_h, &mod_id, &model_h);
+ TC_PRT("return %s\n", __bt_get_error_message(ret));
+ if (ret == BT_ERROR_NONE) {
+ } else {
+ TC_PRT("Model Creation Failed!");
+ break;
+ }
+ /* Create Network */
+ network_name = g_strdup_printf("TestMeshNet%d", i);
+ bt_mesh_network_h net_h;
+ char *token;
+ ret = bt_mesh_network_create(node_h, (const char*)network_name, &net_h, &token);
+ TC_PRT("return %s\n", __bt_get_error_message(ret));
+ if (ret == BT_ERROR_NONE) {
+ TC_PRT("Network Created, token [%s] Network Number[%d]", token, i);
} else {
TC_PRT("Network Creation Failed!");
break;
}
break;
}
- case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_DESTROY: {
- bt_mesh_network_h network_h;
+ case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_INIT_AND_DEINIT_IN_LOOP: {
+ char* network_name = "Mesh Test Network";
+
if (g_test_param.param_count != 1) {
- TC_PRT("Enter parameters first!");
+ TC_PRT("Enter Input parameter first.\n");
break;
}
- network_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16));
- ret = bt_mesh_network_destroy(network_h);
- TC_PRT("return %s\n", __bt_get_error_message(ret));
+ int num = atoi(g_test_param.params[0]);
+ TC_PRT("Create [%d] Networks", num);
+ for (int i = 0; i < num; i++) {
+
+ /* Mesh Init */
+ ret = bt_mesh_initialize();
+ if (ret == BT_ERROR_NONE) {
+ TC_PRT("Mesh init Passed!");
+ } else {
+ TC_PRT("Mesh init failed!");
+ continue;
+ }
+ /* Create Node */
+ bt_mesh_node_h node_h;
+ bt_mesh_node_features_s features;
+ features.features = BT_MESH_FEATURE_RELAY;
+ features.features |= BT_MESH_FEATURE_LOWPOWER;
+
+ ret = bt_mesh_node_create(&features, &node_h);
+ TC_PRT("return %s\n", __bt_get_error_message(ret));
+ if (ret == BT_ERROR_NONE) {
+ } else {
+ TC_PRT("Node Creation Failed!");
+ break;
+ }
+
+ /* Create Element */
+ bt_mesh_element_h elem_h;
+ ret = bt_mesh_node_create_element(node_h, &elem_h);
+ TC_PRT("return %s\n", __bt_get_error_message(ret));
+ if (ret == BT_ERROR_NONE) {
+ } else {
+ TC_PRT("Element Creation Failed!");
+ break;
+ }
+
+ /* Create Model */
+ bt_mesh_model_h model_h;
+ bt_mesh_model_id_s mod_id;
+ memset(&mod_id, 0x00, sizeof(bt_mesh_model_id_s));
+
+ mod_id.model_id = 0x0003;
+ mod_id.company_id = 0xFFFF;
+ ret = bt_mesh_element_create_model(elem_h, &mod_id, &model_h);
+ TC_PRT("return %s\n", __bt_get_error_message(ret));
+ if (ret == BT_ERROR_NONE) {
+ } else {
+ TC_PRT("Model Creation Failed!");
+ break;
+ }
+ /* Sleep for 100 msec to allow network Proxy attach */
+ usleep(100000);
+ /* Create Network */
+ network_name = g_strdup_printf("TestMeshNet%d", i);
+ bt_mesh_network_h net_h;
+ char *token;
+ ret = bt_mesh_network_create(node_h, (const char*)network_name, &net_h, &token);
+ TC_PRT("return %s\n", __bt_get_error_message(ret));
+ if (ret == BT_ERROR_NONE) {
+ TC_PRT("Network Created, token [%s] Network Number[%d]", token, i);
+ } else {
+ TC_PRT("Network Creation Failed!");
+ break;
+ }
+ g_free(network_name);
+
+ /* Mesh De-Init */
+ ret = bt_mesh_deinitialize();
+ if (ret == BT_ERROR_NONE) {
+ TC_PRT("Mesh De-init Passed!");
+ } else {
+ TC_PRT("Mesh De-init failed!");
+ }
+ }
break;
}
case BT_MESH_UNIT_TEST_FUNCTION_NETWORK_LOAD: {