-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttpget.bas
More file actions
149 lines (118 loc) · 3.72 KB
/
Copy pathhttpget.bas
File metadata and controls
149 lines (118 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#lowercase
start:
POKE 53272,23
PRINT CHR$(5): PRINT CHR$(147): PRINT CHR$(19);: REM CLEAR SCREEN, WHITE TEXT
open2,2,4,chr$(8)+chr$(0):rem open the serial from user port
print "starting"
print#2,"at&k1":gosub transmit
for i = 1 to 5
gosub response
NEXT
showinstructs:
gosub instructions
selection:
u$="": i$="": get i$
if i$="1" then print "1 selected": u$="atgethttp://192.168.0.103/WIN&a=64&pl=1": gosub transmit
if i$="2" then print "2 selected": u$="atgethttp://192.168.0.103/WIN&a=64&pl=2": gosub transmit
if i$="3" then print "3 selected": u$="atgethttp://192.168.0.103/WIN&a=64&pl=3": gosub transmit
if i$="m" then print "m selected": u$="atgethttps://hook.eu2.make.com/AD3MIE2EHS5UUHJO3N630YUT9GUHIWJ1?message=c64+basic": gosub transmit
if i$="t" then print "t selected": u$="atgetHTTPS://TIMEAPI.IO/API/TIMEZONE/ZONE?TIMEZONE=EUROPE/LONDON": gosub gettime
if i$="w" then print "w selected": u$="atgetHTTPS://V2.WTTR.IN/YORK,UK": gosub weather
if i$="r" then print "r selected": u$="atgethttps://www.random.org/INTEGERS/?NUM=1&MIN=1&MAX=20&COL=1&BASE=10&FORMAT=PLAIN&RND=NEW": gosub transmit
if i$="d" then print "d selected": u$="atgetHTTPS://API.DICTIONARYAPI.DEV/API/V2/ENTRIES/EN/NERD": gosub transmit
if i$ = "" then goto selection: rem loop back to start of the main loop again
for i = 1 to 5
gosub response
NEXT
goto showinstructs:
close 2: end
transmit:
print#2,u$ + chr$(10)+chr$(13);:u$=""
print ""
waiting:
if PEEK(673) AND 1 then print ".";: goto waiting: rem still transmitting
for i = 1 to 5
gosub response
NEXT
return
rem get the response until nothing waiting
response:
s$="":get#2,s$:
if s$="" then goto shortdelay
if s$=chr$(13) or s$=chr$(10) then print s$;:goto response
if s$<" " or s$>"Z" then goto response
print s$+"";:goto response
shortdelay:
for w=1 to 400: next
return
rem get the url and then
rem parse the result from timeapi
gettime:
print#2,u$ + chr$(10)+chr$(13);:u$=""
print ""
waitfortime:
if PEEK(673) AND 1 then print ".";: goto waitfortime: rem still transmitting
rem get the time
cc=0 : rem the api will return more chars that we can use
ts$ = "": nw$=""
parsetime:
get#2,s$:if s$<>"" and cc < 255 then ts$ = ts$ + s$:cc=cc+1:goto parsetime
nw$=mid$(ts$,176,22): ts$=""
for c = 1 to len(nw$)
c$ = mid$(nw$,c,1)
if c$="t" then i=c
NEXT
h$=mid$(nw$,i+1,2)
m$=mid$(nw$,i+4,2)
s$=mid$(nw$,i+7,2)
print ""
print h$ + ":" + m$ + ":" + s$
print ""
if val(h$)<25 and val(m$) < 60 and val(s$)<60 then time$ = h$ + m$ + s$
leftoverbytes:
get#2,s$:if s$<>"" then goto leftoverbytes
for w=1 to 1000: next
return
restweatherbytes:
get#2,s$: if s$<>"" goto restweatherbytes
return
rem weather
weather:
rem get the url and then
rem parse the result from weather url
gosub restweatherbytes
print#2,u$ + chr$(10)+chr$(13);:u$=""
print ""
waitfortransmit:
if PEEK(673) AND 1 then print ".";: goto waitfortransmit: rem still transmitting
parseweather:
for c=1 to 1160: get#2,s$: next
rem weather string length ~30
wl=50
parseweatherstr:
get#2,s$
if s$ = chr$(13) or s$=chr$(10) and len(w$)<wl then w$ = w$ + s$ : goto parseweatherstr
if s$ >= " " and s$ <= "Z" and len(w$)<wl then w$ = w$ + s$ : goto parseweatherstr
if len(w$)=wl then goto showweather
if s$<>"" goto parseweatherstr
gosub restweatherbytes
return
showweather:
print chr$(147)
print "current weather"
print w$:
w$="":
print "": print "press a key"
waitforkey:
get k$: if k$="" then goto waitforkey
print "please wait ..."
goto restweatherbytes
instructions:
PRINT CHR$(5): PRINT CHR$(147): PRINT CHR$(19);: REM CLEAR SCREEN, WHITE TEXT
print "select 1, 2 or 3 for led sequences"
print "select m to send a message to iphone"
print "select t current time from the internet"
print "select w for weather"
print "select r for random d20 roll"
print "select d for dictionary"
RETURN