Update test code to support connman integration
authorJiwan Kim <ji-wan.kim@samsung.com>
Fri, 26 May 2017 07:17:39 +0000 (16:17 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 17 Jul 2017 02:09:10 +0000 (11:09 +0900)
CMakeLists.txt
include/mesh_private.h
src/mesh_dbus.c
test/CMakeLists.txt
test/mesh_network.c

index 7b910e9..d57e98d 100644 (file)
@@ -20,7 +20,7 @@ FOREACH(flag ${${fw_name}_CFLAGS})
     SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -fvisibility=hidden")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -g -fvisibility=hidden")
 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
 
 IF("${ARCH}" STREQUAL "arm")
index f7d72cf..d7dcba1 100644 (file)
@@ -86,12 +86,12 @@ typedef struct mesh_handle {
 
 
 struct mesh_network_s {
-       char meshid[MAX_MESHID_LEN]; /**< meshid */
-       char bssid[MAX_BSSID_LEN]; /**< bssid */
-       int channel; /**< channel */
-       int rssi; /**< rssi */
-       int data_rate; /**< data rate */
-       int security; /**< security type */
+       char meshid[MAX_MESHID_LEN]; /**< Mesh ID */
+       char bssid[MAX_BSSID_LEN]; /**< BSSID */
+       int channel; /**< Channel */
+       int rssi; /**< RSSI */
+       int data_rate; /**< Data rate */
+       int security; /**< Security type */
 };
 
 struct mesh_station_info_s {
index a5b2cdb..bfadc60 100644 (file)
@@ -161,20 +161,20 @@ static int _mesh_get_scan_result(mesh_h handle)
                                if (strcasecmp(key, "mesh_id") == 0)  {
                                        const char *buf = g_variant_get_string(val, &len);
                                        memcpy(network_info->meshid, buf, len);
-                                       //LOGD("meshid=%s", network_info->meshid);
+                                       LOGD("  MeshID [%s]", network_info->meshid);
                                }
                                else if (strcasecmp(key, "bssid") == 0)  {
                                        const char *buf = g_variant_get_string(val, &len);
                                        memcpy(network_info->bssid, buf, len);
-                                       //LOGD("bssid = %s", network_info->bssid);
+                                       LOGD("  BSSID [%s]", network_info->bssid);
                                }
                                else if (strcasecmp(key, "rssi") == 0)  {
                                        network_info->rssi = g_variant_get_int32(val);
-                                       //LOGD("rssi = %d", network_info->rssi);
+                                       LOGD("  RSSI [%d]", network_info->rssi);
                                }
                                else if (strcasecmp(key, "channel") == 0)  {
                                        network_info->channel = g_variant_get_uint32(val);
-                                       //LOGD("channel = %d", network_info->channel);
+                                       LOGD("  Channel [%d]", network_info->channel);
 
                                        /* Last element */
                                        _mesh_append_network(network_info);
index 56b9833..5a191bd 100644 (file)
@@ -11,7 +11,7 @@ ENDFOREACH(flag)
 
 #SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall")
 # Temporary debug info enable : -O0 -g
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -g")
 SET(CMAKE_EXE_LINKER_FLAGS "-lpthread")
 
 SET(NEW_SOURCES
index 0e321d8..3571271 100644 (file)
@@ -72,7 +72,7 @@ void found_mesh_network_cb(mesh_network_h network, void* user_data)
        mesh_network_get_meshid(net, &meshid);
        mesh_network_get_bssid(net, &bssid);
        mesh_network_get_channel(net, &channel);
-       msgb("[%d] mesh id=%s bssid=%s channel=%d", g_scan_net_idx, meshid, bssid, channel);
+       msgb("  [%02d] Mesh ID[%-10s] BSSID[%s] Channel[%d]", g_scan_net_idx, meshid, bssid, channel);
 
        g_scan_net_idx++;
 }
@@ -93,7 +93,7 @@ void saved_mesh_network_cb(mesh_network_h network, void* user_data)
        g_saved_network_list = g_list_append(g_saved_network_list, net);
        mesh_network_get_meshid(net, &meshid);
        mesh_network_get_channel(net, &channel);
-       msg("[%d] mesh id=%s channel=%d", g_saved_net_idx, meshid, channel);
+       msg("  [%02d] Mesh ID[%-10s] Channel[%d]", g_saved_net_idx, meshid, channel);
 
        g_saved_net_idx++;
 }
@@ -110,23 +110,28 @@ static void found_mpath_cb(mesh_mpath_info_h mpath, void* user_data)
 
 static int run_show_saved_network(MManager *mm, struct menu_data *menu)
 {
-       int i = 0;
+       int i = 1; /* Displays from 1 */
        char *_meshid = NULL;
        int _channel = 1;
 
        GList *iter = NULL;
 
-       if (NULL == g_saved_network_list) {
+//     if (NULL == g_saved_network_list) {
+//             return RET_FAILURE;
+//     }
+       if (NULL == g_scanned_network_list) {
+               msgp("There is not any scan result.. do scan first");
                return RET_FAILURE;
        }
 
        msg("Saved Mesh Network Configurations : ");
-       iter = g_saved_network_list;
+       //iter = g_saved_network_list;
+       iter = g_scanned_network_list;
        while (iter != NULL) {
                mesh_network_h _net = iter->data;
                mesh_network_get_meshid(_net, &_meshid);
                mesh_network_get_channel(_net, &_channel);
-               msgb("[%d] mesh id=%s channel=%d", i++, _meshid, _channel);
+               msgb("  [%02d] Mesh ID[%-10s] Channel[%d]", i++, _meshid, _channel);
                iter = g_list_next(iter);
        }
 
@@ -135,7 +140,7 @@ static int run_show_saved_network(MManager *mm, struct menu_data *menu)
 
 static int run_show_scanned_network(MManager *mm, struct menu_data *menu)
 {
-       int i = 0;
+       int i = 1; /* Displays from 1 */
        char *_meshid = NULL;
        int _channel = 1;
 
@@ -152,7 +157,7 @@ static int run_show_scanned_network(MManager *mm, struct menu_data *menu)
                mesh_network_h _net = iter->data;
                mesh_network_get_meshid(_net, &_meshid);
                mesh_network_get_channel(_net, &_channel);
-               msgb("[%d] mesh id=%s channel=%d", i++, _meshid, _channel);
+               msgb("  [%02d] Mesh ID[%-10s] Channel[%d]", i++, _meshid, _channel);
                iter = g_list_next(iter);
        }
 
@@ -410,11 +415,16 @@ static int run_add_network(MManager *mm, struct menu_data *menu)
        mesh_network_h net = NULL;
        msg("Add a Network Configuration among scan results");
 
-       if (strlen(network_idx))
+       if (strlen(network_idx)) {
                idx = (unsigned short)strtol(network_idx, NULL, 10);
+               if (0 >= idx) {
+                       msg("Invalid index. set to 1");
+                       idx = 1;
+               }
+       }
 
        if (g_scanned_network_list) {
-               net = g_list_nth_data(g_scanned_network_list, idx);
+               net = g_list_nth_data(g_scanned_network_list, idx - 1);
                if (NULL == net) {
                        msg("Failed to find candidate network");
                        return RET_FAILURE;
@@ -461,11 +471,16 @@ static int run_select_network(MManager *mm, struct menu_data *menu)
        mesh_network_h net = NULL;
        msg("Select Saved Network Configuration");
 
-       if (strlen(network_idx))
+       if (strlen(network_idx)) {
                idx = (unsigned short)strtol(network_idx, NULL, 10);
+               if (0 >= idx) {
+                       msg("Invalid index. set to 1");
+                       idx = 1;
+               }
+       }
 
        if (g_saved_network_list) {
-               net = g_list_nth_data(g_saved_network_list, idx);
+               net = g_list_nth_data(g_saved_network_list, idx - 1);
                if (NULL == net) {
                        msg("Failed to g_hash_table_find");
                        return RET_FAILURE;
@@ -580,7 +595,7 @@ static struct menu_data menu_add_new_network[] = {
 };
 
 static struct menu_data menu_select_network[] = {
-       { "0", "show saved networks", NULL, run_show_saved_network, NULL },
+       { "0", "show scanned(!saved) networks", NULL, run_show_saved_network, NULL },
        { "1", "index", NULL, NULL, network_idx },
        { "2", "run", NULL, run_select_network, NULL },
        { NULL, NULL, },