carte réceptrice (Wronski et Deleau)
Dependencies: mbed BufferedSerial SX1276GenericLib HTU21D
Diff: SX1276GenericPingPong/GenericPingPong.cpp
- Revision:
- 12:f3bdcf35751e
- Parent:
- 11:9d7409ebfa57
- Child:
- 13:e0f2f772ebf1
diff -r 9d7409ebfa57 -r f3bdcf35751e SX1276GenericPingPong/GenericPingPong.cpp --- a/SX1276GenericPingPong/GenericPingPong.cpp Fri Aug 18 07:45:44 2017 +0000 +++ b/SX1276GenericPingPong/GenericPingPong.cpp Thu Feb 14 10:34:00 2019 +0000 @@ -10,6 +10,7 @@ #include "GenericPingPong.h" #include "sx1276-mbed-hal.h" #include "main.h" +#include "HTU21D.h" #ifdef FEATURE_LORA @@ -88,8 +89,8 @@ SX1276Generic *Radio; -const uint8_t PingMsg[] = { 0xff, 0xff, 0x00, 0x00, 'P', 'I', 'N', 'G'};// "PING"; -const uint8_t PongMsg[] = { 0xff, 0xff, 0x00, 0x00, 'P', 'O', 'N', 'G'};// "PONG"; +const uint8_t PingMsg[] = { 'A', 'A', 'A', 'A', 'P', 'I', 'N', 'G'};// "PING"; +const uint8_t PongMsg[] = { 'B', 'B', 'B', 'B', 'P', 'O', 'N', 'G'};// "PONG"; uint16_t BufferSize = BUFFER_SIZE; uint8_t *Buffer; @@ -217,6 +218,8 @@ Radio->Rx( RX_TIMEOUT_VALUE ); + + HTU21D temphumid(PB_14, PB_13); //Temp humid sensor || SDA, SCL while( 1 ) { #ifdef TARGET_STM32L4 @@ -278,16 +281,20 @@ // Send the reply to the PING string memcpy(Buffer, PongMsg, sizeof(PongMsg)); // We fill the buffer with numbers for the payload - for( i = sizeof(PongMsg); i < BufferSize; i++ ) + int sample_ctemp = temphumid.sample_ctemp(); + printf("Temp = %d\n\r", sample_ctemp); + char data[BUFFER_SIZE -8]; + sprintf(data,"%d",sample_ctemp); + for( i = 0; i < sizeof(data); i++ ) { - Buffer[i] = i - sizeof(PongMsg); + Buffer[i+sizeof(PongMsg)] = data[i]; } wait_ms( 10 ); Radio->Send( Buffer, BufferSize ); } else // valid reception but not a PING as expected { // Set device as master and start again - isMaster = true; + //isMaster = true; Radio->Rx( RX_TIMEOUT_VALUE ); } }