PC based Tera-term macro or Python script example to send a “GET” using DNS lookup to a HTTP Server.
- Down load Tera Term
- Connect the eS-Wifi module to the PC
- Setup the comm port and Tera Term terminal with Transmit and Receive with CR+LF
- Edit the Macro with your router with ssid, password, security type
- Under the Tera-Term “Control” drop down menu select “Macro” and point to unzip HTTP macro below.
Recommended tools:
- Teraterm
- HTTP Get Macro (zip) or see code below
- eS-WiFi drivers ( easily installed using our PC demo application (ZIP)
Optional tools:
If you prefer Python – Python example
—————————————————————————-
Teraterm Macro – Setup, Terminal, New-Line should be set to CR+LF for both Receive & Transmit
;Fill in your ssid and password
SSID=””
PSWD=””
sendln ‘C1=’SSID
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
sendln ‘C2=’PSWD
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
sendln ‘C3=4’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
sendln ‘C0’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
;Default Remote port, [P4]
port = ’80’
;Protocol
proto = ‘0’
;Packet
;get//http://urlecho.appspot.com/echo?status=200&Content-Type=text%2Fhtml&body=Hello%20world
Pkt0 = ‘GET /echo?status=200&Content-Type=text%2Fhtml&body=Hello%20world HTTP/1.1’#$D#$A
Pkt1 = ‘Host: urlecho.appspot.com’#$D#$A’Connection: close’#$D#$A#$D#$A
;All HTTP request end in 1 blank line
dispstr Pkt0
sendln ‘I?’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
sendln ‘R1=1460
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
sendln ‘R2=10000’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
sendln ‘R?’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
sendln ‘S2=100’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
sendln ‘S?’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
;Protocol settings
sendln ‘P?’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
;Setup
sendln ‘P1=’proto
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
sendln ‘D0=urlecho.appspot.com’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
sendln ‘P4=’ port
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
sendln ‘P?’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
;Connect
sendln ‘P6=1’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
;Send
send ‘S3=124’#$D Pkt0 Pkt1
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
;Receive
sendln ‘R0’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
;Disconnect
sendln ‘P6=0’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
;Jump to end
goto cend
;Command Error
:cerror
dispstr #13#10#10′[SCRIPT ] ***** Command Failed *****’#13#10#10′> ‘
;Exit
:cend
sendln ‘P6=0’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror
sendln ‘CD’
wait ‘OK’ ‘ERROR’
if result=2 goto cerror