Code changes
Another change inspired by the Pi Wars conference was re-examining my use of threads.
Let me add some more background. The pymesh lora mesh networking feature built into these devices and their corresponding pycom gateway is brilliant. It essentially nulls out the need for dedicated gateways to use lora to extend coverage beyond NB-IOT and wifi range. However, the catch was that whenever I enabled this feature performance slowed to a crawl. Evidently it was using a fair bit of processor grunt. it was probably using a fair bit of extra power too (I'll measure it at some point). The later I'm not worries about, battery life is already way above spec, but all that processor usage slowed the speed of reading and sending NFC data, and that was not good.
The solution? Make my code run faster, and reduce processor usage. Easiest solution was I was running a thread that was not required. On the old code-
- Script started and did a lot of setting up
- Thread 1 started for NFC reading, time stamping and storing
- Thread 2 started for transmission
- Script starts, does a lot of setting up then starts NFC scanning
- Thread 1 starts for transmission
Comments
Post a Comment