These are chat archives for esp8266/Arduino

16th
Aug 2016
Mehrdad K
@mkeyno
Aug 16 2016 00:00
I might add I still have problem with software serial and ticker lib , those not perfectly work with wifi context
this is my function to send AT command and capture its respond
int sendCmdAndWaitForResp(const char* cmd, const char *resp, unsigned timeout)
{
  SIM.write(cmd);
 //Serial.println(cmd);
 SIM_BUFF="";
int len = strlen(resp);
    byte sum=0,Location=0;
    unsigned long timerStart,timerEnd;
    timerStart = millis(); 

    while(1) {
        if(SIM.available()) {
                        char c = SIM.read();
                        Serial.write(c);
                        if(c<32) SIM_BUFF+='_';
                        else     SIM_BUFF+=c;
                        Location++;
                        sum = (c==resp[sum]) ? sum+1 : 0;
                        if(sum == len) break;
                      }
       timerEnd = millis();
      // Serial.print(".");
        if((timerEnd - timerStart) > 1000 * timeout) return 0; 
        yield();
      }
    while(SIM.available())    SIM.read(); 
    return Location-len+1;  
}
this is ugly function but have less problem with wifi stack
Stavros Korokithakis
@skorokithakis
Aug 16 2016 00:11
yes, that seems fine, because you're calling yield() in the loop
are you still having problems?
Mehrdad K
@mkeyno
Aug 16 2016 00:13
my webserver and websocket service is not stable and after 20 minute my module reset
almost 20 minute
without trigger any issue
Stavros Korokithakis
@skorokithakis
Aug 16 2016 00:14
ah hmm
Ivan Grokhotkov
@igrr
Aug 16 2016 04:13
@luc-github @martinayotte thanks for bringing this to my attention, i have indeed overlooked this potential problem when i was refactoring WiFiClient
the issue here is that wificlient calls a method of SD class from a system task, and yield can not be used in a system task.
Luc
@luc-github
Aug 16 2016 08:22
@igrr thank you - so using delay(0) or optimistic_yield is the correct solution/workaround ?
Clemens Kirchgatterer
@everslick
Aug 16 2016 08:29
I miss documentation of delay(), yield() and optimistic_yield() desperately. especially the latter
yield() and delay() are documented, but it is not made explicit, when they are not allowed to be called
Ivan Grokhotkov
@igrr
Aug 16 2016 09:58
I'm not yet sure what the correct solution is. This issue is not necessarily limited to SD library. It seems that the asynchronous sending of data from a Stream can not be guaranteed, in general. Maybe we need to revert sending of Stream data in WiFiClient to the old way. This will mean less performance, but for now I don't see another way to guarantee compatibility with arbitrary Arduino Streams.
Changing yield to delay(0) effectively replaces it with a no-op when called from system task. So SD library can theoretically trigger a watchdog in some cases.
In case of SD, maybe it's not very probable. But other libraries providing Stream interfaces may behave differently.
Luc
@luc-github
Aug 16 2016 10:00
@igrr does this Stream issue may affect SPIFFS ? because recently I have a lot "freeze" using it that I did not have before
Ivan Grokhotkov
@igrr
Aug 16 2016 10:01
Yes it can. SPIFFS can also call optimistic_yield internally.
(it calls flash read/write/erase functions, which call optimistic yield in turn)
Luc
@luc-github
Aug 16 2016 10:03
Because now I use SPIFFS and SD in same time and got several strange random behaviour
I mean in same project / not in same time
Akash Ashok
@thehellmaker
Aug 16 2016 13:30
Hi Guys, I am trying to build OTA upgrade for my esp8266 and I have gone through the documentation and I have a few questions. I want to used the ESPhttpUpdate method
Here is what I plan to do
  1. Call an API on Amazon AWS LAmbda and check if an update is available
  1. If its available then point ESPhttpUpdate.update("192.168.0.2", 80, "/arduino.bin"); to an Amazon S3 file location with teh bin file
So I wanted to check up have you guys tried doing an OTA update from Amazon S3 before ?
Any tips and pointers there ?
Akash Ashok
@thehellmaker
Aug 16 2016 14:08
also does esphttpUpdate do DNS resolution ? Can I Used Domain name rather than IP ?
Akash Ashok
@thehellmaker
Aug 16 2016 14:13
and i plan to expose and api on esp access point where i can join on that access point and then start the OTA . This API will be an ESP async webserver. Is there a way to synchronize this api so that multiple calls will get serialized. Are there any synchronization constructs on esp8266. or since its an MCU i can safely assume only one thread executes requests and i can use a variable ot manage state of the OTA myself
Ivan Grokhotkov
@igrr
Aug 16 2016 14:38
ESPhttpUpdate can be handle domain names, it uses ESP8266HTTPClient library for all the HTTP stuff.
But it doesn't support redirects, so make sure the URL you provide is the final one and points directly to the firmware image (or a script which will send firmware image as response)
Async webserver callbacks will always be serialized, because they get dispatched from one single tcp/ip stack task.
Mehrdad K
@mkeyno
Aug 16 2016 14:43
@igrr my program work fine but after 20 minutes watchdog reset without any issue or error, is there a way I could find the reason or disable watchdog to reset my program
I mean is there way the watchdog just refresh wifi stack and not reset the program
Ivan Grokhotkov
@igrr
Aug 16 2016 14:44
Apart from the tcp/ip stack task there is also a task which runs setup and loop functions. Context switches between these two tasks happen cooperatively. From Arduino task one can switch to tcp/ip stack task by calling yield or delay; some Arduino classes also call these functions internally.
Mehrdad K
@mkeyno
Aug 16 2016 14:46
so what should I do?
Ivan Grokhotkov
@igrr
Aug 16 2016 14:47
@mkeyno that was a reply to @thehellmaker 's question :)
What do you get in serial output, Soft WDT reset or wdt reset?
Mehrdad K
@mkeyno
Aug 16 2016 14:47
soft wdt reset
Ivan Grokhotkov
@igrr
Aug 16 2016 14:48
it should be followed by a stack trace. use ESPExceptionDecoder to decode the stack. this will tell you which function is causing a watchdog reset.
Mehrdad K
@mkeyno
Aug 16 2016 14:49
there is no error or anythings comes out , just simply reset after exact 20min
Ivan Grokhotkov
@igrr
Aug 16 2016 15:28
So you don't see any serial output after Soft WDT Reset line?
Mehrdad K
@mkeyno
Aug 16 2016 15:51
nothings at all , maybe it is wdt reset, I can't fully recall but what I remember is, there is no error or special stack error
just the period of reset is similar
around 20 min
Germán Martín
@gmag11
Aug 16 2016 22:40
Hello, some days ago I asked for help on AsyncWebServer Gitter room. It seems it is not much populated these days so Probably you can help me here. It is a question related to C++ more than specific AsyncWebServer. I copy it here next
Hi, I feel frustrated with callbacks. I'm developing a customized AsyncWebServer library to be a startup framework for my projects. I'm stuck assigning class members to callbacks. I've read all that I've found in Google but I've not found a suitable solution. I've written a simple scketch with same structure that I'm using in my code. I know that, most probably, these are beginner problems but I do not want to give up yet. Please have a look to my Gist. I've added comments above lines with errors. Thanx in advance.
Ivan Grokhotkov
@igrr
Aug 16 2016 23:52
_periodicTrigger.attach(1,std::bind(&MyServer::periodicTask, this)); — you need to add _1 as an extra argument because periodicTask takes a void* argument and you aren't binding it.
Germán Martín
@gmag11
Aug 16 2016 23:56
I've tried that too. But it does not compile due to type mismatch.