From: Abhay Agarwal Date: Fri, 31 Jul 2020 09:32:54 +0000 (+0530) Subject: Mesh unit test: Add support for model message communication X-Git-Tag: accepted/tizen/unified/20200810.123220~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F15%2F240015%2F1;p=platform%2Fcore%2Fapi%2Fbluetooth.git Mesh unit test: Add support for model message communication Change-Id: I5e3524b19b1f8570821da0437940eea0b18b6547 Signed-off-by: Abhay Agarwal --- diff --git a/tests/test/bt_mesh_unit_test.c b/tests/test/bt_mesh_unit_test.c index 583f485..fb9221b 100644 --- a/tests/test/bt_mesh_unit_test.c +++ b/tests/test/bt_mesh_unit_test.c @@ -41,12 +41,10 @@ static int g_test_id = -1; static tc_params_t g_test_param = {0,}; static bt_mesh_node_h local_node = NULL; -static bt_mesh_node_h node; +static bt_mesh_node_h g_node; static bt_mesh_network_h network; static char *device_uuid; -static bt_mesh_netkey_h netkey; - static char *token; static bt_mesh_authentication_type_e request_type = BT_MESH_AUTH_ALPHANUMERIC_DISPLAY; @@ -89,6 +87,8 @@ tc_table_t tc_configuration[] = { , 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" @@ -390,7 +390,7 @@ void __bt_mesh_node_discover_status_cb(int result, bt_mesh_network_h network, bt //print_network_handle(network); print_node_handle(node_param); if (result == BT_ERROR_NONE) - node = node_param; + g_node = node_param; } static bool __bt_mesh_elem_foreach_model_cb(int result, bt_mesh_element_h element, int total, @@ -464,7 +464,7 @@ static void __bt_mesh_node_configure_appkey_cb(int result, bt_mesh_node_key_conf TC_PRT("AppKey Updated!"); else TC_PRT("AppKey Deleted!"); - print_appkey_handle(netkey); + print_netkey_handle(netkey); print_appkey_handle(appkey); } } @@ -545,7 +545,20 @@ void __bt_mesh_model_bind_cb(int result, bt_mesh_model_h model, bt_mesh_appkey_h TC_PRT("result: %s", __bt_get_error_message(result)); if (result == BT_ERROR_NONE) { print_model_handle(model); - print_appkey_handle(netkey); + print_appkey_handle(appkey); + } +} + +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) +{ + TC_PRT("bt_mesh_model_msg_cb"); + TC_PRT("result: %s", __bt_get_error_message(result)); + if (result == BT_ERROR_NONE) { + TC_PRT("opcode: 0X%2.2X", msg->opcode); + TC_PRT("msg: %s", msg->data); + print_element_handle(element); + print_appkey_handle(appkey); } } @@ -556,7 +569,7 @@ void __bt_mesh_model_unbind_cb(int result, bt_mesh_model_h model, bt_mesh_appkey TC_PRT("result: %s", __bt_get_error_message(result)); if (result == BT_ERROR_NONE) { print_model_handle(model); - print_appkey_handle(netkey); + print_appkey_handle(appkey); } } @@ -928,6 +941,23 @@ int test_set_params(int test_id, char *param){ 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) { @@ -1808,6 +1838,30 @@ int test_input_callback(void *data) TC_PRT("return %s\n", __bt_get_error_message(ret)); break; } + 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; + } + 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; diff --git a/tests/test/bt_mesh_unit_test.h b/tests/test/bt_mesh_unit_test.h index 10d02b5..488bb10 100644 --- a/tests/test/bt_mesh_unit_test.h +++ b/tests/test/bt_mesh_unit_test.h @@ -98,6 +98,7 @@ typedef enum { BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_SUBSCRIPTION_LIST, BT_MESH_UNIT_TEST_FUNCTION_MODEL_SET_PUBLICATION, BT_MESH_UNIT_TEST_FUNCTION_MODEL_GET_PUBLICATION, + BT_MESH_UNIT_TEST_FUNCTION_MODEL_SEND_MSG, BT_MESH_UNIT_TEST_FUNCTION_APPKEY_GET_NETKEY, BT_MESH_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS = 0XFF, } bt_mesh_unit_test_function_e;