CodeForAfrica / sensors.AFRICA-AQ-sensors-software

sourcecode for reading sensor data
8 stars 10 forks source link

OTA via Webserver #72

Closed gideonmaina closed 2 months ago

gideonmaina commented 2 months ago

Description

This PR adds the feature to update firmware via the webserver which is kept on at all times whether there is a connection to a WiFi hotspots or not. This feature will enable OTA updates eliminating the need to pull down and disassemble a sensor kit to upload new firmware during field work/maintenance.

Fixes #71

Type of change

Screenshots

Screenshot_2024-09-20-15-21-35-79_93753c020959de0ef194d6b95604fb93

Screenshot 2024-09-20 at 15 38 10

Checklist:

gideonmaina commented 2 months ago

@usmanbiu @augustinemwendwa72 I have added HTTP request error handling, file validation and page styling on the client side for different devices. An observed issue is that the ESP server does not send responses as expected for the client-side script to process it accordingly such as logging the response and displaying useful info to the user. This does not however affect the OTA update process so we are good to go.

Screenshot_2024-09-25-10-59-36-22_40deb401b9ffe8e1df2f1cc5ba480b12

usmanbiu commented 2 months ago

Hi @gideonmaina I pulled this branch to test and here are my observations. These observations were made on a kit that had its gsm antenna and LiPo disconnected so it switched on its web server. cc @augustinemwendwa72

  1. The 'secrets.h' file has not been included
  2. After including the 'secrets.h' file, I was able to access the web server without authentication
  3. All the web pages are active aside from the '/status' and '/images' pages simply redirect you to the '/config' page
  4. The webpages are slow to open when the device tries to read data from the sensors.

My next set of tests will be in a situation where the device is connected to a wifi network and the network sets its IP address.

gideonmaina commented 2 months ago

Aha! @usmanbiu for the authentication to work, you need to clear configs either by flashing the ESP or clear configs via the web page /removeconfig. I have only used the former.

For the webserver being slow, I haven't encountered that with recent updates. If you need help updating let me know.

usmanbiu commented 2 months ago

@gideonmaina I used the /removeConfig web page and it worked.

gideonmaina commented 2 months ago

Great! @usmanbiu I will delete this branch since I have merged it with the refactor branch

usmanbiu commented 2 months ago

@gideonmaina I has run tests with a sensor when it's connected to a wifi network that sets its IP address, it works fine. My next test will be to check the same functionalities of the web server of a sensor connected to a GSM network. cc @augustinemwendwa72

usmanbiu commented 1 month ago

@gideonmaina I observed that the 'refactor" code switches from GSM to WiFi if it cannot connect to a GSM network and does not revert back to GSM. Can you confirm this? My understanding is that it is supposed retry connecting to GSM (via a soft rest of the GSM module) after some time cc @augustinemwendwa72