int main(int argc,char* argv[]){ if(argc<3){ printf("usage %s command posID\n",argv[0]); exit(1); } int command, posID; int AP_num,i; AP_info info[100]; AP_num=wifi_status(info); // fprintf(stderr,"number of AP is %d\n",AP_num); int delta[20]; memset(delta,0,20); /* for(i=0;i<AP_num;i++){ printf("%lld: %d %d\n",info[i].mac,info[i].quality,info[i].level); } */ command=atoi(argv[1]); posID=atoi(argv[2]); report(info,AP_num,command,posID); }
static void cmd_wifi(Stream *chp, int argc, char* argv[]) { if (argc < 1) { chprintf(chp, "Usage: wifi on|off|info|ap|shell\r\n"); return; } if (strncasecmp("info", argv[0], 3) == 0) { if (wifi_is_enabled()) { chprintf(chp, " Stn status: %s\r\n", wifi_status(buf)); chprintf(chp, " Connected to: %s\r\n", wifi_doCommand("CONF", buf)); chprintf(chp, " IP address: %s\r\n", wifi_doCommand("IP", buf)); chprintf(chp, " MAC address: %s\r\n", wifi_doCommand("MAC", buf)); chprintf(chp, "\r\n"); chprintf(chp, " AP SSID: %s\r\n", wifi_doCommand("AP.SSID", buf)); chprintf(chp, " AP IP address: %s\r\n", wifi_doCommand("AP.IP", buf)); } else chprintf(chp, " WIFI is off\r\n"); chprintf(chp, "\r\nConfigured access points:\r\n"); for (int i=0; i<N_WIFIAP; i++) { GET_PARAM_I(WIFIAP, i, &wifiap); if (strlen(wifiap.ssid) == 0) chprintf(chp, " %d: -\r\n", i+1); else chprintf(chp," %d: %s : '%s'\r\n", i+1, wifiap.ssid, wifiap.passwd); } } else if (strncasecmp("ap", argv[0], 2) == 0) { if (argc < 2) chprintf(chp, "Usage: wifi ap <1-%d>\r\n", N_WIFIAP); else { int i = atoi(argv[1]); if (i < 1 || i > 4) { chprintf(chp, "Argument must be a number 1-4\r\n"); return; } chprintf(chp, "Enter SSID: "); shellGetLine(chp, wifiap.ssid, 32); if (strlen(wifiap.ssid) > 0) { chprintf(chp, "Enter Password: "******"_OPEN_"); chprintf(chp, "Ok\r\n"); SET_PARAM_I(WIFIAP, i-1, &wifiap); } } else if (strncasecmp("shell", argv[0], 2) == 0) { chprintf(chp, "***** WIFI DEVICE SHELL. Ctrl-D to exit *****\r\n"); wifi_shell(chp); } else if (strncasecmp("on", argv[0], 2) == 0) { wifi_enable(); chprintf(chp, "***** WIFI MODULE ON *****\r\n"); } else if (strncasecmp("off", argv[0], 2) == 0) { chprintf(chp, "***** WIFI MODULE OFF *****\r\n"); wifi_disable(); } }