A Basic Interpreter written from scratch for the ESP8266

Moderator: Mmiscool

User avatar
By sentinel
#62287 This is as far as I've got with the code, which seems to get as far as sending a report once, then seems to hang or stop. Unfortunately the server is not getting connected, so that is also a problem.
One difficulty is that when it is in this mode, the program cannot be modified since there seems to be no way to connect to it locally to send new Basic code. Would using the command "WIFIAPSTA" allow the use of a browser to locally monitor progress of the code for debug purposes while still allowing the device to connect to a remote server?

I'm also unsure whether data can be sent numerically or not.

Code: Select allb = 3
ssid = "My_router"
password = "password123"
print "SSID:"
textbox ssid
print "PASSWORD:"
textbox password
button "Connect", [connect_to_ap]

wifi.connect( ssid, password)   'Should there be a space before "ssid"?

delay 5000

Timeout = 0
 delay 3000
 Timeout = Timeout + 1
 Bla = telnet.client.connect(“”, 4801)   'Connect to the server
 If Timeout = 10 then
  Bla = 1
 End if
Loop until Bla > 0

Timer 20000, [Report]   'send a data report every 20 seconds

io(po,1,1)   'Turn on LED to indicate that the report is being sent
Bla = telnet.client.write(78;68;48;12;34;56;07;30;11111;22222;33333;44444;55555;60666;12345;54321;b;13;10)   
'Send a 32 byte report to the server consisting of 9 single byte values (+CR/LF terminator) and 8 16-bit values (Loendian?).
'Should the numbers be sent as a string or is this numeric format better?

Timeout = 0
Do         'Wait for acknowledgement that data was sent successfully.
 Timeout = Timeout + 1
 If Timeout = 10000 then   'Make sure that it doesn't get stuck in an infinite loop
  Bla = 2
 End if
Loop until Bla > 0

if Bla = 2 then
 io(po,2,1)   'Turn on error LED to indicate that no acknowledgement was received
 delay 1000
 io(po,2,0)   'Turn off error LED
 goto [connect_to_ap]
end if

io(po,1,0)     'Turn off report LED