• @DrAzzy, is above code working to your expectations? I try to understand and get a bit confused about the sequence in which things get called. Last but not least the 15s timeout on line 16 throws me off. (The double-require of http - once in line 5 and the second time in 25 are probably just a casual thing...).

    To capture the ready state, Promise help. When challenged with that, I though chose a more lightweight approach and has retry option built in - and called it Tasker - Task synchronizer - kind of a 'purposed' Promise. It helped me to detangle the callbacks, and also get rid of timeouts that most of the time take annoying long but are never long enough when it comes to hick0-ups.

    As you posted in a different conversation, the callback-mania can become a throw-off and a challenge. May be it is a bit here too... So many things have to get ready - including dependencies have to be considered - before being able to 'moving on' - and you know only within (nested) callbacks when that is the case (for example, you need the ip address, which you can get when successfully connected, and then you can create the server...).

    I also wonder why you put all into one single object: wifi. Having the things separated would allow to exchange the 'http connection' with what ever is available C33K, ESP8266, WIZ550S2E,... On the other hand - as pointed out for your case - your gearing up for managing swarms of Picos that connect with ESP8266.

    Bottom line, the code you present, is straight forward.

About

Avatar for allObjects @allObjects started