The worst kind of bug

The worst kind of bug is the one which is not there. I spent a big chunk of today trying to figure out why MQTT settings weren’t being transferred correctly from the server into my embedded device. The idea is that you plug a brand new ESP8266 or ESP32 powered device your computer, visit the Connected Little Boxes website and all the firmware and settings are loaded into the device automagically. It was working fine with test messages, but not when I tried to use it to actually connect a device.

I built more complex tests, added diagnostics and still the system didn’t work. I was getting more and more confused until I realised one of the messages that I was sending had the wrong thing in it. In other words the transport mechanism was fine but because of a formatting error the setting wouldn’t work in the device. Silly me.

I’m not too unhappy though. The code is now a lot more tested than it was, and it has some diagnostic output which will be useful at some point. And it does indeed work now. The only thing you have to do is enter your WiFi credentials into the webpage so that the device can connect to the network. The device is configured and then added to the list of devices that you own. The next step is to add configuration pages for the internal device interfaces so that owners can make them into lights, buttons, dials, inputs, displays or whatever.