You can chat about native SDK questions and issues here.

User avatar
By MartinC
#73378 The Espressif NONOS_SDK documentation https://www.espressif.com/sites/default/files/documentation/2c-esp8266_non_os_sdk_api_reference_en.pdf describes the API for using the software timer via (mainly) three functions: os_timer_arm(), os_timer_disarm() and os_timer_setfn(). These take a pointer to a structure os_timer_t that contains among other things a timer handle and a pointer to the next timer.
At no point do I see any mention of how you should initialise this structure. All the examples I've seen (e.g. Blinky) simply define a global os_timer_t and then without any initialisation start passing it to the API functions. This evidently works, but it feels risky - e.g. for the initial call to os_timer_disarm(). Maybe one of these calls (os_timer_arm()?) populates the structure with valid members like the timer handle, but is it known which one and which parts of the structure it populates?
Code: Select alltypedef struct _os_timer_t {
    struct _os_timer_t *timer_next;
    void               *timer_handle;
    uint32             timer_expire;
    uint32             timer_period;
    os_timer_func_t    *timer_func;
    bool               timer_repeat_flag;
    void               *timer_arg;
} os_timer_t;
User avatar
By MartinC
#73391 A reference in this page: http://sub.nanona.fi/esp8266/hello-world.html suggests that it may be the call to os_timer_setfn() which initialises the structure. It would be interesting to see if it also sets the ‘pointer to next timer’ in order to keep them as a linked list. Several sources refer to there being a max of 7 software timers - if anyone has successfully used more than one please share how you did it - thanks