GMainLoop *main_loop = NULL;
+tc_table_t tc_control[] = {
+ {"Back"
+ , BT_MESH_UNIT_TEST_FUNCTION_BACK},
+ {"bt_mesh_model_send_msg"
+ , BT_MESH_UNIT_TEST_FUNCTION_MODEL_SEND_MSG},
+ {"bt_mesh_group_send_msg"
+ , BT_MESH_UNIT_TEST_FUNCTION_GROUP_SEND_MSG},
+ {"select this menu to set parameters and then select the function again"
+ , BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS},
+ {NULL , 0X0000},
+};
+
tc_table_t tc_configuration[] = {
{"Back"
, BT_MESH_UNIT_TEST_FUNCTION_BACK},
, BT_MESH_UNIT_TEST_FUNCTION_MODEL_SET_PUBLICATION},
{"bt_mesh_model_get_publication"
, BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_PUBLICATION},
- {"bt_mesh_model_send_msg"
- , BT_MESH_UNIT_TEST_FUNCTION_MODEL_SEND_MSG},
{"bt_mesh_appkey_get_netkey"
, BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_NETKEY},
{"select this menu to set parameters and then select the function again"
, BT_MESH_UNIT_TEST_TABLE_NETWORK},
{"Configuration"
, BT_MESH_UNIT_TEST_TABLE_CONFIGURATION},
+ {"Control"
+ , BT_MESH_UNIT_TEST_TABLE_CONTROL},
{"Finish"
, BT_MESH_UNIT_TEST_TABLE_FINISH},
{NULL , 0x0000},
case BT_MESH_UNIT_TEST_TABLE_CONFIGURATION:
tc_table = tc_configuration;
break;
+ case BT_MESH_UNIT_TEST_TABLE_CONTROL:
+ tc_table = tc_control;
+ break;
default:
tc_table = tc_main;
break;
param_count = 1;
TC_PRT("Input param(%d) (Model Handle)\n", param_index + 1);
break;
- case BT_MESH_UNIT_TEST_FUNCTION_MODEL_SEND_MSG:
- param_count = 4;
- switch(param_index) {
- case 0:
- TC_PRT("Input param(%d) (Model Handle)\n", param_index + 1);
- break;
- case 1:
- TC_PRT("Input param(%d) (Appkey Handle)\n", param_index + 1);
- break;
- case 2:
- TC_PRT("Input param(%d) (opcode)\n", param_index + 1);
- break;
- case 3:
- TC_PRT("Input param(%d) (Message)\n", param_index + 1);
- break;
- }
- break;
case BT_MESH_UNIT_TEST_FUNCTION_MODEL_SET_PUBLICATION:
param_count = 3;
switch(param_index) {
}
break;
}
+ case BT_MESH_UNIT_TEST_TABLE_CONTROL: {
+ switch(test_id) {
+ case BT_MESH_UNIT_TEST_FUNCTION_MODEL_SEND_MSG:
+ param_count = 4;
+ switch(param_index) {
+ case 0:
+ TC_PRT("Input param(%d) (Model Handle)\n", param_index + 1);
+ break;
+ case 1:
+ TC_PRT("Input param(%d) (Appkey Handle)\n", param_index + 1);
+ break;
+ case 2:
+ TC_PRT("Input param(%d) (opcode)\n", param_index + 1);
+ break;
+ case 3:
+ TC_PRT("Input param(%d) (Message)\n", param_index + 1);
+ break;
+ }
+ break;
+ case BT_MESH_UNIT_TEST_FUNCTION_GROUP_SEND_MSG:
+ param_count = 4;
+ switch(param_index) {
+ case 0:
+ TC_PRT("Input param(%d) (Group Handle)\n", param_index + 1);
+ break;
+ case 1:
+ TC_PRT("Input param(%d) (Appkey Handle)\n", param_index + 1);
+ break;
+ case 2:
+ TC_PRT("Input param(%d) (opcode)\n", param_index + 1);
+ break;
+ case 3:
+ TC_PRT("Input param(%d) (Message)\n", param_index + 1);
+ break;
+ }
+ break;
+ default:
+ TC_PRT("There is no parameter to set\n");
+ break;
+ }
+ break;
+ }
default:
TC_PRT("There is no parameter to set\n");
need_to_set_params = false;
TC_PRT("return %s\n", __bt_get_error_message(ret));
break;
}
+ case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_NETKEY: {
+ bt_mesh_appkey_h appkey_h = 0;
+ bt_mesh_netkey_h netkey_h;
+
+ if (g_test_param.param_count != 1) {
+ TC_PRT("Set Input parameter first!");
+ break;
+ }
+ appkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16));
+
+ ret = bt_mesh_appkey_get_netkey(appkey_h, &netkey_h);
+ TC_PRT("return %s\n", __bt_get_error_message(ret));
+ if (ret == BT_ERROR_NONE)
+ print_netkey_handle(netkey_h);
+ break;
+ }
+ case BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: {
+ need_to_set_params = true;
+ TC_PRT("Select the function again");
+ break;
+ }
+ default:
+ break;
+ }
+ __bt_free_test_param(&g_test_param);
+ break;
+ }
+ case BT_MESH_UNIT_TEST_TABLE_CONTROL: {
+ switch (test_id) {
case BT_MESH_UNIT_TEST_FUNCTION_MODEL_SEND_MSG: {
bt_mesh_model_h model_h = NULL;
bt_mesh_appkey_h appkey_h = NULL;
bt_mesh_model_msg_params_s *msg_params = NULL;
+
if (g_test_param.param_count != 4) {
TC_PRT("Set Input parameter first!");
break;
}
+
+ /* Get input parameter */
model_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16));
appkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[1], NULL, 16));
+
msg_params = g_malloc0(sizeof(bt_mesh_model_msg_params_s));
msg_params->opcode = strtoul(g_test_param.params[2], NULL, 16);
msg_params->data = "0101010101010101010101010100101010";
msg_params->data = g_strdup(g_test_param.params[3]);
+
TC_PRT("Input parameters");
print_model_handle(model_h);
print_appkey_handle(appkey_h);
TC_PRT("opcode 0X%4.4X", msg_params->opcode);
TC_PRT("Message to be sent %s", msg_params->data);
+
ret = bt_mesh_model_send_msg(model_h, appkey_h, msg_params,
__bt_mesh_model_msg_cb, NULL);
TC_PRT("return %s\n", __bt_get_error_message(ret));
+
break;
}
- case BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_NETKEY: {
- bt_mesh_appkey_h appkey_h = 0;
- bt_mesh_netkey_h netkey_h;
+ case BT_MESH_UNIT_TEST_FUNCTION_GROUP_SEND_MSG: {
+ bt_mesh_group_h group_h = NULL;
+ bt_mesh_appkey_h appkey_h = NULL;
+ bt_mesh_model_msg_params_s *msg_params = NULL;
- if (g_test_param.param_count != 1) {
+ if (g_test_param.param_count != 4) {
TC_PRT("Set Input parameter first!");
break;
}
- appkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16));
- ret = bt_mesh_appkey_get_netkey(appkey_h, &netkey_h);
+ /* Get input parameter */
+ group_h = GUINT_TO_POINTER(strtoul(g_test_param.params[0], NULL, 16));
+ appkey_h = GUINT_TO_POINTER(strtoul(g_test_param.params[1], NULL, 16));
+
+ msg_params = g_malloc0(sizeof(bt_mesh_model_msg_params_s));
+ msg_params->data = "0101010101010101010101010100101010";
+
+ msg_params->opcode = strtoul(g_test_param.params[2], NULL, 16);
+ msg_params->data = g_strdup(g_test_param.params[3]);
+
+ TC_PRT("Input parameters");
+ print_group_handle(group_h);
+ print_appkey_handle(appkey_h);
+ TC_PRT("opcode 0X%4.4X", msg_params->opcode);
+ TC_PRT("Message to be sent %s", msg_params->data);
+
+ ret = bt_mesh_group_send_msg(group_h, appkey_h, msg_params,
+ __bt_mesh_model_msg_cb, NULL);
TC_PRT("return %s\n", __bt_get_error_message(ret));
- if (ret == BT_ERROR_NONE)
- print_netkey_handle(netkey_h);
+
break;
}
case BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS: {
if (test_id == 0)
current_tc_table = BT_MESH_UNIT_TEST_TABLE_MAIN;
else if(test_id >= BT_MESH_UNIT_TEST_TABLE_NETWORK
- && test_id <= BT_MESH_UNIT_TEST_TABLE_CONFIGURATION) {
+ && test_id <= BT_MESH_UNIT_TEST_TABLE_CONTROL) {
current_tc_table = test_id;
- } else if (test_id > BT_MESH_UNIT_TEST_TABLE_CONFIGURATION
+ } else if (test_id > BT_MESH_UNIT_TEST_TABLE_CONTROL
&& test_id < BT_MESH_UNIT_TEST_TABLE_FINISH) {
current_tc_table = BT_MESH_UNIT_TEST_TABLE_MAIN;
} else {