Simple SX1272 Test Application

Dependencies:   SX1272Lib mbed

Revision:
0:7e7575bda256
Child:
1:4c82bff12ad0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Apr 21 15:36:26 2017 +0000
@@ -0,0 +1,61 @@
+#include "mbed.h"
+
+#include "board.h"
+#include "radio.h"
+
+Serial pc(USBTX, USBRX); // tx, rx
+
+InterruptIn DatarateButton(USER_BUTTON);
+
+static uint8_t LoRaMacBuffer[255];
+
+uint32_t TxFreq;
+uint8_t CurrentDatarate = 12;
+bool ButtonPressed = false;
+
+/* -------------- */
+
+void UserButtonPressed( void )
+{
+    if( CurrentDatarate == 7 )
+    {
+        CurrentDatarate = 12;
+    }
+    else
+    {
+        CurrentDatarate -= 1;
+    }
+    
+    ButtonPressed = true;
+}
+
+/* -------------- */
+
+int main() {
+    pc.printf("HelLoRa !\n");
+    
+    // Get USER button pressed
+    DatarateButton.fall( &UserButtonPressed );
+    
+    // Radio board init
+    BoardInit( );
+    
+    while( 1 )
+    {
+        if( ButtonPressed == true )
+        {
+            // Send one packet
+            TxFreq = 868100000;
+            Radio.SetChannel( TxFreq );
+            Radio.SetTxConfig( MODEM_LORA, 14, 0, 0, CurrentDatarate, 1, 8, false, true, 0, 0, false, 3e3 ); 
+            Radio.Send( LoRaMacBuffer, 10 );
+            pc.printf( "LoRa packet: Freq=%u, SF%u\n", TxFreq, CurrentDatarate );
+
+            // Stop sending
+            ButtonPressed = false;
+        }
+    }
+    
+    return 0;
+}
+ 
\ No newline at end of file