Mick Mick
/
SX1272_TestApp
Simple SX1272 Test Application
Diff: main.cpp
- Revision:
- 2:61713a461cf1
- Parent:
- 1:4c82bff12ad0
- Child:
- 3:e42efecbbe1b
diff -r 4c82bff12ad0 -r 61713a461cf1 main.cpp --- a/main.cpp Mon Apr 24 09:36:52 2017 +0000 +++ b/main.cpp Tue Apr 25 07:31:14 2017 +0000 @@ -33,6 +33,7 @@ int main() { Timer t; uint32_t TxFreq; + double PktToA; pc.printf("HelLo Ra !\n"); @@ -44,13 +45,14 @@ while( 1 ) { + // Check if there is a packet to be sent if( ButtonPressed == true ) { // Configure radio TxFreq = 867720000; Radio.SetChannel( TxFreq ); - Radio.Write( REG_LR_SYNCWORD, 0x34 ); // public: to be replaced with SetPublicNetwork() when available - Radio.SetTxConfig( MODEM_LORA, 14, 0, 0, CurrentDatarate, 1, 8, false, true, 0, 0, false, 3e3 ); + Radio.SetPublicNetwork( true ); + Radio.SetTxConfig( MODEM_LORA, 14, 0, 0, CurrentDatarate, 1, 8, false, true, 0, 0, false, 3e3 ); // Set packet payload //LoRaWANBuffer[0] = 0x40; // Unconfirmed Data Up @@ -66,13 +68,19 @@ LoRaWANBuffer[9] = 0x0; // FRMPayload // Send packet + PktToA = Radio.TimeOnAir( MODEM_LORA, 14 ); Radio.Send( LoRaWANBuffer, 14 ); + pc.printf( "sending LoRa packet: Freq=%u, SF%u (%.1lfus)...\n", TxFreq, CurrentDatarate, PktToA ); + wait_us( PktToA ); + pc.printf( "sent.\n"); FCnt += 1; - pc.printf( "LoRa packet: Freq=%u, SF%u\n", TxFreq, CurrentDatarate ); // Stop sending ButtonPressed = false; } + + // Receive packets + } } \ No newline at end of file