Wireless programming is going to be kind of tricky to get it to work the way I would want it to…
What I would want is ideally:
- super simple
- always works
- secureish (so you can’t reprogram someone elses saber remotely)
- no need to open the saber to reprogram
I’m not sure I can have all of these though.
My first idea was to make it so that if you hold the power button while the saber is booting, then it goes into bootloader mode. I’m not sure how that would work if you don’t have a kill switch or kill key though. I mean, I could put a reset button on the board itself, but then you have to open the saber to program it…
The next issue is that wifi is not a point-to-point protocol, and really the only way to establish a connection between a computer and the esp32 is to have the esp32 know how to connect to the local wifi, which means it has to know the ssid and password to use. Once it’s connected we can use zeroconf or some other kind of broadcast to find out the right IP, and then we can talk to it.
Now, blutetooth on the other hand is a point-to-point protocol, and it comes in two flavors; BLE and old-fashioned bluetooth. Old-fashioned bluetooth has the Serial Port Profile, which would be nice, because it could show up as a port on the computer, which could be selected in Arduino and programmed. However, only some of the Esp32 chips support old-fashioned bluetooth, and those chips don’t have enough pins to work well for a proffieboard.
The last candidate is BLE. BLE is weird, but it’s low enough energy that we might be able to keep it on most or all of the time, which is cool. BLE is a slow, but, maybe I can set it up so that we send the SSID and password for the wifi over BLE. Then we use wifi from there.
None of this is great though. If you type in the wrong password, how will you know?
What if you’re away from home and trying to program the board in a location that doesn’t have wifi? There are a million things that could go wrong, and identifying and fixing them might not be easy. Also, this only works if the computer has a bluetooth adapter, which is not always true for desktop computers.
An alternative would be to have the esp32 act as an access point, and you connect to it to talk to it. Again, this might not work for desktops, and some computers and phones don’t like it when you connect to an access point that has no internet access. Also, it can be tricky to convince a computer to be connected to two different access points, so in most cases it means that you loose internet access while connected to the esp32 access point.
It would also be possible to do it the other way around; have the computer act as an access point and have the esp32 connect to it. Most computers nowadays have an internet sharing mode where they can be both an access point while also being connected to a separate access point, but activating that is generally done through some control panel option which is not particularly simple, and I don’t know if it’s even possible to have a script running from inside arduino activate it. (It probably requires admin access.)
Ok, so far none of these options are simple, reliable and always works.
Maybe cables are better…