Version FC
Dependencies: DmTftLibrary eeprom SX1280Lib filesystem mbed
Fork of MSNV2-Terminal_V1-5 by
Diff: main.cpp
- Revision:
- 2:57f098de07c7
- Parent:
- 1:22e02d1cfbca
- Child:
- 3:3adb454ba1d2
--- a/main.cpp Wed Mar 15 13:16:44 2017 +0000 +++ b/main.cpp Wed Aug 02 21:59:03 2017 +0000 @@ -1,52 +1,14 @@ -/* - ______ _ - / _____) _ | | -( (____ _____ ____ _| |_ _____ ____| |__ - \____ \| ___ | (_ _) ___ |/ ___) _ \ - _____) ) ____| | | || |_| ____( (___| | | | -(______/|_____)_|_|_| \__)_____)\____)_| |_| - (C)2017 Semtech - -Description: Main program - -Maintainer: Gregory Cristian & Gilbert Menth -*/ - #include "mbed.h" #include "radio.h" #include "sx1280-hal.h" -/*! - * \brief Used to display firmware version on RS232 - */ -#define FIRMWARE_VERSION ( ( char* )"Firmware Version: 170314A" ) - -/*! - * Use the Ping Ping in uncommented Mode - */ -//#define MODE_BLE -#define MODE_LORA -//#define MODE_GENERIC -//#define MODE_FLRC - +#define FIRMWARE_VERSION ( ( char* )"Firmware Version: 01" ) // display firmware version on RS232 +#define MODE_LORA // Lora modulation +#define RF_FREQUENCY 2400000000UL // HzNominal frequency +#define TX_OUTPUT_POWER 13 // Output power in dBm [-18..+13] dBm -/*! - * \brief Defines the nominal frequency - */ -#define RF_FREQUENCY 2400000000UL // Hz - -/*! - * \brief Defines the output power in dBm - * - * \remark The range of the output power is [-18..+13] dBm - */ -#define TX_OUTPUT_POWER 13 - -/*! - * \brief Defines the states of the application - */ -typedef enum +typedef enum // States of the application { APP_LOWPOWER, APP_RX, @@ -56,15 +18,15 @@ APP_TX_TIMEOUT, }AppStates_t; -/*! - * \brief Defines the buffer size, i.e. the payload size - */ -#define BUFFER_SIZE 16 +#define BUFFER_SIZE 16 // Payload size +//#define BUFFER_SIZE 34 /*! - * \brief Define the possible message type for this application + * Message type for this application */ -const uint8_t PingMsg[] = "PING"; +//const uint8_t PingMsg[] = "DATA IOT TERMINAL"; +//const uint8_t PongMsg[] = "RESPONSE GATEWAY "; +const uint8_t PingMsg[] = "PING DATA IOT TERMINAL"; const uint8_t PongMsg[] = "PONG"; /*! @@ -72,53 +34,21 @@ */ #define PINGPONGSIZE 4 -/*! - * \brief The size of the buffer - */ -uint8_t BufferSize = BUFFER_SIZE; +uint8_t BufferSize = BUFFER_SIZE; // Size of the buffer +uint8_t Buffer[BUFFER_SIZE]; // Buffer -/*! - * \brief The buffer - */ -uint8_t Buffer[BUFFER_SIZE]; - -/*! - * \brief The State of the application - */ -AppStates_t AppState = APP_LOWPOWER; +AppStates_t AppState = APP_LOWPOWER; // State of the application int8_t RssiValue = 0; int8_t SnrValue = 0; -/*! - * \brief Function to be executed on Radio Tx Done event - */ -void OnTxDone( void ); - -/*! - * \brief Function to be executed on Radio Rx Done event - */ -void OnRxDone( void ); - -/*! - * \brief Function executed on Radio Tx Timeout event - */ -void OnTxTimeout( void ); +void OnTxDone ( void ); // Function to be executed on Radio Tx Done event +void OnRxDone ( void ); // Function to be executed on Radio Rx Done event +void OnTxTimeout ( void ); // Function executed on Radio Tx Timeout event +void OnRxTimeout ( void ); // Function executed on Radio Rx Timeout event +void OnRxError ( IrqErrorCode_t ); // Function executed on Radio Rx Error event -/*! - * \brief Function executed on Radio Rx Timeout event - */ -void OnRxTimeout( void ); - -/*! - * \brief Function executed on Radio Rx Error event - */ -void OnRxError( IrqErrorCode_t ); - -/*! - * \brief All the callbacks are stored in a structure - */ -RadioCallbacks_t callbacks = +RadioCallbacks_t callbacks = // All the callbacks are stored in a structure { &OnTxDone, // txDone &OnRxDone, // rxDone @@ -131,280 +61,199 @@ NULL, // cadDone }; -// mosi, miso, sclk, nss, busy, dio1, dio2, dio3, rst, callbacks... -SX1280Hal Radio( D11, D12, D13, D7, D3, D5, NC, NC, A0, &callbacks ); - -DigitalOut ANT_SW( A3 ); -DigitalOut TxLed( A4 ); -DigitalOut RxLed( A5 ); - -/*! - * \brief Define IO for Unused Pin - */ -DigitalOut F_CS( D6 ); // MBED description of pin -DigitalOut SD_CS( D8 ); // MBED description of pin +// mosi, miso, sclk, nss, busy, dio1, dio2, dio3, rst, callbacks... +SX1280Hal Radio ( D11 , D12 , D13 , D7 , D3 , D5 , NC , NC , A0 , &callbacks ); -/*! - * \brief Number of tick size steps for tx timeout - */ -#define TX_TIMEOUT_VALUE 100 // ms - -/*! - * \brief Number of tick size steps for rx timeout - */ -#define RX_TIMEOUT_VALUE 100 // ms - -/*! - * \brief Size of ticks (used for Tx and Rx timeout) - */ -#define RX_TIMEOUT_TICK_SIZE RADIO_TICK_SIZE_1000_US - -/*! - * \brief Mask of IRQs to listen to in rx mode - */ -uint16_t RxIrqMask = IRQ_RX_DONE | IRQ_RX_TX_TIMEOUT; +DigitalOut ANT_SW ( A3 ); +DigitalOut TxLed ( A4 ); +DigitalOut RxLed ( A5 ); /*! - * \brief Mask of IRQs to listen to in tx mode - */ -uint16_t TxIrqMask = IRQ_TX_DONE | IRQ_RX_TX_TIMEOUT; - -/*! - * \brief Locals parameters and status for radio API - * NEED TO BE OPTIMIZED, COPY OF STUCTURE ALREADY EXISTING - */ -PacketParams_t PacketParams; -PacketStatus_t PacketStatus; - -/*! - * \brief Specify serial datarate for UART debug output + * Define IO for Unused Pin */ -void baud( int baudrate ) -{ - Serial s( USBTX, USBRX ); +DigitalOut F_CS ( D6 ); // MBED description of pin +DigitalOut SD_CS ( D8 ); // MBED description of pin - s.baud( baudrate ); -} +#define TX_TIMEOUT_VALUE 100 // ms Number of tick size steps for tx timeout +#define RX_TIMEOUT_VALUE 100 // ms Number of tick size steps for rx timeout +#define RX_TIMEOUT_TICK_SIZE RADIO_TICK_SIZE_1000_US // Size of ticks (used for Tx and Rx timeout) + +uint16_t RxIrqMask = IRQ_RX_DONE | IRQ_RX_TX_TIMEOUT; // Mask of IRQs to listen to in rx mode +uint16_t TxIrqMask = IRQ_TX_DONE | IRQ_RX_TX_TIMEOUT; // Mask of IRQs to listen to in tx mode + +PacketParams_t PacketParams; // Locals parameters and status for radio API +PacketStatus_t PacketStatus; // NEED TO BE OPTIMIZED, COPY OF STUCTURE ALREADY EXISTING -int main( ) -{ - bool isMaster = true; - ModulationParams_t modulationParams; +bool isMaster = true; +ModulationParams_t modulationParams; + + +/* Specify serial datarate for UART debug output */ +void baud ( int baudrate ) { Serial s( USBTX, USBRX ); s.baud( baudrate );} - baud( 115200 ); +void setup () { + baud (115200); + + printf( "\n\n\r SX1280 Terminal IoT LORA MODULATION 2.4GHz (%s)\n\n\r", FIRMWARE_VERSION ); - F_CS = 1; - SD_CS = 1; - RxLed = 1; - TxLed = 1; - ANT_SW = 1; + F_CS = 1 ; + SD_CS = 1 ; + RxLed = 1 ; + TxLed = 1 ; + ANT_SW = 1 ; wait_ms( 500 ); // wait for on board DC/DC start-up time - Radio.Init( ); - Radio.SetRegulatorMode( USE_DCDC ); // Can also be set in LDO mode but consume more power - - memset( &Buffer, 0x00, BufferSize ); - - printf( "\n\n\r SX1280 Ping Pong Demo Application (%s)\n\n\r", FIRMWARE_VERSION ); - -#if defined( MODE_BLE ) + Radio.Init ( ); + + Radio.SetRegulatorMode ( USE_DCDC ); // Can also be set in LDO mode but consume more power - printf( "\nPing Pong running in BLE mode\n\r"); - modulationParams.PacketType = PACKET_TYPE_BLE; - modulationParams.Params.Ble.BitrateBandwidth = GEN_BLE_BR_0_125_BW_0_3; - modulationParams.Params.Ble.ModulationIndex = GEN_BLE_MOD_IND_1_00; - modulationParams.Params.Ble.ModulationShaping = RADIO_MOD_SHAPING_BT_1_0; - - packetParams.PacketType = PACKET_TYPE_BLE; - packetParams.Params.Ble.BlePacketType = BLE_EYELONG_1_0; - packetParams.Params.Ble.ConnectionState = BLE_MASTER_SLAVE; - packetParams.Params.Ble.CrcField = BLE_CRC_3B; - packetParams.Params.Ble.Whitening = RADIO_WHITENING_OFF; - -#elif defined( MODE_GENERIC ) + memset ( &Buffer, 0x00, BufferSize ); - printf( "\nPing Pong running in GENERIC mode\n\r"); - modulationParams.PacketType = PACKET_TYPE_GENERIC; - modulationParams.Params.Generic.BitrateBandwidth = GEN_BLE_BR_0_125_BW_0_3; - modulationParams.Params.Generic.ModulationIndex = GEN_BLE_MOD_IND_1_00; - modulationParams.Params.Generic.ModulationShaping = RADIO_MOD_SHAPING_BT_1_0; + + RxLed = 0; + TxLed = 0; + + modulationParams.PacketType = PACKET_TYPE_LORA ; + modulationParams.Params.LoRa.SpreadingFactor = LORA_SF7 ; + modulationParams.Params.LoRa.Bandwidth = LORA_BW_0400 ; + modulationParams.Params.LoRa.CodingRate = LORA_CR_4_5 ; - packetParams.PacketType = PACKET_TYPE_GENERIC; - packetParams.Params.Generic.PreambleLength = PREAMBLE_LENGTH_32_BITS; - packetParams.Params.Generic.SyncWordLength = GEN_SYNCWORD_LENGTH_5_BYTE; - packetParams.Params.Generic.SyncWordMatch = RADIO_RX_MATCH_SYNCWORD_1; - packetParams.Params.Generic.HeaderType = RADIO_PACKET_VARIABLE_LENGTH; - packetParams.Params.Generic.PayloadLength = 15; - packetParams.Params.Generic.CrcLength = RADIO_CRC_3_BYTES; - packetParams.Params.Generic.Whitening = RADIO_WHITENING_ON; - -#elif defined( MODE_LORA ) - - printf( "\nPing Pong running in LORA mode\n\r"); - modulationParams.PacketType = PACKET_TYPE_LORA; - modulationParams.Params.LoRa.SpreadingFactor = LORA_SF7; - modulationParams.Params.LoRa.Bandwidth = LORA_BW_0400; - modulationParams.Params.LoRa.CodingRate = LORA_CR_4_5; - - PacketParams.PacketType = PACKET_TYPE_LORA; - PacketParams.Params.LoRa.PreambleLength = 0x08; - PacketParams.Params.LoRa.HeaderType = LORA_PACKET_VARIABLE_LENGTH; - PacketParams.Params.LoRa.PayloadLength = 15; + PacketParams.PacketType = PACKET_TYPE_LORA ; + PacketParams.Params.LoRa.PreambleLength = 0x08 ; + PacketParams.Params.LoRa.HeaderType = LORA_PACKET_VARIABLE_LENGTH; + PacketParams.Params.LoRa.PayloadLength = 15 ; PacketParams.Params.LoRa.CrcMode = LORA_CRC_ON; PacketParams.Params.LoRa.InvertIQ = LORA_IQ_INVERTED; -#elif defined( MODE_FLRC ) - printf( "\nPing Pong running in FLRC mode\n\r"); - modulationParams.PacketType = PACKET_TYPE_FLRC; - modulationParams.Params.Flrc.BitrateBandwidth = FLRC_BR_0_260_BW_0_3; - modulationParams.Params.Flrc.CodingRate = FLRC_CR_1_2; - modulationParams.Params.Flrc.ModulationShaping = RADIO_MOD_SHAPING_BT_1_0; - - packetParams.PacketType = PACKET_TYPE_FLRC; - packetParams.Params.Flrc.PreambleLength = PREAMBLE_LENGTH_32_BITS; - packetParams.Params.Flrc.SyncWordLength = FLRC_SYNCWORD_LENGTH_4_BYTE; - packetParams.Params.Flrc.SyncWordMatch = RADIO_RX_MATCH_SYNCWORD_1; - packetParams.Params.Flrc.HeaderType = RADIO_PACKET_VARIABLE_LENGTH; - packetParams.Params.Flrc.PayloadLength = 15; - packetParams.Params.Flrc.CrcLength = RADIO_CRC_3_BYTES; - packetParams.Params.Flrc.Whitening = RADIO_WHITENING_OFF; - -#else -#error "Please select the mode of operation for the Ping Ping demo" -#endif + Radio.SetStandby ( STDBY_RC ); + Radio.SetPacketType ( modulationParams.PacketType ); + Radio.SetModulationParams ( &modulationParams ); + Radio.SetPacketParams ( &PacketParams ); - Radio.SetStandby( STDBY_RC ); - Radio.SetPacketType( modulationParams.PacketType ); - Radio.SetModulationParams( &modulationParams ); - Radio.SetPacketParams( &PacketParams ); - - Radio.SetRfFrequency( RF_FREQUENCY ); - Radio.SetBufferBaseAddresses( 0x00, 0x00 ); - Radio.SetTxParams( TX_OUTPUT_POWER, RADIO_RAMP_20_US ); + Radio.SetRfFrequency ( RF_FREQUENCY ); + Radio.SetBufferBaseAddresses ( 0x00, 0x00 ); + Radio.SetTxParams ( TX_OUTPUT_POWER, RADIO_RAMP_20_US ); - // only used in GENERIC and BLE mode - Radio.SetSyncWord( 1, ( uint8_t[] ){ 0xDD, 0xA0, 0x96, 0x69, 0xDD } ); - - RxLed = 0; - TxLed = 0; + Radio.SetDioIrqParams ( RxIrqMask, RxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); + Radio.SetRx ( ( TickTime_t ) { RX_TIMEOUT_TICK_SIZE, RX_TIMEOUT_VALUE } ); - Radio.SetDioIrqParams( RxIrqMask, RxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); - Radio.SetRx( ( TickTime_t ) { RX_TIMEOUT_TICK_SIZE, RX_TIMEOUT_VALUE } ); - AppState = APP_LOWPOWER; + AppState = APP_LOWPOWER; + + } - while( 1 ) - { +void loop () { switch( AppState ) { case APP_RX: - AppState = APP_LOWPOWER; - RxLed = !RxLed; - Radio.GetPayload( Buffer, &BufferSize, BUFFER_SIZE ); + printf( "*** TERM *** APP_RX \r\n" ); + AppState = APP_LOWPOWER; + RxLed = !RxLed; + Radio.GetPayload ( Buffer, &BufferSize, BUFFER_SIZE ); + + printf ( "Message Received : %s \r\n", Buffer ); + if( isMaster == true ) { if( BufferSize > 0 ) { if( strncmp( ( const char* )Buffer, ( const char* )PongMsg, PINGPONGSIZE ) == 0 ) { - printf( "...Pong\r\n" ); + printf ( "<Master> Recv ...Pong\r\n" ); + wait_ms (2000) ; memcpy( Buffer, PingMsg, PINGPONGSIZE ); - Radio.SetDioIrqParams( TxIrqMask, TxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); - Radio.SendPayload( Buffer, BufferSize, ( TickTime_t ){ RX_TIMEOUT_TICK_SIZE, TX_TIMEOUT_VALUE } ); + Radio.SetDioIrqParams ( TxIrqMask, TxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); + Radio.SendPayload ( Buffer, BufferSize,( TickTime_t ){ RX_TIMEOUT_TICK_SIZE, TX_TIMEOUT_VALUE } ); } - else if( strncmp( ( const char* )Buffer, ( const char* )PingMsg, PINGPONGSIZE ) == 0 ) - { - // A master already exists then become a slave - printf( "...Ping\r\n" ); - isMaster = false; - memcpy( Buffer, PongMsg, PINGPONGSIZE ); - Radio.SetDioIrqParams( TxIrqMask, TxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); - Radio.SendPayload( Buffer, BufferSize, ( TickTime_t ){ RX_TIMEOUT_TICK_SIZE, TX_TIMEOUT_VALUE } ); - } + else // valid reception but neither a PING or a PONG message { // Set device as master ans start again + printf( "<Master> Unknown message \r\n" ); + isMaster = true; - Radio.SetDioIrqParams( RxIrqMask, RxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); - Radio.SetRx( ( TickTime_t ) { RX_TIMEOUT_TICK_SIZE, RX_TIMEOUT_VALUE } ); + Radio.SetDioIrqParams ( RxIrqMask, RxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); + Radio.SetRx ( ( TickTime_t ) { RX_TIMEOUT_TICK_SIZE, RX_TIMEOUT_VALUE } ); } } } + + // Receiver else { if( BufferSize > 0 ) { if( strncmp( ( const char* )Buffer, ( const char* )PingMsg, PINGPONGSIZE ) == 0 ) { - printf( "...Ping\r\n" ); - memcpy( Buffer, PongMsg, 4 ); - Radio.SetDioIrqParams( TxIrqMask, TxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); - Radio.SendPayload( Buffer, BufferSize, ( TickTime_t ){ RX_TIMEOUT_TICK_SIZE, TX_TIMEOUT_VALUE } ); + printf ( "...Ping\r\n" ); + memcpy ( Buffer, PongMsg, 4 ); + Radio.SetDioIrqParams ( TxIrqMask, TxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); + Radio.SendPayload ( Buffer, BufferSize, ( TickTime_t ){ RX_TIMEOUT_TICK_SIZE, TX_TIMEOUT_VALUE } ); } else // valid reception but not a PING as expected { + printf( "<Slave> Unknown message \r\n" ); isMaster = true; - Radio.SetDioIrqParams( RxIrqMask, RxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); - Radio.SetRx( ( TickTime_t ) { RX_TIMEOUT_TICK_SIZE, RX_TIMEOUT_VALUE } ); + Radio.SetDioIrqParams ( RxIrqMask, RxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); + Radio.SetRx ( ( TickTime_t ) { RX_TIMEOUT_TICK_SIZE, RX_TIMEOUT_VALUE } ); } } } break; case APP_TX: + printf( "*** TERM *** APP_TX \r\n" ); AppState = APP_LOWPOWER; TxLed = !TxLed; - if( isMaster == true ) - { - printf( "Ping...\r\n" ); - } - else - { - printf( "Pong...\r\n" ); - } - Radio.SetDioIrqParams( RxIrqMask, RxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); - Radio.SetRx( ( TickTime_t ) { RX_TIMEOUT_TICK_SIZE, RX_TIMEOUT_VALUE } ); + if( isMaster == true ) printf( "<Master> Send Ping...\r\n" ); + else printf( "<Slave> Send Pong...\r\n" ); + + Radio.SetDioIrqParams ( RxIrqMask, RxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); + Radio.SetRx ( ( TickTime_t ) { RX_TIMEOUT_TICK_SIZE, RX_TIMEOUT_VALUE } ); break; case APP_RX_TIMEOUT: + printf( "*** TERM *** APP_RX_TIMEOUT \r\n" ); AppState = APP_LOWPOWER; if( isMaster == true ) { // Send the next PING frame - memcpy( Buffer, PingMsg, PINGPONGSIZE ); - Radio.SetDioIrqParams( TxIrqMask, TxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); - Radio.SendPayload( Buffer, BufferSize, ( TickTime_t ){ RX_TIMEOUT_TICK_SIZE, TX_TIMEOUT_VALUE } ); + memcpy ( Buffer, PingMsg, PINGPONGSIZE ); + Radio.SetDioIrqParams ( TxIrqMask, TxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); + Radio.SendPayload ( Buffer, BufferSize, ( TickTime_t ){ RX_TIMEOUT_TICK_SIZE, TX_TIMEOUT_VALUE } ); } else { - Radio.SetDioIrqParams( RxIrqMask, RxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); - Radio.SetRx( ( TickTime_t ) { RX_TIMEOUT_TICK_SIZE, RX_TIMEOUT_VALUE } ); + Radio.SetDioIrqParams ( RxIrqMask, RxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); + Radio.SetRx ( ( TickTime_t ) { RX_TIMEOUT_TICK_SIZE, RX_TIMEOUT_VALUE } ); } break; case APP_RX_ERROR: + printf( "*** TERM *** APP_RX_ERROR \r\n" ); AppState = APP_LOWPOWER; // We have received a Packet with a CRC error, send reply as if packet was correct if( isMaster == true ) { // Send the next PING frame - memcpy( Buffer, PingMsg, PINGPONGSIZE ); - Radio.SetDioIrqParams( TxIrqMask, TxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); - Radio.SendPayload( Buffer, BufferSize, ( TickTime_t ){ RX_TIMEOUT_TICK_SIZE, TX_TIMEOUT_VALUE } ); + memcpy ( Buffer, PingMsg, PINGPONGSIZE ); + Radio.SetDioIrqParams ( TxIrqMask, TxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); + Radio.SendPayload ( Buffer, BufferSize, ( TickTime_t ){ RX_TIMEOUT_TICK_SIZE, TX_TIMEOUT_VALUE } ); } else { // Send the next PONG frame - memcpy( Buffer, PongMsg, PINGPONGSIZE ); - Radio.SetDioIrqParams( TxIrqMask, TxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); - Radio.SendPayload( Buffer, BufferSize, ( TickTime_t ){ RX_TIMEOUT_TICK_SIZE, TX_TIMEOUT_VALUE } ); + memcpy ( Buffer, PongMsg, PINGPONGSIZE ); + Radio.SetDioIrqParams ( TxIrqMask, TxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); + Radio.SendPayload ( Buffer, BufferSize, ( TickTime_t ){ RX_TIMEOUT_TICK_SIZE, TX_TIMEOUT_VALUE } ); } break; case APP_TX_TIMEOUT: - AppState = APP_LOWPOWER; - Radio.SetDioIrqParams( RxIrqMask, RxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); - Radio.SetRx( ( TickTime_t ) { RX_TIMEOUT_TICK_SIZE, RX_TIMEOUT_VALUE } ); + printf( "*** TERM *** APP_TX_TIMEOUT \r\n" ); + AppState = APP_LOWPOWER; + Radio.SetDioIrqParams ( RxIrqMask, RxIrqMask, IRQ_RADIO_NONE, IRQ_RADIO_NONE ); + Radio.SetRx ( ( TickTime_t ) { RX_TIMEOUT_TICK_SIZE, RX_TIMEOUT_VALUE } ); break; case APP_LOWPOWER: @@ -414,49 +263,24 @@ // Set low power break; } - } } + + + -void OnTxDone( void ) -{ - AppState = APP_TX; -} +int main( ) { setup () ; while (1) loop () ; } -void OnRxDone( void ) -{ - AppState = APP_RX;/* +void OnTxDone ( void ) { printf( "*** TERM *** OnTxDone \r\n" ); AppState = APP_TX ; } +void OnRxDone ( void ) { printf( "*** TERM *** OnRxDone \r\n" ); AppState = APP_RX ; } +void OnTxTimeout ( void ) { printf( "*** TERM *** OnTxTimeout \r\n" ); AppState = APP_TX_TIMEOUT ; } +void OnRxTimeout ( void ) { printf( "*** TERM *** OnRxTimeout \r\n" ); AppState = APP_RX_TIMEOUT ; } +void OnRxError ( IrqErrorCode_t errorCode ) { printf( "*** TERM *** OnRxError \r\n" ); AppState = APP_RX_ERROR ; } +void OnRangingDone ( IrqRangingCode_t val ) { printf( "*** TERM *** OnRangingDone \r\n" ); } +void OnCadDone ( bool channelActivityDetected ) { printf( "*** TERM *** OnCadDone \r\n" ); } + + /* Radio.GetPacketStatus(&packetStatus); -#if ( defined( MODE_BLE ) || defined( MODE_GENERIC ) ) - RssiValue = packetStatus.Ble.RssiSync; - printf("rssi: %d\n\r", RssiValue); -#elif defined( MODE_LORA ) RssiValue = packetStatus.Lr24.RssiPkt; SnrValue = packetStatus.Lr24.SnrPkt; printf("rssi: %d; snr: %d\n\r", RssiValue, SnrValue ); -#endif*/ -} - -void OnTxTimeout( void ) -{ - AppState = APP_TX_TIMEOUT; - printf( "<>>>>>>>>TXE\r\n" ); -} - -void OnRxTimeout( void ) -{ - AppState = APP_RX_TIMEOUT; -} - -void OnRxError( IrqErrorCode_t errorCode ) -{ - AppState = APP_RX_ERROR; - printf( "RXE<>>>>>>>>\r\n" ); -} - -void OnRangingDone( IrqRangingCode_t val ) -{ -} - -void OnCadDone( bool channelActivityDetected ) -{ -} + */