Update with OTA

This is a user guide about upgrading code over-the-air(OTA)

Step 1 - Creating files and folders

  • Create folder sample in desktop

  • Create folder 1.0.0 in sample

  • Create file version in sample

  • Create boot.py and main.py in 1.0.0

desktop/
|- sample/
|  |- version
|  |- 1.0.0/
   |  |- boot.py
   |  |- main.py

Step 2 - Adding user codes

  • Add code in boot.py

import pywpc_ota

def do_update(host_ip, port):
   # connect to network
   ota_host = "http://%s:%d" % (host_ip, port)
   print(ota_host)
   project_name = 'sample'
   filenames = ['boot.py', 'main.py']
   pywpc_ota.ota_update(ota_host, project_name, filenames, use_version_prefix=False, hard_reset_device=True, soft_reset_device=False, timeout=1)

do_update('192.168.5.118', 9000)
  • Add code in main.py

print("This is version 1.0.0 in main.py.")
  • Add code in version

1.0.0

Step 3 - Open sever

  • Open command prompt in your PC

  • python -m http.server port –bind YOUR PC IP –directory LOCATION OF FOLDER

python -m http.server 9000 --bind 192.168.5.118 --directory C:/Users/user/Desktop

Step 4 - Reboot

  • Reboot your device