Mick Mick
/
SX1272_TestApp
Simple SX1272 Test Application
main.cpp
- Committer:
- mick_ccc
- Date:
- 2017-04-21
- Revision:
- 0:7e7575bda256
- Child:
- 1:4c82bff12ad0
File content as of revision 0:7e7575bda256:
#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; }