NUKnightLab / SensorGrid

10 stars 2 forks source link

Adalogger write to SD card is conflicting with WiFi #2

Open scott2b opened 7 years ago

scott2b commented 7 years ago

Sort out conflict between logger writing and WiFi module. Config read only of the SD card seems to be ok. Worst case if not resolvable: spec out/implement a mechanism for making WiFi logging/SD card logging on a collector either/or

This seems likely due to sharing the SPI. See this thread for more general info on integrating WiFi w/ LoRa feather https://forums.adafruit.com/viewtopic.php?f=57&t=104164&p=523629&hilit=share+miso#p523629

scott2b commented 7 years ago

Per discussion here: https://forums.adafruit.com/viewtopic.php?f=57&t=113864&p=569494&hilit=wifi+spi#p569494

Fix seems not to be trivial. Looking at SDFat code, it seems to do a good job of writing CS HIGH after operations. WiFi101 however uses timer interrupts. Thus queueing operations is probably the best bet. This actually seems reasonable given that we want simply to write each log line and post the same data to the API, thus SPI bus management can be handled by function issuing these operations

scott2b commented 7 years ago

There is some good general info about the SPI bus here http://arduino.stackexchange.com/a/16349

scott2b commented 7 years ago

After much effort: Unable to get WINC1500 and Adalogger to share SPI bus for logger writes. WiFi does not want to reconnect after losing the SPI. Things tried:

In the end, unable to get WiFi to continue after writing to the SD card. For now settle with incompatibility between logging and WiFi API posts. SD card read for configs still seems to be ok.

We might consider doing a fallback to SD logging if WiFi can't connect -- depending on how reliable we find WiFi API posts to be.