HTTP (s) TCP File Download For OTA

PC based Python script example to download a file from a HTTP Server and send to a host processor. This example can be used to update your product over the air (OTA) or just to download a file off a HTTP or HTTPs server.downloadOTA

  1. Down load HFS free HTTP server and Start Server
  2. Setup a client to connect to module to send the following:
    ssid,password, security type,server DNS name or IP address,server port
  3. Edit URL in script to point to where you loaded file to be download
    //parsed = urlparse.urlparse(“http(s)://domain:Port/path/filename)
    //parsed = urlparse.urlparse(“http://10.16.190.166:1443/filename.bin”)
  4. Edit location in script to change location for the file to be saved.
    fname = “C:\\Users\\mypc\\test_download.bin”
  5. Run the script

Recommended tools:

  1. HFS File server Download here
  2. Python
  3. eS-WiFi drivers ( easily installed using our PC demo application (ZIP)

#——————————————————————————-
# Name: File Download to Host Interface Demo
# Purpose: To illustrate how to use the TCP/UDP cLient IWIN AT commands to
# download a file from a HTTP server and send the data to the host
# processor.
# Key Parameters to set:
baud = 115200
Protocol Setup
PROTOCOL=”0″ #TCP=0, UDP=1, UDP-Lite=2 TCP-SSL=3(Hercules doesn’t support)

#Local Network Setup
SSID = “xxxxxxxxxx” #SSID of AP
PSWD = “ThisIsMyWorkNetwork” #Password of AP
SEC=”4″ #Security type of AP: 0-Open, 1-WEP, 2-WPA, 3-WPA2-AES, 4-WPA2-Mixed
DHCP=”1″ #Get IP address for DHCP, 0-No, 1-Yes

#Client Mode
remoteIP = “192.168.10.100” #Remote Server IP address (use 192.168.10.100 with AD Direct Mode)
remotePort = “8002” #Remote TCP port

#Server Mode
clientIP = “192.168.10” #Client IP address, use to validate sever accept
localPort = “8003” #Local server port

#Parse URL
#parsed = urlparse.urlparse(“http://192.168.1.3:1443/ISM43362_M3G_L44_C2.5.0.17.ECO2.bin”)
parsed = urlparse.urlparse(“http://10.16.190.166:1443/ISM43362_M3G_L44_C2.5.0.17.ECO2.bin”)