Chat freely about anything...

User avatar
By cyborgmax
#2530 I'm trying to Configure WiFi (only the password) through a TCP Connection and I can't get it to connect to the access point and/or get WiFi
The First thing the Module does, it creates it's own AP and then it starts a TCP Server, everything good so far, then the Server waits for the wifi password, (for now ssid is hard coded). When I send the password over TCP I get the password on the Module side but then when it tries to use it it looks like it fails. I have seen other codes using the configuration over http and it works, I wonder what am I doing wrong??
Can someone help me here?? Thanks.
This is the Code in the Recv funtion:

static void ICACHE_FLASH_ATTR ctrl_config_server_recv(void *arg, char *data, unsigned short len)
{
struct espconn *ptrespconn = (struct espconn *)arg;
struct station_config stationConf;

char wifissid[128] = "mywifi";
char wifipassword[128] = "";

uart0_sendStr("RECV: ");
unsigned short i;
for(i=0; i<len; i++)
{
char tmp2[5];
os_sprintf(tmp2, "%c", data[i]);
uart0_sendStr(tmp2);
}
if( os_strcmp(data, wifipassword) == 0 ) {
uart0_sendStr("Received: ");
uart0_sendStr(data);
uart0_sendStr("\r\n");
// wifi_set_opmode(1); //I have tried to set mode to 3 in the main code so I know this is not the issue,
os_strncpy((char*)stationConf.ssid, wifissid, 32); //I've tried memcpy and I got the same issue, I even print the password to uart0 to compare to what I sent over TCP and it's the same password, it just doesn't connect
os_strncpy((char*)stationConf.password, data, 64); // I also tried different access points/hotspots and nothing.
wifi_station_set_config(&stationConf);
wifi_station_connect();
uart0_sendStr("Station Configured\r\n");
uart0_sendStr("\r\n");
}
else {
uart0_sendStr("Data NOT equal to wifipassword\r\n");
}
}
User avatar
By cyborgmax
#2550 Thanks for replying, SSID is hardcoded, when I hard code the password it works, I did some uart output of the received variable (data) right before starting the wifi and I can see that it's the same password I'm entering over TCP, I had the same problem with arduino, then I moved from arduino to try from compiling the chip and I can't believe I got exactly the same error, don't know what I'm doing wrong here.
Have someone used this approach (WiFi configuring over TCP) with any luck??