|
|
@ -295,40 +295,32 @@ static void ICACHE_FLASH_ATTR cmdWifiSelectSSID(CmdPacket *cmd) { |
|
|
|
CmdRequest req; |
|
|
|
CmdRequest req; |
|
|
|
cmdRequest(&req, cmd); |
|
|
|
cmdRequest(&req, cmd); |
|
|
|
int argc = cmdGetArgc(&req); |
|
|
|
int argc = cmdGetArgc(&req); |
|
|
|
char *ssid, *pass; |
|
|
|
char ssid[33], pass[65]; |
|
|
|
|
|
|
|
|
|
|
|
if (argc != 2) |
|
|
|
if (argc != 2) return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int len = cmdArgLen(&req); |
|
|
|
int len = cmdArgLen(&req); |
|
|
|
if (len == 1) { |
|
|
|
if (len == 1) { |
|
|
|
// Assume this is the index
|
|
|
|
// Assume this is the index
|
|
|
|
uint8_t ix; |
|
|
|
uint8_t ix; |
|
|
|
cmdPopArg(&req, &ix, 1); |
|
|
|
cmdPopArg(&req, &ix, 1); |
|
|
|
len = cmdArgLen(&req); |
|
|
|
wifiGetApName(ix, ssid); |
|
|
|
pass = (char *)os_malloc(len+1); |
|
|
|
ssid[32] = '\0'; |
|
|
|
cmdPopArg(&req, pass, len); |
|
|
|
|
|
|
|
pass[len] = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DBG("SelectSSID(%d,%s)", ix, pass); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char myssid[33]; |
|
|
|
|
|
|
|
wifiGetApName(ix, myssid); |
|
|
|
|
|
|
|
myssid[32] = '\0'; |
|
|
|
|
|
|
|
connectToNetwork(myssid, pass); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ssid = os_malloc(len+1); |
|
|
|
// Longer than 1 byte: must be SSID
|
|
|
|
|
|
|
|
if (len > 32) return; |
|
|
|
cmdPopArg(&req, ssid, len); |
|
|
|
cmdPopArg(&req, ssid, len); |
|
|
|
ssid[len] = 0; |
|
|
|
ssid[len] = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
len = cmdArgLen(&req); |
|
|
|
// Extract password from message
|
|
|
|
pass = (char *)os_malloc(len+2); |
|
|
|
len = cmdArgLen(&req); |
|
|
|
cmdPopArg(&req, pass, len); |
|
|
|
if (len > 64) return; |
|
|
|
pass[len] = 0; |
|
|
|
cmdPopArg(&req, pass, len); |
|
|
|
|
|
|
|
pass[len] = 0; |
|
|
|
|
|
|
|
|
|
|
|
DBG("SelectSSID(%s,%s)", ssid, pass); |
|
|
|
DBG("SelectSSID(%d,%s)", ix, pass); |
|
|
|
connectToNetwork(ssid, pass); |
|
|
|
connectToNetwork(ssid, pass); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#if 0 |
|
|
|
#if 0 |
|
|
|