Cleaning Up And Commenting Sawppy Rover ESP32 Code
The rover is now up and running on its own, independent of my home network. I felt this was a good time to pause feature development of Sawppy ESP32 control software. From an user experience viewpoint, this software is already in better shape than my SGVHAK rover software. Several of the biggest problems I've discovered since our local rovers started running have been solved. I feel pretty good about taking this rover out to play. More confident, in fact, than rovers running my earlier software.
Before I turn my attention elsewhere, though, I need to pay off some technical debt in the areas of code organization and code commenting. I know if I don't do it now, it'll never happen. Especially the comments! I'm very likely to forget if I don't write them down now while they're fresh in my mind. The code organization needed to be tamed because there were a lot of haphazard edits as I experimented and learned how to do things in two new environment simultaneously: ESP32 and JavaScript. The haphazard nature was not necessarily out of negligence but out of ignorance as I had no idea what I was doing. Another factor was that I copied and pasted a lot of Espressif sample code (especially in the WiFi area) and I had instances of direct copied text "EXAMPLE" that needed to be removed.
I also spent time improving code robustness with error handling code paths. And if errors are not handled, they should at least be reported. I have many unhappy memories trying to debug some problem that made no sense, and eventually traced it to a failed API call upstream whose error code was never reported. Here I found Espressif's own ESP_LOG
AND ESP_ERROR_CHECK
macros to be quite handy. Some were carried over directly from sample code. I've already started using ESP_ERROR_CHECK
during experimentation, because again I didn't have robust error handling in place at the time but I wanted to know immediately if something fails.
Since this was my first nontrivial ESP32 project, I don't think it's a good idea for anyone to use and copy my amateurish code. But if they want to, they should be allowed to. Thus another bulk edit added the MIT license prefix to all of my source files. Some of them had pieces copied from Espressif example, but those were released to public domain so I understand there would be no licensing conflict.
While adding error handling code, though, I wasted an hour to a minor code edit because I didn't have debug tools.
[Code for this project is publicly available on GitHub]