test
Dependencies: SX1276Lib1 WakeUp mbed-src
Fork of SX1276PingPong by
Diff: main.cpp
- Revision:
- 16:cb5523c208e6
- Parent:
- 15:ddd519fefbe8
diff -r ddd519fefbe8 -r cb5523c208e6 main.cpp --- a/main.cpp Thu Jul 07 06:49:15 2016 +0000 +++ b/main.cpp Tue Dec 13 06:43:55 2016 +0000 @@ -1,6 +1,7 @@ #include "mbed.h" #include "main.h" #include "sx1276-hal.h" +#include "WakeUp.h" //#include "debug.h" /* Set this flag to '1' to display debug messages on the console */ @@ -10,12 +11,12 @@ #define USE_MODEM_LORA 1 #define USE_MODEM_FSK !USE_MODEM_LORA -#define RF_FREQUENCY 471899946 // Hz -#define TX_OUTPUT_POWER 20 // 14 dBm +#define RF_FREQUENCY 471900000 // Hz +#define TX_OUTPUT_POWER 20 // 14 dBm #if USE_MODEM_LORA == 1 -#define LORA_BANDWIDTH 0 // [0: 125 kHz, +#define LORA_BANDWIDTH 1 // [0: 125 kHz, // 1: 250 kHz, // 2: 500 kHz, // 3: Reserved] @@ -71,6 +72,7 @@ CAD, CAD_DONE + } AppStates_t; volatile AppStates_t State = LOWPOWER; @@ -90,17 +92,23 @@ uint16_t BufferSize = BUFFER_SIZE; uint8_t Buffer[BUFFER_SIZE]; - int16_t RssiValue = 0.0; int8_t SnrValue = 0.0; Serial pc(PB_6, PB_7); +void srprintf(uint8_t *load,uint8_t size) +{ + pc.printf(":"); + for(int i=0; i<size; i++) { + pc.printf("%x ",load[i]); + } + // pc.printf("size:%drssi:%dsnr:%d\r\n",size,rssi,snr); +} int main() { uint8_t i; bool isMaster = true; pc.printf("Hello World !\n"); //debug( "\n\n\r SX1276 Ping Pong Demo Application \n\n\r" ); - // Initialize Radio driver RadioEvents.TxDone = OnTxDone; RadioEvents.RxDone = OnRxDone; @@ -163,10 +171,11 @@ // debug_if( DEBUG_MESSAGE, "Starting Ping-Pong loop\r\n" ); led = 0; - + // WakeUp::calibrate(); Radio.Rx( RX_TIMEOUT_VALUE ); - - while( 1 ) { + while( 0 ) { + // WakeUp::set_ms(6000); + // deepsleep(); switch( State ) { case RX: // debugs((char* )Buffer,sizeof(Buffer)); @@ -287,6 +296,7 @@ break; } } + // while(1); } void OnTxDone( void ) @@ -309,6 +319,8 @@ // debug_if( DEBUG_MESSAGE, "> OnRxDone\n\r" ); pc.printf("> OnRxDone\r\n"); pc.printf("size:%d rssi:%d snr:%d",size,rssi,snr); + srprintf(payload,sizeof(payload)); + Radio.Rx( RX_TIMEOUT_VALUE ); } void OnTxTimeout( void ) @@ -317,6 +329,7 @@ State = TX_TIMEOUT; // debug_if( DEBUG_MESSAGE, "> OnTxTimeout\n\r" ); pc.printf("> OnTxTimeout\r\n"); + Radio.Rx( RX_TIMEOUT_VALUE ); } void OnRxTimeout( void ) @@ -326,6 +339,7 @@ State = RX_TIMEOUT; // debug_if( DEBUG_MESSAGE, "> OnRxTimeout\n\r" ); pc.printf("> OnRxTimeout\r\n"); + Radio.Rx( RX_TIMEOUT_VALUE ); } void OnRxError( void ) @@ -334,5 +348,6 @@ State = RX_ERROR; // debug_if( DEBUG_MESSAGE, "> OnRxError\n\r" ); pc.printf("> OnRxError\r\n"); + Radio.Rx( RX_TIMEOUT_VALUE ); }