ESP8266 Webserver Project

Moderator: Sprite_tm

User avatar
By mharizanov
#6883
pvvx wrote:But all this does not help do the job properly through espconn. Use Lwip! :)

That's a setback, calls for a rework of unknown magnitude..

Integrating the esp-httpd into a more complex solution causes heap issues and after few page loads it simply crashes with 'malloc assert!'
User avatar
By dnts
#6894
Sprite_tm wrote:Banitama, dtns: If you compile the AT code with the SDK and flash that, then use AT commands to connect to the access point, does the ESP connect to / remember the access point data then?

dnts: The timer thing is a nice observation: I perhaps should code that a bit differently to account for slower DHCP servers like yours.


Hi Sprite.
These are my observations:
1. took a brand new ESP8266 and started with stock FW. It connected to my home AP (AT+CWJAP) and remained connected through resets and power cycles.
2. Flashed AT 020 (0.9.4) and it still remembered to connect to my AP, albeit the AT 020 has issues (AT+CWLAP crashes it).
3. Flashed httpd.. and the AP info was gone.. it tried the default AP provided in code (MYAP)
4. Went back to AT 020.. The AP was not there either. AT+CWLAP now works.
5. Connected to my AP. It connects and survives reset and power cycling.

My conclusion is that something goes wrong within the HTTPD code where it either tries to store or load (or both) the AP info from persistent storage.
BTW - any API commands that let the user (me) use this persistent storage for my own needs?

Thanks,
Nir
User avatar
By bkrajendra
#6896 Hello @Sprite_tm

I'm trying to implement AC dimmer wth ESP code.
My dimmer hardware requires serial hex data for dimming.
for ex. 0x00 will switch it off and 0xFF will make it glow high.

I'm giving this data through range selector in HTML5. = 0 to 255.
Cgi code for it as follows.
Code: Select all//Transmit Serial Data
int ICACHE_FLASH_ATTR SendSerialData(HttpdConnData *connData) {
   int len;

   char buff[1024];

   char dataTX[1024];

   httpdStartResponse(connData, 200);
   httpdHeader(connData, "Content-Type", "text/json");
   httpdEndHeaders(connData);

   if (connData->conn==NULL) {
      //Connection aborted. Clean up.
      return HTTPD_CGI_DONE;
   }
   
   httpdFindArg(connData->postBuff, "dataTX", dataTX, sizeof(dataTX));

      len=os_sprintf(buff, "{\n \"result\": { \n\"data\": \"%s\"\n }\n}\n",dataTX);
      os_printf("%s",dataTX); // This is sending data to my AC dimmer Hardware
      //len=os_sprintf(buff, "]\n}\n}\n");
      espconn_sent(connData->conn, (uint8 *)buff, len);

   return HTTPD_CGI_DONE;
}


now the problem is when HTML range selector sends 23 my serial terminal screen shows it as 23 but I think actual data sent is
"32 33"
What can be done to send only single hex value from 00 to FF serial.

Please help!!!
User avatar
By dnts
#6924 Hi Sprite_em.. I think I found the reason for httpd not using saved AP info... in wifi.c 'setup_wifi_st_mode' routine I had to comment out some stuff:
if(wifi_station_get_config(&stconfig))
{
memset(stconfig.ssid, 0, sizeof(stconfig.ssid));
memset(stconfig.password, 0, sizeof(stconfig.password));
//os_sprintf(stconfig.ssid, "%s", WIFI_CLIENTSSID);
//os_sprintf(stconfig.password, "%s", WIFI_CLIENTPASSWORD);
/*if(!wifi_station_set_config(&stconfig))
{
#ifdef PLATFORM_DEBUG
os_printf("ESP8266 not set station config!\r\n");
#endif
}*/
}
I think this code runs over AP data with the default settings in WIFI_CLIENTSSID... is this some leftover debug stuff? some bug? intentional?

Now I'm facing another issue with wifi scan crashing...
BTW - the PUTC workaround works great. I can send clean data to the terminal (later on it will be Arduino). I just need to figure out how to read back data from the Arduino with some timeout (say - 1 sec max to not leave the connection hanging).
Nir