ESP8266 Developer Zone The Official ESP8266 Forum 2022-01-05T23:57:22+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=75264 2022-01-05T23:57:22+08:00 2022-01-05T23:57:22+08:00 https://bbs.espressif.com:443/viewtopic.php?t=75264&p=100528#p100528 <![CDATA[Re: Broken Code with SDK 2.2 and newer]]> Glad to know the OVA was of some assistance! =]

Statistics: Posted by AgentSmithers — Wed Jan 05, 2022 11:57 pm


]]>
2022-01-05T23:39:39+08:00 2022-01-05T23:39:39+08:00 https://bbs.espressif.com:443/viewtopic.php?t=75264&p=100527#p100527 <![CDATA[Re: Broken Code with SDK 2.2 and newer]]>

I got it working... here are the results.
My program runs fine on your environment, as well as PlatformIO environments and on the Arduino environment versions too... IF... I include a call to espconn_init().

Some time ago, I read one post on another thread mentioning this method, but adding it to my projects gave compiler errors. So I discounted the post as being for an older version. The thing is... this call wasn't needed in SDK 2.2 and earlier.

Anyway, I was working backwards though the available Espressif codebase from the espconn_regist_disconcb() method and ran into... wait for it... espconn_init() in an Espressif C file. But it had no corresponding H file declaring it. I simply added my own declaration...

extern "C" void ICACHE_FLASH_ATTR espconn_init(void);

and added the call in my startup code... and Wham, bam, thank you mam! My disconnect callback started getting called and all was right with the world.

Thanks for your help!

Statistics: Posted by Inquisitor — Wed Jan 05, 2022 11:39 pm


]]>
2021-12-24T08:35:06+08:00 2021-12-24T08:35:06+08:00 https://bbs.espressif.com:443/viewtopic.php?t=75264&p=100485#p100485 <![CDATA[Re: Broken Code with SDK 2.2 and newer]]> *Edit* Yep, this is set to

osboxes.org <--- same as username. This is the default from osboxes.org (of course)

Statistics: Posted by AgentSmithers — Fri Dec 24, 2021 8:35 am


]]>
2021-12-24T05:50:08+08:00 2021-12-24T05:50:08+08:00 https://bbs.espressif.com:443/viewtopic.php?t=75264&p=100484#p100484 <![CDATA[Re: Broken Code with SDK 2.2 and newer]]>
AgentSmithers wrote:
LMAO, no your fine.. I should of packed up a thumbdrive and sent over a carrier pigeon lol. I'll keep watch for your reply if you need anything else. I still use this OVA today for alot of my programming so should work like a charm.


For someone that spent the last twenty years of my career tied to fiber, this feels like using smoke-signals. For S&G, I started a download at home while all the tourist and locals are at home for the holidays... projected to be three+ days to download. Drove over to the library... and seven whole minutes to download. It's all GOOD! :D Next...

  1. Fortunately, I had VirtualBox loaded and a couple of Windows VM's that I know work.
  2. Imported just fine.
  3. Trying to boot up, it complained about the NIC card, but apparently that is a Virtual Box setting and it let me swap that over.
  4. Next it complained about my USB. It let me select the USB 1.1 and didn't complain (I have 2.0 and 3.0 ports on my desktop) Hoping if that is a problem, it'll let me upgrade them by detection and download over the Internet once I get in.
  5. It booted up and I'm now at the login... I tried all kinds of accounts/passwords... <blank>, sudo, su, password, passW0rd, pw, AgentSmithers, Inquisitor... and looked on the Internet for defaults for CentOS. Those didn't work either.

Seems like I'm close.

P.S. - I came from a Microsoft Windows development background and use the Arduino IDE for the MPU's... :? IOW... I barely know what a make file is... and have never knowingly opened one up. Even my baby step into PlatformIO have sheltered me from those evil files. :D If it's not too much trouble, a small project with make file would be great. Although, I probably could dig out the example projects from Espressif.

Oh... and no rush. Don't let this interfere with your holidays.

VBR

Statistics: Posted by Inquisitor — Fri Dec 24, 2021 5:50 am


]]>
2021-12-23T08:06:25+08:00 2021-12-23T08:06:25+08:00 https://bbs.espressif.com:443/viewtopic.php?t=75264&p=100478#p100478 <![CDATA[Re: Broken Code with SDK 2.2 and newer]]>
Inquisitor wrote:
AgentSmithers wrote:Link as promised!
Download OracleBox and you can import the OVA.
https://drive.google.com/file/d/1JrA750 ... sp=sharing
Then import you project folder and compile and your good to go!
Let me know if you need help but that is a fully setup dev. If you need a test project if your having issues let me know and Ill zip one up with a makefile and send that over too.


Thank you for all your time. I hope I didn't take you away from festivities. :?
Later today, I'll go into town and download this at the library. If I remember correctly, these images are multi-gigabytes. I'm on a metered connection here at the house and with everyone home this time of year, my download is often below 1 Mbit and sometime it drops. :( I'll report back with progress.



LMAO, no your fine.. I should of packed up a thumbdrive and sent over a carrier pigeon lol. I'll keep watch for your reply if you need anything else. I still use this OVA today for alot of my programming so should work like a charm.

Statistics: Posted by AgentSmithers — Thu Dec 23, 2021 8:06 am


]]>
2021-12-22T18:41:55+08:00 2021-12-22T18:41:55+08:00 https://bbs.espressif.com:443/viewtopic.php?t=75264&p=100474#p100474 <![CDATA[Re: Broken Code with SDK 2.2 and newer]]>
AgentSmithers wrote:
Link as promised!
Download OracleBox and you can import the OVA.
https://drive.google.com/file/d/1JrA750 ... sp=sharing
Then import you project folder and compile and your good to go!
Let me know if you need help but that is a fully setup dev. If you need a test project if your having issues let me know and Ill zip one up with a makefile and send that over too.


Thank you for all your time. I hope I didn't take you away from festivities. :?
Later today, I'll go into town and download this at the library. If I remember correctly, these images are multi-gigabytes. I'm on a metered connection here at the house and with everyone home this time of year, my download is often below 1 Mbit and sometime it drops. :( I'll report back with progress.

Statistics: Posted by Inquisitor — Wed Dec 22, 2021 6:41 pm


]]>
2021-12-22T06:53:42+08:00 2021-12-22T06:53:42+08:00 https://bbs.espressif.com:443/viewtopic.php?t=75264&p=100473#p100473 <![CDATA[Re: Broken Code with SDK 2.2 and newer]]> Download OracleBox and you can import the OVA.
https://drive.google.com/file/d/1JrA750 ... sp=sharing
Then import you project folder and compile and your good to go!
Let me know if you need help but that is a fully setup dev. If you need a test project if your having issues let me know and Ill zip one up with a makefile and send that over too.

Statistics: Posted by AgentSmithers — Wed Dec 22, 2021 6:53 am


]]>
2021-12-16T06:03:23+08:00 2021-12-16T06:03:23+08:00 https://bbs.espressif.com:443/viewtopic.php?t=75264&p=100460#p100460 <![CDATA[Re: Broken Code with SDK 2.2 and newer]]> Statistics: Posted by AgentSmithers — Thu Dec 16, 2021 6:03 am


]]>
2021-12-16T06:02:57+08:00 2021-12-16T06:02:57+08:00 https://bbs.espressif.com:443/viewtopic.php?t=75264&p=100459#p100459 <![CDATA[Re: Broken Code with SDK 2.2 and newer]]> Statistics: Posted by AgentSmithers — Thu Dec 16, 2021 6:02 am


]]>
2021-12-15T23:28:00+08:00 2021-12-15T23:28:00+08:00 https://bbs.espressif.com:443/viewtopic.php?t=75264&p=100458#p100458 <![CDATA[Re: Broken Code with SDK 2.2 and newer]]>
AgentSmithers wrote:
Ah! I feel your pain, I used Pfalcons tool chain and had a hell of a time getting to Version 3.0+.
I have a VM premade with the environment setup in cent os (for this exact problem), Ill get it uploaded to Googledrive and you can download it and give it a run in Oracle box and move your files to it or from a share on your host OS. Its a complete setup of the latest SDK for NON-OS. Would that give you a hand?


Sure! That would be very helpful. At the very least it would confirm whether my program above works on pure Espressif SDK > 2.1. It would also confirm my suspicions that it's the Arduino libraries riding on top of Espressif SDK > 2.1 causing the problem.

Thank you for your help.

Statistics: Posted by Inquisitor — Wed Dec 15, 2021 11:28 pm


]]>
2021-12-14T05:02:38+08:00 2021-12-14T05:02:38+08:00 https://bbs.espressif.com:443/viewtopic.php?t=75264&p=100448#p100448 <![CDATA[Re: Broken Code with SDK 2.2 and newer]]> I have a VM premade with the environment setup in cent os (for this exact problem), Ill get it uploaded to Googledrive and you can download it and give it a run in Oracle box and move your files to it or from a share on your host OS. Its a complete setup of the latest SDK for NON-OS. Would that give you a hand?

Statistics: Posted by AgentSmithers — Tue Dec 14, 2021 5:02 am


]]>
2021-12-11T05:00:51+08:00 2021-12-11T05:00:51+08:00 https://bbs.espressif.com:443/viewtopic.php?t=75264&p=100439#p100439 <![CDATA[Re: Broken Code with SDK 2.2 and newer]]>

AgentSmithers wrote:
...
API Reference" for 2.2 and compared it to this below (version 2.0, look for 2.1 if you can, I couldn't find it online)
http://www.liot.io/media/liot_esp8266_e ... erence.pdf

In 2.2 I think if my memory serves me correctly they add a few new API commands for the 802.11 to adjust power savings to some extent. I would add those API's into your AP init code and toggle with those Params and see if it resolves your issue. If it does post back here so everyone else can see the result!


Last week in desperation, I did resort to looking for old documentation. I did not find any. Must have had the wrong search terms. So this document was a great find. Since your post, I have been scouring through the differences and trying various parameters. I would not have even tried things related to power settings. At this point, I'd try anything.

I think what bothers me the most is that no one else has this problem. I am beginning to think it has more to do with the Arduino implementation riding on top of the Espressif code base. I have tried...
  1. A totally NonOS version using VSCode/PlatformIO which is at 2.1.0. It works fine, showing the espconn_regist_disconcb() being called.
    good.png
  2. Unfortunately, I can't seem to find a way to make PlatformIO use a newer SDK. So, I have not found a way to test the above code with a true, unmodified SDK like 3.0+.
  3. I have tested it with the NonOS modified version in Arduino IDE that uses SDK 1.5 and again, it works fine the same as above.
  4. As soon as I move to the newer Arduino IDE versions that uses Espressif version 2.2 through 3.0 SDK, it serves up the web page five times and fails on the sixth request. The Browser shows a "This site can’t be reached The connection was reset."
    bad.png

Currently, I'm now focusing on what settings the Arduino version modifies that might cause this to fail. But again, I'm stuck with the lack of complaints on the Arduino forum. There differences seem to be that all their code is based on lwIP while the above code avoids even using that 3rd party library.

Thanks again!
VBR

Statistics: Posted by Inquisitor — Sat Dec 11, 2021 5:00 am


]]>
2021-12-09T16:59:51+08:00 2021-12-09T16:59:51+08:00 https://bbs.espressif.com:443/viewtopic.php?t=75264&p=100432#p100432 <![CDATA[Re: Broken Code with SDK 2.2 and newer]]> API Reference" for 2.2 and compared it to this below (version 2.0, look for 2.1 if you can, I couldn't find it online)
http://www.liot.io/media/liot_esp8266_e ... erence.pdf

In 2.2 I think if my memory serves me correctly they add a few new API commands for the 802.11 to adjust power savings to some extent. I would add those API's into your AP init code and toggle with those Params and see if it resolves your issue. If it does post back here so everyone else can see the result!

Also, do a full memory purge with esp_tool erase and reflash your 'esp_init_data_default' files to make sure everything is clean.

That should get you back and running.

Good Luck!

Statistics: Posted by AgentSmithers — Thu Dec 09, 2021 4:59 pm


]]>
2021-11-29T00:52:35+08:00 2021-11-29T00:52:35+08:00 https://bbs.espressif.com:443/viewtopic.php?t=75264&p=100404#p100404 <![CDATA[Broken Code with SDK 2.2 and newer]]> Can someone tell me what modifications I need to make to allow it to work with SDK > 2.2 and newer?

It is a simple Testing Web Server (only 230 lines). In old SDK (and current manual) espconn_regist_disconcb gets called and all works great. In 2.2 and newer it never gets called and fails after the 5th browser refresh.

Thanks.

Code:

#include "user_interface.h"
#include "espconn.h"
#include "osapi.h"
#include "driver/uart.h"
#include "mem.h"

#define SSID "<your SSID>"
#define PW "<your Password>"
#define HOST "ws"
#define dbg(f, ...) os_printf(f, ## __VA_ARGS__)

static os_timer_t ptimer;

// This PAGE only sends a one time page.
const char* PAGE = "<!DOCTYPE html><html><head><title>Native Server Test</title> <meta name='viewport' content='width=device-width, initial-scale=1'></head><body>  <h1>Welcome to my Native Server Test</h1></body></html>";
// This PAGE sends back a page that keeps reloading, so we can check for errors and/or memory leaks.
// const char* PAGE = "<!DOCTYPE html><html><head><title>Native Server Test</title> <meta name='viewport' content='width=device-width, initial-scale=1'><script>window.addEventListener('load',()=>{ setTimeout(()=>{location.reload();},500);},false);</script></head><body>  <h1>Welcome to my Native Server Test</h1></body></html>";

ICACHE_FLASH_ATTR void printIfErr(s8 esp, const char* msg)
{
    if (esp)
        os_printf("ERR - %s = %d\n", msg, esp);
}

ICACHE_FLASH_ATTR void hack(const char* msg)
{
    static u32 last = 0;
    u32 now = system_get_time();
    if (msg)
        os_printf("%s=%uus ", msg, now - last);
    last = now;
}

ICACHE_FLASH_ATTR void onDisconnect(void* c)
{
    hack("onDisconnect");
}

ICACHE_FLASH_ATTR void doDisconnect(void* c)
{
    hack("doDisconnect");

    struct espconn* conn = (struct espconn*)c;
   
    // ******** THIS IS WHERE I THINK THE PROBLEM IS ******************
    // In SDK <= 2.1.0 espconn_disconnect
    //        * does disconnect
    //        * does call espconn_regist_disconcb callback
    //        * does allow new connection after the first 5
    // In SDK > 2.1.0 espconn_disconnect
    //        * does NOT disconnect
    //        * does NOT call espconn_regist_disconcb callback
    //        * does NOT allow new connection after the first 5
   
    printIfErr(espconn_disconnect(conn), "disconnect");
}

ICACHE_FLASH_ATTR void onSent(void* c)
{
    hack("onSent");

    struct espconn* conn = (struct espconn*)c;

    os_timer_disarm(&ptimer);
    os_timer_setfn(&ptimer, (os_timer_func_t *)doDisconnect, conn);
    os_timer_arm(&ptimer, 5, 0);
}

ICACHE_FLASH_ATTR void onReceive(void* c, char* buf, u16 length)
{
    hack("onReceive");

    struct espconn* conn = (struct espconn*)c;

    // Print out the request just to make sure its what we think it is.
    static char buffer[1024];
    os_memcpy(buffer, buf, length);
    *(buffer + length) = 0;
    // os_printf(buffer);
    os_sprintf(buffer, "HTTP/1.1 200 OK\r\n"
        "Server: InqPortal/5.0\r\n"
        "Content-Length: %d\r\n"
        "Content-type: text/html\r\n"
        "Pragma: no-cache\r\n\r\n%s", strlen(PAGE), PAGE);
    printIfErr(espconn_send(conn, (u8*)buffer, strlen(buffer)), "send");   
}

ICACHE_FLASH_ATTR void onConnection(void* c)
{
    hack(NULL);

    static u32 cnt = 0;
    os_printf("\n%3u ", ++cnt);   
   
    struct espconn* conn = (struct espconn*)c;
    espconn_regist_recvcb(conn, onReceive);
    espconn_regist_sentcb(conn, onSent);
    espconn_regist_disconcb(conn, onDisconnect);   
}

ICACHE_FLASH_ATTR void startServer()
{
    // Setup and start web server listener
    LOCAL struct espconn listen;
    LOCAL esp_tcp tcp;
    os_memset(&listen, 0, sizeof(struct espconn));
    listen.type = ESPCONN_TCP;
    listen.state = ESPCONN_NONE;   
    listen.proto.tcp = &tcp;
    listen.proto.tcp->local_port = 80;
   
    espconn_regist_connectcb(&listen, onConnection); 
       
    printIfErr(espconn_accept(&listen), "listen");   
}

ICACHE_FLASH_ATTR void chkAP(void* arg)
{
    if (wifi_station_get_connect_status() != STATION_GOT_IP)
    {
        os_printf(".");
        return;
    }
    os_timer_disarm(&ptimer);

    struct ip_info info;
    wifi_get_ip_info(STATION_IF, &info);
    // This is just cook-book Station connection stuff.
    dbg("\n\nSDK version: %s\n", system_get_sdk_version());

    os_printf("\nBrowse to (http://%s/index.html) or (http://" IPSTR
        "/index.html)\n",
        HOST, IP2STR(&(info.ip)));
}

ICACHE_FLASH_ATTR void startStation()
{
    os_printf("\nConnecting to your router");

    struct station_config sc;
    os_memset(&sc, 0, sizeof(struct station_config));
    sc.bssid_set = 0;
    os_memcpy(&sc.ssid, SSID, 32);
    os_memcpy(&sc.password, PW, 64);   
    wifi_station_set_config_current(&sc);

    wifi_station_set_hostname(HOST);

    wifi_station_connect();

    os_timer_disarm(&ptimer);
    os_timer_setfn(&ptimer, (os_timer_func_t *)chkAP, NULL);
    os_timer_arm(&ptimer, 1000, 1);
}

ICACHE_FLASH_ATTR void startSoftAP()
{   
    // Start up the communications Host/Station and Client/Soft
    // ssid - Not NULL terminated in code - Can be 32 characters coming in! 
    // Password length must be blank OR >= 8!  Truncated if >= 64 characters.

    // Address
    wifi_softap_dhcps_stop();

    struct ip_info info;
    os_memset(&info, 0, sizeof(struct ip_info));
    // Don't set Gateway since we can't offer Internet / DNS
    // We're hardcoding our InqPortal server to always be 10.10.10.10.
    IP4_ADDR(&info.ip, 10, 10, 10, 10);   
    IP4_ADDR(&info.gw, 10, 10, 10, 10);   
    IP4_ADDR(&info.netmask, 255, 255, 255, 0);
   
    wifi_set_ip_info(SOFTAP_IF, &info);
   
    // Start up the DHCP server.
    wifi_softap_dhcps_start();
   
    struct softap_config cfg;
    os_memset((u8*)&cfg, 0, sizeof(struct softap_config));
   
    os_sprintf((char*)cfg.ssid, "%s-%X",
        "ESP8266", system_get_chip_id());
    cfg.ssid_len = strlen((char*)cfg.ssid);   
    // Password is null terminated (no length) specified.  Use this filling.
    os_sprintf((char*)cfg.password, "");
    cfg.channel = 1;
    cfg.authmode = AUTH_OPEN;
    cfg.ssid_hidden = 0;
    cfg.max_connection = 4;    // Note: default 4, max 4
    cfg.beacon_interval = 100; // Note: support 100 ~ 60000 ms, default 100   
   
    wifi_softap_set_config(&cfg);

    wifi_set_sleep_type(NONE_SLEEP_T);
}

ICACHE_FLASH_ATTR void user_init(void)
{
    uart_init(BIT_RATE_115200, BIT_RATE_115200);

    wifi_set_opmode(STATIONAP_MODE);

    startSoftAP();
    startStation();

    startServer();
   
   os_printf("Ready\n");
}

ICACHE_FLASH_ATTR uint32 user_rf_cal_sector_set(void)
{
    enum flash_size_map size_map = system_get_flash_size_map();
    uint32 rf_cal_sec = 0;

    switch (size_map) {
        case FLASH_SIZE_4M_MAP_256_256:
            rf_cal_sec = 128 - 5;
            break;

        case FLASH_SIZE_8M_MAP_512_512:
            rf_cal_sec = 256 - 5;
            break;

        case FLASH_SIZE_16M_MAP_512_512:
        case FLASH_SIZE_16M_MAP_1024_1024:
            rf_cal_sec = 512 - 5;
            break;

        case FLASH_SIZE_32M_MAP_512_512:
        case FLASH_SIZE_32M_MAP_1024_1024:
            rf_cal_sec = 1024 - 5;
            break;

        case FLASH_SIZE_64M_MAP_1024_1024:
            rf_cal_sec = 2048 - 5;
            break;
        case FLASH_SIZE_128M_MAP_1024_1024:
            rf_cal_sec = 4096 - 5;
            break;
        default:
            rf_cal_sec = 0;
            break;
    }
    return rf_cal_sec;
}

Statistics: Posted by Inquisitor — Mon Nov 29, 2021 12:52 am


]]>