LP Long Distance IR Vision Robot
Dependencies: max77650_charger_sample BufferedSerial SX1276GenericLib Adafruit-MotorShield NEO-6m-GPS MAX17055_EZconfig Adafruit_GFX USBDeviceHT Adafruit-PWM-Servo-Driver
Diff: SX1276GenericPingPong/GenericPingPong.cpp
- Revision:
- 27:6b549f838f0a
- Parent:
- 26:69aba05f010f
- Child:
- 28:0ed92c590607
--- a/SX1276GenericPingPong/GenericPingPong.cpp Fri Jul 20 16:31:41 2018 +0000 +++ b/SX1276GenericPingPong/GenericPingPong.cpp Fri Jul 20 21:29:53 2018 +0000 @@ -87,8 +87,9 @@ */ SX1276Generic *Radio; -uint8_t *BufferTx; -uint8_t *BufferRx; + +uint8_t * BufferTxAlias; +uint8_t * BufferRxAlias; DigitalOut *led3; @@ -111,8 +112,8 @@ * when sending a buffer to the other microcontroller. The BufferRx is what holds * data from a message that is received. */ - BufferTx = PointerToBufferTx; - BufferRx = PointerToBufferRx; + BufferTxAlias = PointerToBufferTx; + BufferRxAlias = PointerToBufferRx; *led3 = 1; #ifdef B_L072Z_LRWAN1_LORA @@ -242,7 +243,7 @@ { if( BufferSizeRx > 0 ) { - if( memcmp(&BufferRx[rx_idx_signature], PongMsg, sizeof(PongMsg)) == 0 ) + if( memcmp(&BufferRxAlias[rx_idx_signature], PongMsg, sizeof(PongMsg)) == 0 ) { // *led = !*led; dprintf( "...Pong" ); @@ -256,9 +257,9 @@ } */ /* Construct the payload buffer so data can be transmited. */ - fillPayloadWithGlobalBufs(BufferTx); + fillPayloadWithGlobalBufs(); wait_ms( 10 ); - Radio->Send( BufferTx, BufferSizeTx ); + Radio->Send( BufferTxAlias, BufferSizeTx ); } /* else if( memcmp(Buffer, PingMsg, sizeof(PingMsg)) == 0 ) { // A master already exists then become a slave @@ -287,7 +288,7 @@ { if( BufferSizeRx > 0 ) { - if( memcmp(BufferRx, PingMsg, sizeof(PingMsg)) == 0 ) + if( memcmp(BufferRxAlias, PingMsg, sizeof(PingMsg)) == 0 ) { // *led = !*led; dprintf( "...Ping" ); @@ -302,7 +303,7 @@ */ //fillPayloadWithGlobalBufs(BufferTx); wait_ms( 10 ); - Radio->Send( BufferTx, BufferSizeTx ); + Radio->Send( BufferTxAlias, BufferSizeTx ); } else // valid reception but not a PING as expected { // Set device as master and start again @@ -337,9 +338,9 @@ BufferTx[i] = i - sizeof(PingMsg); } */ - fillPayloadWithGlobalBufs(BufferTx); + fillPayloadWithGlobalBufs(); wait_ms( 10 ); - Radio->Send( BufferTx, BufferSizeTx ); + Radio->Send( BufferTxAlias, BufferSizeTx ); } else { @@ -352,16 +353,16 @@ if( isMaster == true ) { // Send the next PING frame - memcpy(BufferTx, PingMsg, sizeof(PingMsg)); +// memcpy(BufferTxAlias, PingMsg, sizeof(PingMsg)); /* for( i = 4; i < BufferSizeTx; i++ ) { BufferTx[i] = i - 4; } */ - fillPayloadWithGlobalBufs(BufferTx); + fillPayloadWithGlobalBufs(); wait_ms( 10 ); - Radio->Send( BufferTx, BufferSizeTx ); + Radio->Send( BufferTxAlias, BufferSizeTx ); } else { @@ -373,9 +374,9 @@ BufferTx[i] = i - sizeof(PongMsg); } */ - fillPayloadWithGlobalBufs(BufferTx); + fillPayloadWithGlobalBufs(); wait_ms( 10 ); - Radio->Send( BufferTx, BufferSizeTx ); + Radio->Send( BufferTxAlias, BufferSizeTx ); } State = LOWPOWER; break; @@ -404,11 +405,11 @@ { Radio->Sleep( ); uint16_t ActualBufferSizeRx = size; - memcpy( BufferRx, payload, ActualBufferSizeRx ); + memcpy( BufferRxAlias, payload, ActualBufferSizeRx ); State = RX; // Call function that deconstructs payload - fillGlobalBufsWithPayload(payload); + fillGlobalBufsWithPayload(); if (DEBUG_MESSAGE) dprintf("> OnRxDone: RssiValue=%d dBm, SnrValue=%d", rssi, snr); @@ -428,7 +429,7 @@ { *led3 = 0; Radio->Sleep( ); - BufferRx[BufferSizeRx-1] = 0; + BufferRxAlias[BufferSizeRx-1] = 0; State = RX_TIMEOUT; if (DEBUG_MESSAGE) dprintf("> OnRxTimeout");