Update main.cpp
This commit is contained in:
parent
087b206ea1
commit
d884e33ec0
26
main.cpp
26
main.cpp
|
@ -75,21 +75,21 @@ void loop()
|
||||||
{
|
{
|
||||||
switch(state)
|
switch(state)
|
||||||
{
|
{
|
||||||
case TX:
|
case TX:
|
||||||
#ifndef SILENT
|
#ifndef SILENT
|
||||||
Serial.print("Sending packet..");
|
Serial.print("Sending packet..");
|
||||||
Serial.printf("(Size: %i)..", rxSize);
|
Serial.printf("(Size: %i)..", rxSize);
|
||||||
#endif
|
#endif
|
||||||
Radio.Send( (uint8_t *)mPacket, rxSize );
|
Radio.Send( (uint8_t *)mPacket, rxSize );
|
||||||
state=LOWPOWER;
|
state=LOWPOWER;
|
||||||
break;
|
break;
|
||||||
case RX:
|
case RX:
|
||||||
Radio.Rx( 0 ); // receive mode with no time-out
|
Radio.Rx( 0 ); // receive mode with no time-out
|
||||||
state=LOWPOWER;
|
state=LOWPOWER;
|
||||||
break;
|
break;
|
||||||
case LOWPOWER:
|
case LOWPOWER:
|
||||||
lowPowerHandler(); // put SoC to sleep, wake-up at LoRa receive
|
lowPowerHandler(); // put SoC to sleep, wake-up at LoRa receive
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -98,10 +98,10 @@ void loop()
|
||||||
|
|
||||||
void OnTxDone( void )
|
void OnTxDone( void )
|
||||||
{
|
{
|
||||||
#ifndef SILENT
|
#ifndef SILENT
|
||||||
Serial.println(".done!");
|
Serial.println(".done!");
|
||||||
#endif
|
#endif
|
||||||
state=RX; // switch to receive mode
|
state=RX; // switch to receive mode
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnTxTimeout( void )
|
void OnTxTimeout( void )
|
||||||
|
@ -115,8 +115,8 @@ void OnTxTimeout( void )
|
||||||
|
|
||||||
void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr )
|
void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr )
|
||||||
{
|
{
|
||||||
|
( size > BUFFER_SIZE ) ? rxSize = BUFFER_SIZE : rxSize = size;
|
||||||
memcpy( mPacket, payload, size );
|
memcpy( mPacket, payload, size );
|
||||||
rxSize=size;
|
|
||||||
Radio.Sleep();
|
Radio.Sleep();
|
||||||
#ifndef SILENT
|
#ifndef SILENT
|
||||||
Serial.printf("\nReceived packet! (Size %i bytes, RSSI %i, SNR %i)\n", size, rssi, snr);
|
Serial.printf("\nReceived packet! (Size %i bytes, RSSI %i, SNR %i)\n", size, rssi, snr);
|
||||||
|
|
Loading…
Reference in New Issue