Writing up code as you write it

I’ve found a good use for all that time I seem to be spending waiting for my programs to compile and deploy to my hardware. I’m writing up what I’m trying to do. This is what I wrote today:

  • fixed a bug whereby only the latest reading and not the average environmental values are sent in an MQTT reading.

  • changed the handling of timeout so that an incomplete reading is sent rather than just skipping a reading

  • bug in modification so that the air quality reading was not sent when only the environmental sensor was disabled. This is because the reading age was less than the reading timeout. So a reading taken at the start of the reading period would be "out of date" by the time that the reading had timed out. Fix this by increasing the reading age to 60 seconds. Also modified the reading timeout setting so this cannot be set more than 60, so that a user couldn't cause this by silly settings.

  • added a 1 second delay before powering down after a message has been sent so that we can send MQTT messages to the device when we know it is awake. Managed this delay to ensure that it is none blocking.

  • found a nasty bug in MQTT message decoding that broke the decoding of incoming messages. Put the MQTT message decode into the main thread rather than calling the JSON decoder on the callback which is running on a network interrupt because it broke the Serial.print output. Added better decoding of the message types (better as in working).