[Coco] Basic09 procedure to access the ESP8266 wifi modem

Gene Heskett gheskett at shentel.net
Sat Jan 16 02:46:54 EST 2021


On Friday 15 January 2021 23:07:01 Doug Fraser wrote:

> I have an ESP8266 for use as a WiFi modem using a modified DCModrm
> pak, for RS-232 pak. There is a Hayes command to access the NTP time
> server so one can set the system time. As I use primarily Nitros9,
> I've tried the following procedure in Basic09, but it just prints the
> command to the screen and exits, when its supposed to set the timezone
> and return the time for eventually setting the system time. For any
> Nitros9 gurus out there, what am I missing?
>
> PROCEDURE netime
> (* Variables
> PARAM modem,timezone:STRING[4]
> DIM path:BYTE
> DIM atcommand,ntptime:STRING
>
> (* Prep the Hayes at&t command
> atcommand="at&t "+chr$(34)+timezone+chr$(34)
>
> (* Open path to serial port
> OPEN #path,modem:UPDATE
>
> (* set up timezone
> WRITE #path,atcommand
>
> (*  ask for time
> atcommand="at&t"
> WRITE #path,atcommand
>
> READ #path,ntptime
> CLOSE #path
> PRINT ntptime
>
> Any help would be greatly appreciated.
> Doug
>
os9 returns the memory when the procedure is finished so that data exists 
only in the screen buffer. You need to open a file, in UPDATE mode, and 
output ntptime into that file, then close it then read that file for 
settime data which will by then be a wee bit stale. That might take some 
reformatting. But in this case, I think I would parse it into bytes that 
match the dp definitions, and write it directly to those 6 locations in 
the dp page. This is assuming you don't have a realtime clock.

If you do, you will have to use the matching settime or it will update 
you to the probably wrong time on the next update from the clock chip.

Software clocks are pretty sloppy, so I'd probably write a cron driven 
daemon to update you clocks time at 10 minute intervals from a local 
server that does keep good time. I know linux can act as an ntp client 
and server, I'm doing it with this machine, serving the other 4 here, 
and I expect windoze has a similar utility. cron isn't part of os9, but 
is I think, included in nitros9. I wrote it probably 30 years ago. Runs 
on a level 1 system too.

Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.
 - Louis D. Brandeis
Genes Web page <http://geneslinuxbox.net:6309/gene>


More information about the Coco mailing list