Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SX1276GenericLib USBDevice
Fork of NonPingPong_PICO_LoRa by
Revision 7:62c868478eef, committed 2020-10-20
- Comitter:
- walterluu
- Date:
- Tue Oct 20 00:00:20 2020 +0000
- Parent:
- 6:51f492ca61a2
- Commit message:
- MAX20361 System Demo firmware with Low Power 2 mode
Changed in this revision
diff -r 51f492ca61a2 -r 62c868478eef SX1276GenericPingPong/GenericPingPong2.cpp
--- a/SX1276GenericPingPong/GenericPingPong2.cpp Wed Oct 14 00:19:02 2020 +0000
+++ b/SX1276GenericPingPong/GenericPingPong2.cpp Tue Oct 20 00:00:20 2020 +0000
@@ -19,13 +19,13 @@
#ifdef FEATURE_LORA // in main.cpp
/* Set this flag to '1' to display debug messages on the console */
-#define DEBUG_MESSAGE 0
+#define DEBUG_MESSAGE 1
/* Set this flag to '1' to use the LoRa modulation or to '0' to use FSK modulation */
#define USE_MODEM_LORA 1
#define USE_MODEM_FSK !USE_MODEM_LORA
#define RF_FREQUENCY RF_FREQUENCY_915_0 // Hz
-#define TX_OUTPUT_POWER 14 // 14 dBm
+#define TX_OUTPUT_POWER 1 // 14 dBm
#if USE_MODEM_LORA == 1
@@ -33,8 +33,11 @@
#define LORA_SPREADING_FACTOR LORA_SF7
#define LORA_CODINGRATE LORA_ERROR_CODING_RATE_4_5
-#define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx
+#define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx, default
+//#define LORA_PREAMBLE_LENGTH 5
#define LORA_SYMBOL_TIMEOUT 5 // Symbols
+//#define LORA_SYMBOL_TIMEOUT 4 // Symbols
+
#define LORA_FIX_LENGTH_PAYLOAD_ON false
#define LORA_FHSS_ENABLED false
#define LORA_NB_SYMB_HOP 4
@@ -55,10 +58,9 @@
#error "Please define a modem in the compiler options."
#endif
+//#define RX_TIMEOUT_VALUE 3500 // in ms, default
+#define RX_TIMEOUT_VALUE 333 // in ms
-//#define RX_TIMEOUT_VALUE 3500 // in ms, default
-#define RX_TIMEOUT_VALUE 333 // testing
-//#define RX_TIMEOUT_VALUE 333 // in ms
//#define BUFFER_SIZE 32 // Define the payload size here
//#define BUFFER_SIZE 64 // Define the payload size here
@@ -246,143 +248,199 @@
if (DEBUG_MESSAGE)
ad->printf("Starting Ping-Pong loop\r\n");
-
- Radio->Rx( RX_TIMEOUT_VALUE );
+#if MASTER == 1
+ Radio->Rx( RX_TIMEOUT_VALUE ); // initate Rx State for Master
+#endif
+
return 0; //added by Walter due to "Control reaches end of non-void function"
}
+
+bool SX1276MasterCheckForNewData(void)
+{
+ bool new_data_available = false;
+ switch( State )
+ {
+ case RX:
+ if( BufferSizeRx > 0 )
+ {
+ new_data_available = true;
+ wait_ms( 10 ); //do we need this?
+ if (DEBUG_MESSAGE)
+ ad->printf( "State=RX\r\n" );
+ }
+ Radio->Rx( RX_TIMEOUT_VALUE );
+ State = LOWPOWER;
+ break;
+ case RX_TIMEOUT:
+ wait_ms( 10 );
+ if (DEBUG_MESSAGE)
+ ad->printf( "State=RX_TIMEOUT\r\n" );
+ Radio->Rx( RX_TIMEOUT_VALUE );
+ State = LOWPOWER;
+ break;
+ case RX_ERROR:
+ // We have received a Packet with a CRC error, send reply as if packet was correct
+ wait_ms( 10 );
+ if (DEBUG_MESSAGE)
+ ad->printf( "State=RX_ERROR\r\n" );
+ Radio->Rx( RX_TIMEOUT_VALUE );
+ State = LOWPOWER;
+ break;
+ case TX_TIMEOUT:
+ if (DEBUG_MESSAGE)
+ ad->printf( "State=TX_TIMEOUT\r\n" );
+ State = LOWPOWER;
+ break;
+ case LOWPOWER:
+ sleep();
+ break;
+ default:
+ sleep(); // TODO, should this be removed?
+ break;
+ }
+ return new_data_available;
+}
+
+void SX1276SlaveSendData(void)
+{
+ //wait_ms( 10 );
+ Radio->Send( BufferTx, BufferSizeTx );
+ sleep();
+}
+
/****************************************************************************************************************************************
*
****************************************************************************************************************************************/
-int SX1276PingPong(void)
-{
-#if MASTER == 1 // Master Device: Bluetooth Gateway
- bool isMaster = true;
-#elif SLAVE == 1 // Slave Device: Robot
- bool isMaster = false;
-#endif
-
- switch( State )
- {
- case RX:
-// *led3 = 0; // uncommented
- if( isMaster == true ) // Master Device received payload from Slave
- {
- if( BufferSizeRx > 0 )
- {
- /* This checks if the ID of the received transaction is matching that of
- * the slave device's ID. This is defined in the GenericPingPong.h
- */
- if( memcmp(&BufferRx[rx_idx_signature], PongMsg, sizeof(PongMsg)) == 0 )
- {
-// *led = !*led;
-// *led = 0; // changed to 0
- if (DEBUG_MESSAGE)
- ad->printf( "...Pong\r\n" );
- wait_ms( 10 );
- Radio->Send( BufferTx, BufferSizeTx );
- } // memcmp != 0
- else // valid reception but not a PONG message
- { // Set device as master and start again
- isMaster = true; // new update
- Radio->Rx( RX_TIMEOUT_VALUE );
- } // end of if memcmp
- } // end of if BufferSizeRx > 0
- } // end of isMaster == true
- else // Slave Device received payload from Master
- {
- if( BufferSizeRx > 0 )
- {
- if( memcmp(BufferRx, PingMsg, sizeof(PingMsg)) == 0 )
- {
-// *led = !*led;
-// *led = 0 //changed to 0
- if (DEBUG_MESSAGE)
- ad->printf( "...Ping\r\n" );
- wait_ms( 10 );
- Radio->Send( BufferTx, BufferSizeTx );
- }
- else // valid reception but not a PING as expected
- { // Set device as slave and start again
- isMaster = false; // new update
- Radio->Rx( RX_TIMEOUT_VALUE );
- }
- } // end of if BufferSizeRx > 0
- } // end of if (isMaster == True), end of checking devices
-
- State = LOWPOWER; // back to LOWPOWER State
-
- break;
- case TX:
-// *led3 = 0; // change to 0
- if( isMaster == true ) // Master Device
- {
- if (DEBUG_MESSAGE)
- ad->printf("Ping...\r\n" );
- }
- else // Slave Device
- {
- if (DEBUG_MESSAGE)
- ad->printf("Pong...\r\n" );
- }
- Radio->Rx( RX_TIMEOUT_VALUE );
- State = LOWPOWER; // back to LOWPOWER State
- break;
- case RX_TIMEOUT:
- if( isMaster == true ) // Master Device
- {
- wait_ms( 10 );
- Radio->Send( BufferTx, BufferSizeTx );
- }
- else // Slave Device
- {
- Radio->Rx( RX_TIMEOUT_VALUE );
- }
- State = LOWPOWER; // back to LOWPOWER State
- break;
- case RX_ERROR:
- // We have received a Packet with a CRC error, send reply as if packet was correct
- if( isMaster == true ) // Master Device
- {
- // Send the next PING frame
-// memcpy(BufferTx, PingMsg, sizeof(PingMsg));
-/*
- for( i = 4; i < BufferSizeTx; i++ )
- {
- BufferTx[i] = i - 4;
- }
-*/
-// fillPayloadWithGlobalBufs(BufferTx);
- wait_ms( 10 );
- Radio->Send( BufferTx, BufferSizeTx );
- }
- else // Slave Device
- {
- // Send the next PONG frame
-// memcpy(BufferTx, PongMsg, sizeof(PongMsg));
-/*
- for( i = sizeof(PongMsg); i < BufferSizeTx; i++ )
- {
- BufferTx[i] = i - sizeof(PongMsg);
- }
-*/
- wait_ms( 10 );
- Radio->Send( BufferTx, BufferSizeTx );
- }
- State = LOWPOWER; // Back to Low Power State
- break;
- case TX_TIMEOUT:
- Radio->Rx( RX_TIMEOUT_VALUE );
- State = LOWPOWER;
- break;
- case LOWPOWER:
- sleep();
- break;
- default:
- State = LOWPOWER;
- break;
- }
-}
+//int SX1276PingPong(void)
+//{
+//#if MASTER == 1 // Master Device: Bluetooth Gateway
+// bool isMaster = true;
+//#elif SLAVE == 1 // Slave Device: Robot
+// bool isMaster = false;
+//#endif
+//
+// switch( State )
+// {
+// case RX:
+//// *led3 = 0; // uncommented
+// if( isMaster == true ) // Master Device received payload from Slave
+// {
+// if( BufferSizeRx > 0 )
+// {
+// /* This checks if the ID of the received transaction is matching that of
+// * the slave device's ID. This is defined in the GenericPingPong.h
+// */
+// if( memcmp(&BufferRx[rx_idx_signature], PongMsg, sizeof(PongMsg)) == 0 )
+// {
+//// *led = !*led;
+//// *led = 0; // changed to 0
+// if (DEBUG_MESSAGE)
+// ad->printf( "...Pong\r\n" );
+// wait_ms( 10 );
+// Radio->Send( BufferTx, BufferSizeTx );
+// } // memcmp != 0
+// else // valid reception but not a PONG message
+// { // Set device as master and start again
+// isMaster = true; // new update
+// Radio->Rx( RX_TIMEOUT_VALUE );
+// } // end of if memcmp
+// } // end of if BufferSizeRx > 0
+// } // end of isMaster == true
+// else // Slave Device received payload from Master
+// {
+// if( BufferSizeRx > 0 )
+// {
+// if( memcmp(BufferRx, PingMsg, sizeof(PingMsg)) == 0 )
+// {
+//// *led = !*led;
+//// *led = 0 //changed to 0
+// if (DEBUG_MESSAGE)
+// ad->printf( "...Ping\r\n" );
+// wait_ms( 10 );
+// Radio->Send( BufferTx, BufferSizeTx );
+// }
+// else // valid reception but not a PING as expected
+// { // Set device as slave and start again
+// isMaster = false; // new update
+// Radio->Rx( RX_TIMEOUT_VALUE );
+// }
+// } // end of if BufferSizeRx > 0
+// } // end of if (isMaster == True), end of checking devices
+//
+// State = LOWPOWER; // back to LOWPOWER State
+//
+// break;
+// case TX:
+//// *led3 = 0; // change to 0
+// if( isMaster == true ) // Master Device
+// {
+// if (DEBUG_MESSAGE)
+// ad->printf("Ping...\r\n" );
+// }
+// else // Slave Device
+// {
+// if (DEBUG_MESSAGE)
+// ad->printf("Pong...\r\n" );
+// }
+// Radio->Rx( RX_TIMEOUT_VALUE );
+// State = LOWPOWER; // back to LOWPOWER State
+// break;
+// case RX_TIMEOUT:
+// if( isMaster == true ) // Master Device
+// {
+// wait_ms( 10 );
+// Radio->Send( BufferTx, BufferSizeTx );
+// }
+// else // Slave Device
+// {
+// Radio->Rx( RX_TIMEOUT_VALUE );
+// }
+// State = LOWPOWER; // back to LOWPOWER State
+// break;
+// case RX_ERROR:
+// // We have received a Packet with a CRC error, send reply as if packet was correct
+// if( isMaster == true ) // Master Device
+// {
+// // Send the next PING frame
+//// memcpy(BufferTx, PingMsg, sizeof(PingMsg));
+///*
+// for( i = 4; i < BufferSizeTx; i++ )
+// {
+// BufferTx[i] = i - 4;
+// }
+//*/
+//// fillPayloadWithGlobalBufs(BufferTx);
+// wait_ms( 10 );
+// Radio->Send( BufferTx, BufferSizeTx );
+// }
+// else // Slave Device
+// {
+// // Send the next PONG frame
+//// memcpy(BufferTx, PongMsg, sizeof(PongMsg));
+///*
+// for( i = sizeof(PongMsg); i < BufferSizeTx; i++ )
+// {
+// BufferTx[i] = i - sizeof(PongMsg);
+// }
+//*/
+// wait_ms( 10 );
+// Radio->Send( BufferTx, BufferSizeTx );
+// }
+// State = LOWPOWER; // Back to Low Power State
+// break;
+// case TX_TIMEOUT:
+// Radio->Rx( RX_TIMEOUT_VALUE );
+// State = LOWPOWER;
+// break;
+// case LOWPOWER:
+// sleep();
+// break;
+// default:
+// State = LOWPOWER;
+// break;
+// }
+//}
int TimeOnAirSend(void) {
@@ -558,4 +616,6 @@
}
+
+
#endif
diff -r 51f492ca61a2 -r 62c868478eef SX1276GenericPingPong/GenericPingPong2.h --- a/SX1276GenericPingPong/GenericPingPong2.h Wed Oct 14 00:19:02 2020 +0000 +++ b/SX1276GenericPingPong/GenericPingPong2.h Tue Oct 20 00:00:20 2020 +0000 @@ -110,4 +110,8 @@ */ int numOfRxTimeouts(); +bool SX1276MasterCheckForNewData(void); + +void SX1276SlaveSendData(void); + #endif // __MAIN_H__ \ No newline at end of file
diff -r 51f492ca61a2 -r 62c868478eef global_buffers.h
--- a/global_buffers.h Wed Oct 14 00:19:02 2020 +0000
+++ b/global_buffers.h Tue Oct 20 00:00:20 2020 +0000
@@ -23,7 +23,6 @@
#include "mbed.h"
//#include "GenericPingPong2.h"
-//#include "support.h"
/***************************************************************************
* MASTER Device
@@ -40,22 +39,11 @@
* Indexes for which byte specific data begins at in the payload buffer
**************************************************************************/
/* size of ID data that defines what the signature of the device is */
-const uint8_t size_signature = 1;
-
-/* size of data in bytes that is acquired by the master device */
-//const uint8_t size_of_ble = 2;
-//const uint8_t size_of_dum = 2;
-
-/* size of data in bytes that is acquired by the slave device */
-//const uint8_t size_of_grid_eye = 128;
-//const uint8_t size_of_gps = 20;
-//const uint8_t size_of_MAX17055 = 22;
-//const uint8_t size_of_MAX77650 = 5;
+//const uint8_t size_signature = 1;
const uint8_t size_of_MAX30208 = 2; // temperature data
const uint8_t size_of_MAX44009 = 2; // light data
-const uint8_t size_of_MAX20361 = 4; // AO32 data
-const uint8_t size_of_other = 0; // other data
+const uint8_t size_of_MAX20361 = 3; // AO32 data
/* These are the sizes of each payload in bytes. Since there is different amount
@@ -64,18 +52,9 @@
* is to be delivered and for data that is received.
*/
-const uint16_t PAYLOAD_BUFFER_SIZE_MASTER_TO_SLAVE = size_signature;
//const uint16_t PAYLOAD_BUFFER_SIZE_MASTER_TO_SLAVE = 0;
-const uint16_t PAYLOAD_BUFFER_SIZE_SLAVE_TO_MASTER = size_signature + size_of_MAX30208 + size_of_MAX44009 + size_of_MAX20361;
-
-/* determine the appropriate buffer sizes */
-//#if defined(TARGET_MAX32630FTHR) // Master Device: Bluetooth Gateway
-// const uint16_t BufferSizeTx = PAYLOAD_BUFFER_SIZE_MASTER_TO_SLAVE;
-// const uint16_t BufferSizeRx = PAYLOAD_BUFFER_SIZE_SLAVE_TO_MASTER;
-//#elif defined(TARGET_MAX32620FTHR) // Slave Device: Robot
-// const uint16_t BufferSizeTx = PAYLOAD_BUFFER_SIZE_SLAVE_TO_MASTER;
-// const uint16_t BufferSizeRx = PAYLOAD_BUFFER_SIZE_MASTER_TO_SLAVE;
-//#endif
+const uint16_t PAYLOAD_BUFFER_SIZE_MASTER_TO_SLAVE = 1; // can't be zero, otherwise internal error
+const uint16_t PAYLOAD_BUFFER_SIZE_SLAVE_TO_MASTER = size_of_MAX30208 + size_of_MAX44009 + size_of_MAX20361;
/* determine the appropriate buffer sizes */
#if MASTER == 1 // Master Device
@@ -86,104 +65,28 @@
const uint16_t BufferSizeRx = PAYLOAD_BUFFER_SIZE_MASTER_TO_SLAVE;
#endif
-
-//#if defined(TARGET_MAX32630FTHR) // Master Device: BLE-to-LoRa Gateway
-// /* These are indexs used to create the payload buffer to send to Slave */
-// const uint8_t tx_idx_signature = 0; // 1st buf in tx payload (begins at byte 0)
-// const uint8_t tx_idx_ble = tx_idx_signature + size_signature; // 2nd buf in tx payload
-//
-// /* These are indexs used to deconstruct received payload buffer sent by the Slave */
-// const uint8_t rx_idx_signature = 0; // 1st buf in rx payload (begins at byte 0)
-// const uint8_t rx_idx_grid_eye = rx_idx_signature + size_signature; // 2nd buf in rx payload
-// const uint8_t rx_idx_gps = rx_idx_grid_eye + size_of_grid_eye; // 3rd buf in rx payload
-// const uint8_t rx_idx_MAX17055 = rx_idx_gps + size_of_gps; // 4th buf in rx payload
-// const uint8_t rx_idx_MAX77650 = rx_idx_MAX17055 + size_of_MAX17055; // 5th buf in rx payload
-//
-//#elif defined(TARGET_MAX32620FTHR) // Client Device: LoRa Controlled Robot
-// /* These are indexs used to create the payload buffer to send to Master */
-// const uint8_t tx_idx_signature = 0; // 1st buf in tx payload (begins at byte 0)
-// const uint8_t tx_idx_grid_eye = tx_idx_signature + size_signature; // 2nd buf in tx payload
-// const uint8_t tx_idx_gps = tx_idx_grid_eye + size_of_grid_eye; // 3rd buf in tx payload
-// const uint8_t tx_idx_MAX17055 = tx_idx_gps + size_of_gps; // 4th buf in tx payload
-// const uint8_t tx_idx_MAX77650 = tx_idx_MAX17055 + size_of_MAX17055; // 5th buf in tx payload
-//
-// /* These are indexs used to deconstruct received payload buffer sent by the Master */
-// const uint8_t rx_idx_signature = 0; // 1st buf in rx payload (begins at byte 0)
-// const uint8_t rx_idx_ble = rx_idx_signature + size_signature; // 2nd buf in rx payload
-//#endif
-
-#if MASTER == 1 // Master Device
- /* These are indexs used to create the payload buffer to send to Slave */
- const uint8_t tx_idx_signature = 0; // 1st buf in tx payload (begins at byte 0)
-// const uint8_t tx_idx_dum = tx_idx_signature + size_signature; // 2nd buf in tx payload
+#if MASTER == 1 // Master Device: Gateway Device, only receiving data from Slave
/* These are indexs used to deconstruct received payload buffer sent by the Slave */
- const uint8_t rx_idx_signature = 0; // 1st buf in rx payload (begins at byte 0)
- const uint8_t rx_idx_MAX30208 = rx_idx_signature + size_signature; // 2nd buf in rx payload
- const uint8_t rx_idx_MAX44009 = rx_idx_MAX30208 + size_of_MAX30208; // 3rd buf in rx payload
- const uint8_t rx_idx_MAX20361 = rx_idx_MAX44009 + size_of_MAX44009; // 4th buf in rx payload
-// const uint8_t rx_idx_other = rx_idx_MAX20361 + size_of_MAX20361; // 5th buf in rx payload
+ const uint8_t rx_idx_MAX30208 = 0; // 1st buf in rx payload (begins at byte 0), temp data
+ const uint8_t rx_idx_MAX44009 = rx_idx_MAX30208 + size_of_MAX30208; // 2nd buf in rx payload, lux data
+ const uint8_t rx_idx_MAX20361 = rx_idx_MAX44009 + size_of_MAX44009; // 3rd buf in rx payload, AO32 data
-#elif SLAVE == 1 // Slave Device: LoRa Controlled Robot
+#elif SLAVE == 1 // Slave Device: Sensor Node, only sending data to Master
/* These are indexs used to create the payload buffer to send to Master */
- const uint8_t tx_idx_signature = 0; // 1st buf in tx payload (begins at byte 0)
- const uint8_t tx_idx_MAX30208 = tx_idx_signature + size_signature; // 2nd buf in tx payload
- const uint8_t tx_idx_MAX44009 = tx_idx_MAX30208 + size_of_MAX30208; // 3rd buf in tx payload
- const uint8_t tx_idx_MAX20361 = tx_idx_MAX44009 + size_of_MAX44009 ; // 4th buf in tx payload
-// const uint8_t tx_idx_other = tx_idx_MAX20361 + size_of_MAX20361; // 5th buf in tx payload
-
- /* These are indexs used to deconstruct received payload buffer sent by the Master */
- const uint8_t rx_idx_signature = 0; // 1st buf in rx payload (begins at byte 0)
-// const uint8_t rx_idx_dum = rx_idx_signature + size_signature; // 2nd buf in rx payload
+ const uint8_t tx_idx_MAX30208 = 0; // 1st buf in tx payload (begins at byte 0), temp data
+ const uint8_t tx_idx_MAX44009 = tx_idx_MAX30208 + size_of_MAX30208; // 2nd buf in tx payload, lux data
+ const uint8_t tx_idx_MAX20361 = tx_idx_MAX44009 + size_of_MAX44009; // 3rd buf in tx payload, AO32 data
#endif
-
-/***************************************************************************
- * BLE Data Buffers
- **************************************************************************/
-//#if defined(TARGET_MAX32630FTHR) // Master Device: BLE-to-LoRa Gateway
-// static char curr_ble_data_to_slave[size_of_ble];
-//#elif defined(TARGET_MAX32620FTHR) // Slave Device: LoRa Controlled Robot
-// static char curr_ble_data_from_master[size_of_ble];
-// static char prev_ble_data_from_master[size_of_ble];
-//#endif
-
-/***************************************************************************
- * Dummy Data Buffers
- **************************************************************************/
-#if MASTER == 1 // Master Device
-// static char curr_dum_data_to_slave[size_of_dum];
-#elif SLAVE == 1 // Slave Device
-// static char curr_dum_data_from_master[size_of_dum];
-// static char prev_dum_data_from_master[size_of_dum];
-#endif
-
-
-/***************************************************************************
- * Grid Eye Sensor Data Buffers
- **************************************************************************/
-//#if defined(TARGET_MAX32630FTHR) // Master Device: BLE-to-LoRa Gateway
-// static char curr_raw_frame_data_from_slave[size_of_grid_eye];
-// static char prev_raw_frame_data_from_slave[size_of_grid_eye];
-// static int16_t conv_frame_data_from_slave[64];
-//#elif defined(TARGET_MAX32620FTHR) // Client Device: LoRa Controlled Robot
-// static char curr_raw_frame_data_to_master[size_of_grid_eye];
-// static char prev_raw_frame_data_to_master[size_of_grid_eye];
-// static int16_t conv_frame_data_to_master[64];
-//#endif
-
-
/***************************************************************************
* MAX30208 Data Buffers
**************************************************************************/
#if MASTER == 1 // Master Device
static char curr_raw_temp_data_from_slave[size_of_MAX30208];
static char prev_raw_temp_data_from_slave[size_of_MAX30208];
-// static int16_t conv_frame_data_from_slave[64];
#elif SLAVE == 1 // Slave Device
static char curr_raw_temp_data_to_master[size_of_MAX30208];
-// static char prev_raw_temp_data_to_master[size_of_MAX30208];
-// static int16_t conv_frame_data_to_master[64];
#endif
/***************************************************************************
@@ -192,11 +95,8 @@
#if MASTER == 1 // Master Device
static char curr_raw_light_data_from_slave[size_of_MAX44009];
static char prev_raw_light_data_from_slave[size_of_MAX44009];
-// static int16_t conv_frame_data_from_slave[64];
#elif SLAVE == 1 // Slave Device
static char curr_raw_light_data_to_master[size_of_MAX44009];
-// static char prev_raw_light_data_to_master[size_of_MAX44009];
-// static int16_t conv_frame_data_to_master[64];
#endif
/***************************************************************************
@@ -205,56 +105,10 @@
#if MASTER == 1 // Master Device
static char curr_raw_AO32_data_from_slave[size_of_MAX20361];
static char prev_raw_AO32_data_from_slave[size_of_MAX20361];
-// static int16_t conv_frame_data_from_slave[64];
#elif SLAVE == 1 // Slave Device
static char curr_raw_AO32_data_to_master[size_of_MAX20361];
-// static char prev_raw_AO32_data_to_master[size_of_MAX20361];
-// static int16_t conv_frame_data_to_master[64];
#endif
-/***************************************************************************
- * Other Data Buffers
- **************************************************************************/
-#if MASTER == 1 // Master Device
-// static char curr_raw_other_data_from_slave[size_of_other];
-// static char prev_raw_other_data_from_slave[size_of_other];
-// static int16_t conv_frame_data_from_slave[64];
-#elif SLAVE == 1 // Slave Device
-// static char curr_raw_other_data_to_master[size_of_other];
-// static char prev_raw_other_data_to_master[size_of_other];
-// static int16_t conv_frame_data_to_master[64];
-#endif
-
-/***************************************************************************
- * GPS Data Buffers
- **************************************************************************/
-//#if defined(TARGET_MAX32630FTHR) // Master Device: BLE-to-LoRa Gateway
-// static char curr_gps_data_from_slave[size_of_gps];
-// static char prev_gps_data_from_slave[size_of_gps];
-//#elif defined(TARGET_MAX32620FTHR) // Slave Device: LoRa Controlled Robot
-// static char curr_gps_data_to_master[size_of_gps];
-//#endif
-
-/***************************************************************************
- * MAX17055 Data Buffers
- **************************************************************************/
-//#if defined(TARGET_MAX32630FTHR) // Master Device: BLE-to-LoRa Gateway
-// static char curr_MAX17055_from_slave[size_of_MAX17055];
-// static char prev_MAX17055_from_slave[size_of_MAX17055];
-//#elif defined(TARGET_MAX32620FTHR) // Slave Device: LoRa Controlled Robot
-// static char curr_MAX17055_to_master[size_of_MAX17055];
-//#endif
-
-/***************************************************************************
- * MAX77650 Data Buffers
- **************************************************************************/
-//#if defined(TARGET_MAX32630FTHR) // Master Device: BLE-to-LoRa Gateway
-// static char curr_MAX77650_from_slave[size_of_MAX77650];
-// static char prev_MAX77650_from_slave[size_of_MAX77650];
-//#elif defined(TARGET_MAX32620FTHR) // Slave Device: LoRa Controlled Robot
-// static char curr_MAX77650_to_master[size_of_MAX77650];
-//#endif
-
/**
* @brief This function constructs a payload buffer that is used in transmitting data in a LoRa Message
*/
diff -r 51f492ca61a2 -r 62c868478eef main.cpp
--- a/main.cpp Wed Oct 14 00:19:02 2020 +0000
+++ b/main.cpp Tue Oct 20 00:00:20 2020 +0000
@@ -1,6 +1,8 @@
#include "mbed.h"
+#include "lp.h"
+
// Board pins related
#include "PinMap.h"
@@ -25,11 +27,6 @@
// AO19 related
#include "AO19_lib.h"
-//#if defined(TARGET_MAX32630FTHR) // using the RFM95 board
-// #include "max32630fthr.h"
-// MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
-//#endif
-
// Virtual COM related
#include "USBSerial.h" // for virtual COM
#define BS 8 // ASCII Back Space
@@ -38,15 +35,6 @@
// Virtual serial port over USB TODO NEW VID PID NEEDED!!
USBSerial pc(0x0B6A, 0x0042, 0x0001, false);
-///***************************************************************************
-// * Virtual COM Instantiation
-// **************************************************************************/
-//#include "USBSerial.h" // for virtual COM
-//#define BS 8 // ASCII Back Space
-//#define CR 13 // ASCII Carriage Return
-//// Virtual serial port over USB TODO NEW VID PID NEEDED!!
-//USBSerial pc(0x0B6A, 0x0042, 0x0001, false);
-
/***************************************************************************
* LEDs Instantiation
**************************************************************************/
@@ -84,99 +72,52 @@
/* Setup begins here: */
#if MASTER == 1 // Master Device
-// pc.printf("MAX32625PICO: MASTER DEVICE\r\n");
-// wait(1);
+ rLED = LED_ON; // red LED on
+ myled = LED_OFF;
+ bLED = LED_OFF;
#elif SLAVE == 1 // Slave Device
-// pc.printf("MAX32625PICO: SLAVE DEVICE\r\n");
-// wait(1);
+ rLED = LED_OFF;
+ myled = LED_OFF;
+ bLED = LED_ON; // blue LED on
+
+ sleep(); // put slave in sleep mode
+
#endif
- /* Introduction text: */
-// pc.printf("Welcome to the SX1276GenericLib\r\n");
-// wait(5);
-// pc.printf("Starting a simple LoRa PingPong\r\n");
-// wait(5);
-
/***************************************************************************
* Combined Payload Buffers for LoRa Communications
**************************************************************************/
uint8_t BufferTx[BufferSizeTx]; // more info in global_buffers.h
uint8_t BufferRx[BufferSizeRx]; // more info in global_buffers.h
-
- /***************************************************************************
- * Identification Buffers
- **************************************************************************/
- #if MASTER == 1 // Master Device
- uint8_t ID_of_slave[size_signature];
- #elif SLAVE == 1 // Slave Device
- uint8_t ID_of_master[size_signature];
- #endif
-
- /***************************************************************************
- * Dummy Data Buffers
- **************************************************************************/
- #if MASTER == 1 // Master Device
-// uint8_t curr_dum_to_slave[size_of_dum];
- #elif SLAVE == 1 // Slave Device
-// uint8_t curr_dum_from_master[size_of_dum];
-// uint8_t prev_dum_from_master[size_of_dum];
- #endif
-
+
/***************************************************************************
* MAX30208 Data Buffers
**************************************************************************/
#if MASTER == 1 // Master Device
-// uint8_t curr_MAX77650_from_slave[size_of_MAX77650];
-// uint8_t curr_raw_temp_from_slave[size_of_MAX30208];
char curr_raw_temp_from_slave[size_of_MAX30208]; // to match data type
-// uint8_t prev_MAX77650_from_slave[size_of_MAX77650];
char prev_raw_temp_from_slave[size_of_MAX30208];
#elif SLAVE == 1 // Slave Device
-// uint8_t curr_MAX77650_to_master[size_of_MAX77650];
-// bool chrg_status = false; //True = ON False = OFF
uint8_t curr_raw_temp_to_master[size_of_MAX30208];
#endif
-
/***************************************************************************
* MAX44009 Data Buffers
**************************************************************************/
#if MASTER == 1 // Master Device
-// uint8_t curr_raw_light_from_slave[size_of_MAX44009];
char curr_raw_light_from_slave[size_of_MAX44009]; // to match data type
char prev_raw_light_from_slave[size_of_MAX44009];
- // static int16_t conv_frame_data_from_slave[64];
#elif SLAVE == 1 // Slave Device
uint8_t curr_raw_light_to_master[size_of_MAX44009];
- // static char prev_raw_light_data_to_master[size_of_MAX44009];
- // static int16_t conv_frame_data_to_master[64];
#endif
/***************************************************************************
* MAX20361 Data Buffers
**************************************************************************/
#if MASTER == 1 // Master Device
-// uint8_t curr_raw_AO32_from_slave[size_of_MAX20361];
char curr_raw_AO32_from_slave[size_of_MAX20361]; // to match data type
char prev_raw_AO32_from_slave[size_of_MAX20361];
- // static int16_t conv_frame_data_from_slave[64];
#elif SLAVE == 1 // Slave Device
uint8_t curr_raw_AO32_to_master[size_of_MAX20361];
- // static char prev_raw_AO32_data_to_master[size_of_MAX20361];
- // static int16_t conv_frame_data_to_master[64];
- #endif
-
- /***************************************************************************
- * Other Data Buffers
- **************************************************************************/
- #if MASTER == 1 // Master Device
-// uint8_t curr_raw_other_from_slave[size_of_other];
-// uint8_t prev_raw_other_from_slave[size_of_other];
- // static int16_t conv_frame_data_from_slave[64];
- #elif SLAVE == 1 // Slave Device
-// uint8_t curr_raw_other_to_master[size_of_other];
- // static char prev_raw_other_data_to_master[size_of_other];
- // static int16_t conv_frame_data_to_master[64];
#endif
/***************************************************************************
@@ -188,31 +129,6 @@
// https://www.tutorialspoint.com/cprogramming/c_pointers.htm
/***************************************************************************
- * Create Dummy Data For Master and Slave
- **************************************************************************/
-// Array Tutorials
-// http://www.cplusplus.com/doc/tutorial/arrays/
- #if MASTER == 1
-// curr_dum_to_slave[0] = {33, 34};
-// curr_dum_to_slave[0] = 33;
-// curr_dum_to_slave[1] = 34;
- #endif
-
- #if SLAVE == 1
-
- curr_raw_temp_to_master[0] = 99;
- curr_raw_temp_to_master[1] = 99;
-
- curr_raw_light_to_master[0] = 25;
- curr_raw_light_to_master[1] = 26;
-
- curr_raw_AO32_to_master[0] = 99;
- curr_raw_AO32_to_master[1] = 100;
- curr_raw_AO32_to_master[2] = 101;
- curr_raw_AO32_to_master[3] = 102;
- #endif
-
- /***************************************************************************
* Loop Counter
**************************************************************************/
int loopCnt = 0;
@@ -236,7 +152,7 @@
char MAX44009_i2c_add = 0x94; // 0b1001 010x
//************* AO32 Variables ****************
- char rawOCVdata[2]; // only needs 1
+ char rawOCVdata[1]; // only needs 1
char rawCntdata[2];
char AO32_i2c_add = 0x2A; // 0b0010 101x
@@ -267,7 +183,11 @@
while (1) {
- #if SLAVE == 1
+ #if SLAVE == 1 // only send sensor data
+
+ // Slave sleeps before interrupt calls
+ sleep();
+
if(get_data_flag) {
//reset the flag
@@ -281,17 +201,7 @@
convert_temperature(&i2cBus0, OT07_i2c_add); //send OW convert selected device
wait_ms(CONVERT_T_DELAY); //wait 20 ms for convert temperature to complete
int temp_error = OT07_read_register(&i2cBus0, OT07_i2c_add, OT07_FIFO_DATA, rawtempdata, 2);
-// pc.printf("OT07 add[%02X] data[%02X] data[%02X]\r\n", OT07_FIFO_DATA, rawtempdata[0], rawtempdata[1]);
-
- //calculate temperature from data
-// int count = (int)(rawtempdata[0]*256 + rawtempdata[1]);
-// if (count >= 32768)count = count - 65536; // 2s comp
-// double Temp = (double)count*0.005;
-// pc.printf("OT07 temperature[%.3f] status[%d]\r\n", Temp, temp_error);
double tempFinal = calc_temperature(rawtempdata);
-// pc.printf("OT07 Final temperature[%.3f] \r\n", tempFinal);
-// pc.printf("\r\n");
-
//fill raw temp data into the array
curr_raw_temp_to_master[0] = rawtempdata[0];
@@ -302,55 +212,25 @@
**************************************************************************/
// obtain register hex values
int lux_error = MAX44009_read_lux_register(&i2cBus0, MAX44009_i2c_add, MAX44009_LUX_HI, rawluxdata);
-// int lux_error1 = MAX44009_read_register(&i2cBus0, MAX44009_i2c_add, MAX44009_LUX_HI, &rawluxdata[0]);
-// int lux_error2 = MAX44009_read_register(&i2cBus0, MAX44009_i2c_add, MAX44009_LUX_LO, &rawluxdata[1]);
-// pc.printf("MAX44009 hi_add[%02X] hi_data[%02X] lo_add[%02X] lo_data[%02X]\r\n", MAX44009_LUX_HI, rawluxdata[0], MAX44009_LUX_LO, rawluxdata[1]);
-
- //calculate temperature from data
-// int exponent = int(rawluxdata[0] >> 4);
-// int mantissa = (int)((rawluxdata[0] << 4) & 0xF0) + (int)(rawluxdata[1]);
-// double lux = 0.045 * mantissa * pow((double) 2, exponent);
-// pc.printf("MAX44009 exponent[%d] mantissa[%d]\r\n", exponent, mantissa);
-// pc.printf("MAX44009 lux[%.2f] status[%d] status[%d]\r\n", lux, lux_error1, lux_error2);
-// pc.printf("MAX44009 lux[%.2f] status[%d]\r\n", lux, lux_error);
int luxFinal = (int) (calc_lux(rawluxdata));
-// pc.printf("MAX44009 Final Lux[%.2f] \r\n", luxFinal);
-// pc.printf("\r\n");
//fill raw lux data into the array
curr_raw_light_to_master[0] = rawluxdata[0];
curr_raw_light_to_master[1] = rawluxdata[1];
-
/***************************************************************************
* Solar Harvester Data Measurement
**************************************************************************/
- // obtain register hex values
-// char AO32ID[2];
-// int id_error = AO32_read_register(&i2cBus0, AO32_i2c_add, AO32_DEVICE_ID, AO32ID); // testing
-// pc.printf("AO32 add[%02X] data[%02X]\r\n", AO32_DEVICE_ID, AO32ID[0]); // should be 0x00: 0x11
int ocv_error = AO32_read_register(&i2cBus0, AO32_i2c_add, AO32_VOC, rawOCVdata);
-// pc.printf("AO32 add[%02X] data[%02X]\r\n", AO32_VOC, rawOCVdata[0]);
int cnt_error = AO32_read_register(&i2cBus0, AO32_i2c_add, AO32_HARV_H, rawCntdata, 2); // burst read 2 bytes
-// pc.printf("AO32 hi_add[%02X] hi_data[%02X] lo_add[%02X] lo_data[%02X]\r\n", AO32_HARV_H, rawCntdata[0], AO32_HARV_L, rawCntdata[1]);
//calculate open circuit voltage from data
- double voltage = (double)(rawOCVdata[0]) / 100;
-// pc.printf("AO32 OCV[%.2f] status[%d]\r\n", voltage, ocv_error);
+// double voltage = (double)(rawOCVdata[0]) / 100;
double OCVFinal = calc_OCV(rawOCVdata);
-// pc.printf("AO32 Final OCV[%.2f] \r\n", OCVFinal);
-// pc.printf("\r\n");
//calculate harvesting counts from data
-// int countHi = int(rawCntdata[0]) * 256;
-// int countLo = int(rawCntdata[1]);
-// int harvest_counts = countHi + countLo;
-// pc.printf("AO32 HarvesterCnt[%d] status[%d]\r\n", harvest_counts, cnt_error);
int countFinal = calc_Harvest(rawCntdata);
-// pc.printf("AO32 Final HarvesterCnt[%d]\r\n", countFinal);
-// pc.printf("\r\n");
-
//fill raw AO32 data into the array
curr_raw_AO32_to_master[0] = rawOCVdata[0]; // Fill OCV hex first
@@ -363,169 +243,64 @@
/***************************************************************************
* Fill Payload Buffer With Data From Main Program Buffers for next LoRa Transmition
**************************************************************************/
- memcpy(&BufferTx[tx_idx_signature], PongMsg, size_signature);
memcpy(&BufferTx[tx_idx_MAX30208], curr_raw_temp_to_master, size_of_MAX30208);
memcpy(&BufferTx[tx_idx_MAX44009], curr_raw_light_to_master, size_of_MAX44009);
memcpy(&BufferTx[tx_idx_MAX20361], curr_raw_AO32_to_master, size_of_MAX20361);
-// memcpy(&BufferTx[tx_idx_other], curr_raw_other_to_master, size_of_other);
-
- /***************************************************************************
- * In case of OnRxTimeout
- **************************************************************************/
- // Slave Device, these are values when LoRa communication did not happen
- // ID_of_master[0] = 'N'; // 0x4E or 78
-// ID_of_master[1] = 'A'; // 0x41 or 65
-// ID_of_master[2] = 'C'; // 0x43 or 67
-// ID_of_master[3] = 'K'; // 0x4B or 75
-// ID_of_master[4] = 'M'; // 0x4D or 77
-// ID_of_master[5] = 'A'; // 0x41 or 65
-// ID_of_master[6] = 'S'; // 0x53 or 83
-// ID_of_master[7] = '!'; // 0x21 or 33
-//
-// curr_dum_from_master[0] = 39;
-// curr_dum_from_master[1] = 40;
-
+
/***************************************************************************
* LoRa Communication: Send Sensor Data
**************************************************************************/
-// SX1276SensorSend();
- SX1276PingPong();
-// int sendTime = TimeOnAirSend();
-// pc.printf("Tx Time on Air: %d \r\n", sendTime);
-
- /***************************************************************************
- * Fill Main Program Buffers With Data From Received Payload Buffer
- **************************************************************************/
- // Slave Device
-// memcpy(ID_of_master, &BufferRx[rx_idx_signature], size_signature);
-// memcpy(curr_dum_from_master, &BufferRx[rx_idx_dum], size_of_dum);
-
- /***************************************************************************
- * Slave Device: Print out Master Data
- **************************************************************************/
- // memcpy(ID_of_master, &BufferRx[rx_idx_signature], size_signature);
-// pc.printf("Print ID_of_master\r\n");
-// for(int i = 0; i < sizeof(ID_of_master); i++){
-// pc.printf("%d \r\n", ID_of_master[i]);
-// }
-
- // memcpy(curr_dum_from_master, &BufferRx[rx_idx_dum], size_of_dum);
-// pc.printf("Print Dum From Master\r\n");
-// for(int i = 0; i < sizeof(curr_dum_from_master); i++){
-// pc.printf("%d \r\n", curr_dum_from_master[i]);
-// }
-
- // print loop counter
-// pc.printf("Loop Counter Slave: %d \r\n", loopCnt);
+// SX1276PingPong();
+ SX1276SlaveSendData();
loopCnt = loopCnt + 1;
} // end of transmission frequency for slave
#endif
- #if MASTER == 1
- /***************************************************************************
- * Fill Payload Buffer With Data From Main Program Buffers for next LoRa Transmition
- **************************************************************************/
- memcpy(&BufferTx[tx_idx_signature], PingMsg, size_signature);
-// memcpy(&BufferTx[tx_idx_dum], curr_dum_to_slave, size_of_dum);
+ #if MASTER == 1 // only Receive Sensor Data
/***************************************************************************
* LoRa Communication: Gateway Receive Sensor Data
**************************************************************************/
-// SX1276GateWayReceive(333);
- SX1276PingPong();
-// int sendTime = TimeOnAirSend();
-// pc.printf("Tx Time on Air: %d \r\n", sendTime);
+// SX1276PingPong();
+ if(SX1276MasterCheckForNewData())
+ {
/***************************************************************************
* Fill Main Program Buffers With Data From Received Payload Buffer
**************************************************************************/
- memcpy(ID_of_slave, &BufferRx[rx_idx_signature], size_signature);
memcpy(curr_raw_temp_from_slave, &BufferRx[rx_idx_MAX30208], size_of_MAX30208);
memcpy(curr_raw_light_from_slave, &BufferRx[rx_idx_MAX44009], size_of_MAX44009);
memcpy(curr_raw_AO32_from_slave, &BufferRx[rx_idx_MAX20361], size_of_MAX20361);
-// memcpy(curr_raw_other_from_slave, &BufferRx[rx_idx_other], size_of_other);
/***************************************************************************
* Master Device: Print out Slave Data
**************************************************************************/
- // memcpy(ID_of_slave, &BufferRx[rx_idx_signature], size_signature);
- //pc.printf("Print ID_of_slave\r\n");
-// for(int i = 0; i < sizeof(ID_of_slave); i++){
-// pc.printf("%d \r\n", ID_of_slave[i]);
-// }
-
- // memcpy(curr_raw_temp_from_slave, &BufferRx[rx_idx_MAX30208], size_of_MAX30208);
-// pc.printf("Print MAX30208 data\r\n");
-// for(int i = 0; i < sizeof(curr_raw_temp_from_slave); i++){
-// pc.printf("[%02X]\r\n", curr_raw_temp_from_slave[i]);
-// }
-
-// int count = curr_raw_temp_from_slave[0] * 256 + curr_raw_temp_from_slave[1];
-// if (count >= 32768)count = count - 65536; // 2s comp
-// double tempResult = count * 0.005;
-
double tempResult = calc_temperature(curr_raw_temp_from_slave);
-// pc.printf("MSG: [%.3f] [] [] [] []\r\n", tempResult);
+ int luxResult = (int) calc_lux(curr_raw_light_from_slave);
-
- // memcpy(curr_raw_light_from_slave, &BufferRx[rx_idx_MAX44009], size_of_MAX44009);
-// pc.printf("Print MAX44009 data\r\n");
-// for(int i = 0; i < sizeof(curr_raw_light_from_slave); i++){
-// pc.printf("[%02X] \r\n", curr_raw_light_from_slave[i]);
-// }
-
- int luxResult = (int) calc_lux(curr_raw_light_from_slave);
-// pc.printf("MSG: [%.3f] [%.2f] [] [] []\r\n", tempResult, luxResult);
-
- // memcpy(curr_raw_AO32_from_slave, &BufferRx[rx_idx_MAX20361], size_of_MAX20361);
-// pc.printf("Print MAX20361 data\r\n");
-// for(int i = 0; i < sizeof(curr_raw_AO32_from_slave); i++){
-// pc.printf("[%02X] \r\n", curr_raw_AO32_from_slave[i]);
-// }
-
- char OCVrawHex[2];
+ char OCVrawHex[1];
OCVrawHex[0] = curr_raw_AO32_from_slave[0];
- OCVrawHex[1] = curr_raw_AO32_from_slave[1];
char CntrawHex[2];
- CntrawHex[0] = curr_raw_AO32_from_slave[2];
- CntrawHex[1] = curr_raw_AO32_from_slave[3];
+ CntrawHex[0] = curr_raw_AO32_from_slave[1];
+ CntrawHex[1] = curr_raw_AO32_from_slave[2];
double OCVResult = calc_OCV(OCVrawHex);
int CntResult = calc_Harvest(CntrawHex);
-
-
- // only print out new results
-// int tempNew = memcmp(prev_raw_temp_from_slave, curr_raw_temp_from_slave, sizeof(size_of_MAX30208));
-// int luxNew = memcmp(prev_raw_light_from_slave, curr_raw_light_from_slave, sizeof(size_of_MAX44009));
-// int AO32New = memcmp(prev_raw_AO32_from_slave, curr_raw_AO32_from_slave, sizeof(size_of_MAX20361));
-
-// if (tempNew != 0 || luxNew != 0 || AO32New != 0) {
-
-// pc.printf("MSG: [%.3f] [%d] [%.2f] [%d] [0]\r\n", tempResult, luxResult, OCVResult, CntResult);
-
-// }
+
+ //reset the flag
+ print_data_flag = false; // no need
+ pc.printf("MSG: [%.3f] [%d] [%.2f] [%d] [0]\r\n", tempResult, luxResult, OCVResult, CntResult);
- if(print_data_flag) {
-
- //reset the flag
- print_data_flag = false;
- pc.printf("MSG: [%.3f] [%d] [%.2f] [%d] [0]\r\n", tempResult, luxResult, OCVResult, CntResult);
-
- }
-
- // copy the current recceived data into previous data
-// memcpy(prev_raw_temp_from_slave, curr_raw_temp_from_slave, sizeof(size_of_MAX30208));
-// memcpy(prev_raw_light_from_slave, c/urr_raw_light_from_slave, sizeof(size_of_MAX44009));
-// memcpy(prev_raw_AO32_from_slave, curr_raw_AO32_from_slave, sizeof(size_of_MAX20361));
-
- // print loop counter
-// pc.printf("Loop Counter Master: %d \r\n", loopCnt);
+ } // end of SX1276MasterCheckForNewData
+
loopCnt = loopCnt + 1;
#endif
+ sleep(); // going back to sleep mode
+
} // end of while(1) loop
} // end of main()
\ No newline at end of file
diff -r 51f492ca61a2 -r 62c868478eef main.h
--- a/main.h Wed Oct 14 00:19:02 2020 +0000
+++ b/main.h Tue Oct 20 00:00:20 2020 +0000
@@ -8,49 +8,49 @@
#define FEATURE_LORA
-#ifdef FEATURE_LORA // in main.cpp
+//#ifdef FEATURE_LORA // in main.cpp
/* Set this flag to '1' to display debug messages on the console */
-#define DEBUG_MESSAGE 1
+//#define DEBUG_MESSAGE 1
/* Set this flag to '1' to use the LoRa modulation or to '0' to use FSK modulation */
-#define USE_MODEM_LORA 1
-#define USE_MODEM_FSK !USE_MODEM_LORA
-#define RF_FREQUENCY RF_FREQUENCY_915_0 // Hz
-#define TX_OUTPUT_POWER 14 // 14 dBm
+//#define USE_MODEM_LORA 1
+//#define USE_MODEM_FSK !USE_MODEM_LORA
+//#define RF_FREQUENCY RF_FREQUENCY_915_0 // Hz
+//#define TX_OUTPUT_POWER 14 // 14 dBm
-#if USE_MODEM_LORA == 1
+//#if USE_MODEM_LORA == 1
-#define LORA_BANDWIDTH 125000 // LoRa default, details in SX1276::BandwidthMap
-#define LORA_SPREADING_FACTOR LORA_SF7
-#define LORA_CODINGRATE LORA_ERROR_CODING_RATE_4_5
+//#define LORA_BANDWIDTH 125000 // LoRa default, details in SX1276::BandwidthMap
+//#define LORA_SPREADING_FACTOR LORA_SF7
+//#define LORA_CODINGRATE LORA_ERROR_CODING_RATE_4_5
-#define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx
-#define LORA_SYMBOL_TIMEOUT 5 // Symbols
-#define LORA_FIX_LENGTH_PAYLOAD_ON false
-#define LORA_FHSS_ENABLED false
-#define LORA_NB_SYMB_HOP 4
-#define LORA_IQ_INVERSION_ON false
-#define LORA_CRC_ENABLED true
+//#define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx
+//#define LORA_SYMBOL_TIMEOUT 5 // Symbols
+//#define LORA_FIX_LENGTH_PAYLOAD_ON false
+//#define LORA_FHSS_ENABLED false
+//#define LORA_NB_SYMB_HOP 4
+//#define LORA_IQ_INVERSION_ON false
+//#define LORA_CRC_ENABLED true
-#elif USE_MODEM_FSK == 1
+//#elif USE_MODEM_FSK == 1
-#define FSK_FDEV 25000 // Hz
-#define FSK_DATARATE 19200 // bps
-#define FSK_BANDWIDTH 50000 // Hz
-#define FSK_AFC_BANDWIDTH 83333 // Hz
-#define FSK_PREAMBLE_LENGTH 5 // Same for Tx and Rx
-#define FSK_FIX_LENGTH_PAYLOAD_ON false
-#define FSK_CRC_ENABLED true
+//#define FSK_FDEV 25000 // Hz
+//#define FSK_DATARATE 19200 // bps
+//#define FSK_BANDWIDTH 50000 // Hz
+//#define FSK_AFC_BANDWIDTH 83333 // Hz
+//#define FSK_PREAMBLE_LENGTH 5 // Same for Tx and Rx
+//#define FSK_FIX_LENGTH_PAYLOAD_ON false
+//#define FSK_CRC_ENABLED true
-#else
- #error "Please define a modem in the compiler options."
-#endif
+//#else
+// #error "Please define a modem in the compiler options."
+//#endif
-#define RX_TIMEOUT_VALUE 3500 // in ms
+//#define RX_TIMEOUT_VALUE 3500 // in ms
-#endif
+//#endif
/*
* Global variables declarations
