Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By Eddiie
#9518 Hello,
I have gone through all of this so quickly, forgive me if something is incorrect.

Using Espressif and IoT SDK along with Sprite's webserver. (Sprite, you da man!)

I just want to throw a GPIO high for 3 seconds and put it low again after. THATS IT!!!!

Can't use a loop, watchdog kicks in and resets the chip (thanks for pointing that out Sprite)

I found a timer function in some of the code, it looks like it has 3 calls -
Arm, reset, callback.

I set the reset and arm. I eliminated the callback because I could not think of anything to put in there. To my surprise, the timer doesn't work.

I've spent hours on this and am frustrated. When I can't do simple things, it gets to me. Being a Windows person, I've jumped through many hoops to make a compiling environment on Linux. That was simple compared to making a 3 second pause.

Links on Google don't seem to help, they use while(1) which I am pretty sure is blocking. Another example uses C++ in C code, I am not even sure if all C functions are available.

So, before I waste any more time, start breaking more things, can someone show me a simple easy to understand timer example using the above SDK(s), compilers, whatever? Don't write the whole code for me, not looking for that but want to make the connections in my head so I understand where I am going wrong!! GRRRR Just show me a simple working example.

Furthermore, is there a link or document somewhere that shows all the available functions for the SDK? With code samples?

Thank you.
User avatar
By Eddiie
#9521 Maybe the callback function should set the gpio low when called!
Will try it when I get home.
User avatar
By Eddiie
#9526 So, in Sprite's sample code - cgiwifi.c there is a timer..

Code: Select allfuncton here  {
     static ETSTimer resetTimer;
.....

     os_timer_disarm(&resetTimer);
     os_timer_setfn(&resetTimer, resetTimerCb, NULL);
     os_timer_arm(&resetTimer, 4000, 0);
......
}


Callback
Code: Select allstatic void ICACHE_FLASH_ATTR resetTimerCb(void *arg) {
       ....
}



So, os_timer_disarm(), os_timer_setfn(), os_timer_arm() are functions... Typing through this, it seems

os_timer_disarm to disable any pre-existing timer?
os_setfn to define what to do when the timer expires
os_arm to start the timer!

?