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);
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++;
}
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++;
}
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);
}
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;
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);
}
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;
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;
};
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, },