I am trying to learn how to do OTA updates for the ESP32. I have built the ota_demo project:
And have followed the readme, as well as the additional steps here:
I have the project loaded onto an ESP32 device, and it is direct connected to SmartThings server. On the SmartThings app, when I go to the device’s menu (the three vertical dots on the top right of the screen) and select “Information”, there is an enabled button that says “Firmware update”. When I click it, it says the latest firmware will be installed. On the device, I get the following serial messages (after clicking the “Firmware update” button on the SmartThings app):
Starting OTA... _update_device E (50859) esp-tls: Failed to connnect to host (errno 113) E (50859) esp-tls: Failed to open new connection E (50859) TRANS_SSL: Failed to open a new connection E (50859) HTTP_CLIENT: Connection failed, sock < 0 Failed to open HTTP connection: 28674 E (59359) esp-tls: Failed to connnect to host (errno 113) E (59359) esp-tls: Failed to open new connection E (59359) TRANS_SSL: Failed to open a new connection E (59359) HTTP_CLIENT: Connection failed, sock < 0 Failed to open HTTP connection: 28674 Firmware Upgrades Failed (-1)
So the device definitely gets the command from the SmartThings server to try to OTA update, but then it is unable to connect.
It seems like this might be an issue with how I created the certificate for HTTPS, but I’m not 100% sure. There are a couple of steps in the process where I had questions, so I’ll outline them here in case I did something wrong.
The first question is when creating the scrip for the certificates. There are two domain names:
For SERVER_DOMAIN_NAME, I used the IP address of the computer I’m running the webserver. So I think that one is probably correct. But what do I put for ROOT_DOMAIN_NAME? I left it as “yourRootDomain” assuming it was for the ESP32, and it would use whatever IP address that it obtained when it connects to my WiFi? But maybe I’m supposed to explicitly set it?
The next question was when I created firmware_sign.py, I got an error when I tried to do the following:
# write signature's header fd.write("\xFF\xFF\xFF\xFF\x00\x00")
So I changed it to:
# write signature's header fd.write(binascii.unhexlify('FFFFFFFF0000'))
And same modification with the # write footer. I’m not sure if this is an acceptable change, but it allowed me to run the file without error.
Also in firmware_sign.py, there were a lot of spots that it had print without the () after, so I added those parenthesis, and the errors I were getting for that went away as well. I assume this has no bearing on the outcome.
Last, I wasn’t sure if the location of the webserver directory matters. I assume it doesn’t, but the example had it located in the ota_demo folder.
If anyone has any insight to the errors I am getting, or to any of the steps I have questions on, please let me know. Any help is appreciated.
BTW I’m using esp-idf v3.3, as recommended by @jody.albritton from his “How to Build Direct Connected Devices” post. Also, I’m tagging @nayelyz to make sure she sees this.