HTTP Get Request

PC based Tera-term macro or Python script example to send a “GET” using DNS lookup to a HTTP Server.

  1. Down load Tera Term
  2. Connect the eS-Wifi module to the PC
  3. Setup the comm port and Tera Term terminal with Transmit and Receive with CR+LF
  4. Edit the Macro with your router with ssid, password, security type
  5. Under the Tera-Term “Control” drop down menu select “Macro” and point to unzip HTTP macro below.

Recommended tools:

  1. Teraterm
  2. HTTP Get Macro (zip) or see code below
  3. 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

2015-09-10T13:48:27+00:00 2018-06-07T02:02:50+00:00