ESP8266 zbasic questions

Discussion of issues related to writing ZBasic applications for targets other than ZX devices, i.e. generic targets.
Post Reply
FFMan
Posts: 502
Joined: 09 January 2010, 12:52 PM

ESP8266 zbasic questions

Post by FFMan »

I have a few questions before I have a play with zbasic on esp8266. I don't think these are addressed in the helpful article on this but apologies if they are:-

1) the document states that Main() is called repeatedly, I am guessing/hoping that variable contents are preserved on each call. For contents to be preserved should the variables be declare in Main() or the init routine ? It looks like from the examples I can dim them in main and contents are preserved. Is State in anyway special or just a variable that starts at zero ?

2) I have been using an esp8266 with AT firmware to make a UDP call to an NTP server to get date & time. Does the connection to a wifi network set date and time for zbasic ? If not, can the new commands be used to make a UDP connection ?

3) If 'no' to question 2, would the AT firmware still be loaded (or does zbasic overwrite), active and accessible from zbasic code ?

thanks
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: ESP8266 zbasic questions

Post by dkinzer »

FFMan wrote:I am guessing/hoping that variable contents are preserved on each call.
Each invocation of Main() is just like each invocation of any other subroutine/function with regard to variable persistence. Variables that are declared inside a subroutine are *not* preserved across invocations unless they have the Static attribute. Of course, variables declared at the module level persist for the duration of application execution.
FFMan wrote:Is State in anyway special or just a variable that starts at zero ?
It is just an ordinary variable. Since it is declared at the module level it is automatically initialized to zero and the value persists across invocations of Main().
FFMan wrote:Does the connection to a wifi network set date and time for zbasic ? If not, can the new commands be used to make a UDP connection ?
There is no automatic initialization of the date/time. If you want to retrieve the date/time using the SNTP protocol you can use the resulting data to initialize the RTC. The ClientUDP project in the Examples-ESP8266 sub-directory of the ZBasic installation directory implements an SNTP client.
FFMan wrote:would the AT firmware still be loaded (or does zbasic overwrite)
The AT command application is an application just like one implemented in ZBasic. Any time you download an application to the ESP8266 the previously resident application is overwritten. Technically, if you are using Over-The-Air update (which ZBasic does not support), there are actually two separate application areas and new downloads are alternately overwritten. Even so, the application in one area cannot access the application in the other.
- Don Kinzer
Post Reply