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.
-
- Down load HFS free HTTP server and Start Server
- Setup a client to connect to module to send the following:
ssid, password, security type, server DNS name or IP address, server port - 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”) - Edit location in script to change location for the file to be saved.
fname = “C:\\Users\\mypc\\test_download.bin” - Run the script
Recommended tools:
- HFS File server Download here
- IWIN AT Command Example- TCP -UDP File Download Script Python
- eS-WiFi PC drivers ( easily installed using our PC demo application (ZIP)
New Features:
- Prompts User for SSID, PASSWORD, SECURITY and URL(must include port)
- Selects TCP or TLS based upon the http or the https in the URL
- Uses the file name in the URL when saving the file to the script’s location
- Recommend HFS server for local http testing: http://www.rejetto.com/hfs
- For https testing: http://www.rejetto.com/wiki/index.php?title=HFS:_Secure_your_server
- stunnel: http://www.stunnel.org/downloads.html
- zlib1.dll: http://www.zlib.net/
- For https testing: http://www.rejetto.com/wiki/index.php?title=HFS:_Secure_your_server
#——————————————————————————-
# 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_Cxxx.bin”)
parsed = urlparse.urlparse(“http://10.16.190.166:1443/ISM43362_M3G_L44_Cxxx.bin”)