-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Hello,
It appears that, when running in normal conditions with ArduinoLowPower, the library stops on the second occurence.
On first occurence, all code is ran properly, on second occurence, code stops right after:
spi_port->transfer(0x10);
in int SIGFOXClass::send(unsigned char mess[], int len, bool rx)
method.
So the second message is received on Sigfox backend, but then nothing happens after this.
Some other users where able to reproduce this:
https://forum.arduino.cc/index.php?topic=629227.0
I have noticed it happens with timed sleep, not event ones.
As a workaround, I tried to clean SPI before the sleep, start it again after, and end it up properly in the end() fuction of the library:
Both block where changed to:
#ifdef SIGFOX_SPI
spi_port->end();
LowPower.attachInterruptWakeup(interrupt_pin, NULL, FALLING);
LowPower.sleep(timeout);
spi_port->begin();
spi_port->setDataMode(SPI_MODE0);
spi_port->setBitOrder(MSBFIRST);
#endif
And this SPI end in following function:
void SIGFOXClass::end()
{
pinMode(poweron_pin, LOW);
delay(1);
digitalWrite(chip_select_pin, LOW);
delay(1);
spi_port->beginTransaction(SPICONFIG);
spi_port->transfer(0x05);
spi_port->endTransaction();
delay(1);
digitalWrite(chip_select_pin, HIGH);
delay(1);
spi_port->end();
}
Not sure yet if this issue is purely relaed to ArduinoLowPower library with SPI of if it is a normal behavior and therefore need to be handled differently in Sigfox library.