From 066b69ebd859052db5f212931949c9ed1f1a1e00 Mon Sep 17 00:00:00 2001 From: "venkat.iyer" Date: Thu, 21 Sep 2017 19:23:46 +0900 Subject: [PATCH] Fixed build and run-time errors for DM itc. Point-wise description 1. The build fix mainly involved changing function signature for linkUpEvent() callback. 2. The run-time error fix was to provide the correct tx power level argument for the itc_dm_conn_set_get_tx_power_p testcase. 3. Changed argument types for DM API get_client_state 4. Changed argument types for WiFiConnect SLSI API, to prevent possible compilation error --- .../ta_tc/device_management/itc/itc_dm_conn.c | 4 +- .../ta_tc/device_management/itc/itc_dm_lwm2m.c | 4 +- .../ta_tc/device_management/itc/itc_dm_main.c | 60 +++++++++++++--------- 3 files changed, 40 insertions(+), 28 deletions(-) diff --git a/apps/examples/testcase/ta_tc/device_management/itc/itc_dm_conn.c b/apps/examples/testcase/ta_tc/device_management/itc/itc_dm_conn.c index ad5e473..d930ac3 100644 --- a/apps/examples/testcase/ta_tc/device_management/itc/itc_dm_conn.c +++ b/apps/examples/testcase/ta_tc/device_management/itc/itc_dm_conn.c @@ -117,7 +117,7 @@ static void itc_dm_conn_get_rssi_p(void) static void itc_dm_conn_set_get_tx_power_p(void) { int ret; - int setVal = 1, getVal, defaultvalue; + int setVal = 20, getVal, defaultvalue; // To get default value dm_conn_get_tx_power(&defaultvalue); ret = dm_conn_set_tx_power(&setVal); TC_ASSERT_EQ("dm_conn_set_tx_power" , ret , DM_ERROR_NONE); @@ -136,7 +136,7 @@ static void itc_dm_conn_set_get_tx_power_p(void) * @precondition NA * @postcondition NA */ -static conn_cb linkEvent() +static void linkEvent(void) { printf("Set link event\n"); } diff --git a/apps/examples/testcase/ta_tc/device_management/itc/itc_dm_lwm2m.c b/apps/examples/testcase/ta_tc/device_management/itc/itc_dm_lwm2m.c index 2036db9..fd684c8 100644 --- a/apps/examples/testcase/ta_tc/device_management/itc/itc_dm_lwm2m.c +++ b/apps/examples/testcase/ta_tc/device_management/itc/itc_dm_lwm2m.c @@ -44,7 +44,7 @@ static struct work_s itc_dm_wq; * @precondition DM LWM2M client has been started * @postcondition DM LWM2M client has been stopped */ -static int display_resource(FAR void *arg) +static void display_resource(FAR void *arg) { int ret; char argbuffer[10]; @@ -160,7 +160,7 @@ static void itc_dm_lwm2m_get_server_port_p(void) */ static void itc_dm_lwm2m_get_client_state_p(void) { - int8_t state = -1; + dm_lwm2m_client_state_e state; int ret = dm_lwm2m_start_client(&test_data_itc); TC_ASSERT_EQ("dm_lwm2m_start_client" , ret , DM_ERROR_NONE); diff --git a/apps/examples/testcase/ta_tc/device_management/itc/itc_dm_main.c b/apps/examples/testcase/ta_tc/device_management/itc/itc_dm_main.c index c1ef8f7..8b6a4fd 100644 --- a/apps/examples/testcase/ta_tc/device_management/itc/itc_dm_main.c +++ b/apps/examples/testcase/ta_tc/device_management/itc/itc_dm_main.c @@ -67,23 +67,26 @@ static int app_dhcp_main(void) return 1; } -static conn_cb linkUpEvent() +void linkUpEvent(void) { isConnected = 1; - return 0; } -int wifiAutoConnectInit_itc() +int wifiAutoConnectInit_itc(void) { int8_t ret; uint8_t result; + uint8_t *ssid = NULL; + char *ap_security = NULL; + char *ap_password = NULL; + + slsi_security_config_t *sec_config = NULL; isConnected = 0; dm_conn_register_linkup_cb(linkUpEvent); - if (WifiIsConnected(&result, NULL) != SLSI_STATUS_SUCCESS) { - printf("failed to WifiIsConnected\n"); - return; + if (WiFiIsConnected(&result, NULL) != SLSI_STATUS_SUCCESS) { + printf("Wifi Is not Connected\n"); } if (result > 0) { @@ -95,7 +98,15 @@ int wifiAutoConnectInit_itc() ret = WiFiStart(SLSI_WIFI_STATION_IF, NULL); if (ret == SLSI_STATUS_SUCCESS) { printf("[AutoConnect]STA mode started\n"); - ret = WiFiNetworkJoin(CONFIG_DM_AP_SSID, strlen(CONFIG_DM_AP_SSID), NULL, get_security_config(CONFIG_DM_AP_SECURITY, CONFIG_DM_AP_PASS)); + ssid = (uint8_t *)CONFIG_DM_AP_SSID; + ap_security = (char *) CONFIG_DM_AP_SECURITY; + ap_password = (char *) CONFIG_DM_AP_PASS; + if ((ssid == NULL) || (ap_security == NULL) || (ap_password == NULL)) { + return -1; + } + + sec_config = (slsi_security_config_t *)getSecurityConfig(ap_security, ap_password); + ret = WiFiNetworkJoin(ssid, strlen(CONFIG_DM_AP_SSID), NULL, sec_config); sleep(1); if (ret == SLSI_STATUS_SUCCESS) { printf("[AutoConnect]Start doJoin with SSID %s\n", CONFIG_DM_AP_SSID); @@ -110,15 +121,16 @@ int wifiAutoConnectInit_itc() return -1; } -void wifiAutoConnectDeInit_itc() +void wifiAutoConnectDeInit_itc(void) { isConnected = 0; dm_conn_unregister_linkup_cb(linkUpEvent); } -static void wifiAutoConnect() +static int wifiAutoConnect(void) { int ret; + ret = -1; if ((ret = wifiAutoConnectInit_itc()) == 1) { int waitTime = 10; while (waitTime--) { @@ -142,6 +154,7 @@ static void wifiAutoConnect() return 0; } } + return ret; } #ifdef CONFIG_BUILD_KERNEL @@ -157,44 +170,43 @@ int itc_dm_main(int argc, char *argv[]) printf("=== Please Setup WiFi Info ===\n"); return 0; #endif - wifiAutoConnect(); - - printf("=== TINYARA DM ITC START! ===\n"); - itc_dm_lwm2m_testcase_main(); + if (wifiAutoConnect() == 1) { + printf("=== TINYARA DM ITC START! ===\n"); + itc_dm_lwm2m_testcase_main(); #ifdef CONFIG_ITC_DM_CONN_GET_RSSI - itc_dm_conn_get_rssi_main(); + itc_dm_conn_get_rssi_main(); #endif #ifdef CONFIG_ITC_DM_CONN_GET_ADDRESS - itc_dm_conn_get_address_main(); + itc_dm_conn_get_address_main(); #endif #ifdef CONFIG_ITC_DM_CONN_GET_INTERFACE - itc_dm_conn_get_interface_main(); + itc_dm_conn_get_interface_main(); #endif #ifdef CONFIG_ITC_DM_CONN_GET_CHANNEL - itc_dm_conn_get_channel_main(); + itc_dm_conn_get_channel_main(); #endif #ifdef CONFIG_ITC_DM_CONN_GET_TX_POWER #ifdef CONFIG_ITC_DM_CONN_SET_TX_POWER - itc_dm_conn_set_get_tx_power_main(); + itc_dm_conn_set_get_tx_power_main(); #endif #endif #ifdef CONFIG_ITC_DM_CONN_REGI_LINKUP #ifdef CONFIG_ITC_DM_CONN_UNREGI_LINKUP - itc_dm_conn_regi_unreg_linkup_main(); + itc_dm_conn_regi_unreg_linkup_main(); #endif #endif #ifdef CONFIG_ITC_DM_CONN_REGI_LINKDOWN #ifdef CONFIG_ITC_DM_CONN_UNREGI_LINKDOWN - itc_dm_conn_regi_unreg_linkdown_main(); + itc_dm_conn_regi_unreg_linkdown_main(); #endif #endif - printf("\n=== TINYARA DM ITC COMPLETE ===\n"); - printf("\t\tTotal pass : %d\n\t\tTotal fail : %d\n", total_pass, total_fail); - - wifiAutoConnectDeInit_itc(); + printf("\n=== TINYARA DM ITC COMPLETE ===\n"); + printf("\t\tTotal pass : %d\n\t\tTotal fail : %d\n", total_pass, total_fail); + wifiAutoConnectDeInit_itc(); + } sem_post(&tc_sem); return 0; -- 2.7.4