based on their sender and receiver examples, you could try something like this
SENDER
// SENDER
#include "LoRaWan_APP.h"
#define RF_FREQUENCY 915000000 // Hz
#define TX_OUTPUT_POWER 5 // dBm
#define LORA_BANDWIDTH 0 // 0: 125 kHz,1: 250 kHz,2: 500 kHz, 3: Reserved
#define LORA_SPREADING_FACTOR 7 // SF7..SF12
#define LORA_CODINGRATE 1 // 1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8
#define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx
#define LORA_SYMBOL_TIMEOUT 0 // Symbols
#define LORA_FIX_LENGTH_PAYLOAD_ON false
#define LORA_IQ_INVERSION_ON false
struct Paylaod {
float temperature;
float humidity;
};
bool lora_idle = true;
static RadioEvents_t RadioEvents;
void OnTxDone() {
Serial.println("TX done......");
lora_idle = true;
}
void OnTxTimeout() {
Radio.Sleep( );
Serial.println("TX Timeout......");
lora_idle = true;
}
void setup() {
Serial.begin(115200);
Mcu.begin(HELTEC_BOARD, SLOW_CLK_TPYE);
RadioEvents.TxDone = OnTxDone;
RadioEvents.TxTimeout = OnTxTimeout;
Radio.Init( &RadioEvents );
Radio.SetChannel( RF_FREQUENCY );
Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,
LORA_SPREADING_FACTOR, LORA_CODINGRATE,
LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
true, 0, 0, LORA_IQ_INVERSION_ON, 3000 );
}
void loop() {
if (lora_idle) {
delay(1000);
Paylaod payload;
payload.temperature = random(-1000, 1000) / 10.0;
payload.humidity = random(0, 101) / 100.0;
Radio.Send( (uint8_t *)&payload, sizeof payload);
Serial.print("sending packet: temperature = ");
Serial.print(payload.temperature, 2);
Serial.print(" and humidity = ");
Serial.println(payload.humidity, 2);
lora_idle = false;
}
Radio.IrqProcess( );
}
RECEIVER
// RECEIVER
#include "LoRaWan_APP.h"
#define RF_FREQUENCY 915000000 // Hz
#define LORA_BANDWIDTH 0 // 0: 125 kHz,1: 250 kHz,2: 500 kHz, 3: Reserved
#define LORA_SPREADING_FACTOR 7 // SF7..SF12
#define LORA_CODINGRATE 1 // 1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8
#define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx
#define LORA_SYMBOL_TIMEOUT 0 // Symbols
#define LORA_FIX_LENGTH_PAYLOAD_ON false
#define LORA_IQ_INVERSION_ON false
struct Paylaod {
float temperature;
float humidity;
};
static RadioEvents_t RadioEvents;
bool lora_idle = true;
void OnRxDone( uint8_t *byteBuffer, uint16_t size, int16_t rssi, int8_t snr ) {
Paylaod payload;
if (size == sizof paylaod) {
memcpy(&payload, byteBuffer, size );
Serial.print("received packet: temperature = ");
Serial.print(payload.temperature, 2);
Serial.print(" and humidity = ");
Serial.println(payload.humidity, 2);
} else {
Serial.println("Wrong paylaod size");
}
Radio.Sleep( );
lora_idle = true;
}
void setup() {
Serial.begin(115200);
Mcu.begin(HELTEC_BOARD, SLOW_CLK_TPYE);
RadioEvents.RxDone = OnRxDone;
Radio.Init( &RadioEvents );
Radio.SetChannel( RF_FREQUENCY );
Radio.SetRxConfig( MODEM_LORA, LORA_BANDWIDTH, LORA_SPREADING_FACTOR,
LORA_CODINGRATE, 0, LORA_PREAMBLE_LENGTH,
LORA_SYMBOL_TIMEOUT, LORA_FIX_LENGTH_PAYLOAD_ON,
0, true, 0, 0, LORA_IQ_INVERSION_ON, true );
}
void loop() {
if (lora_idle) {
lora_idle = false;
Serial.println("into RX mode");
Radio.Rx(0);
}
Radio.IrqProcess();
}
I typed this here so I don't know if it compiles, mind typos.
The idea is to define a structure and send that structure over. as it's the same platform on both side, I assume the structure will be organised in the same way - you could add GCC attributes (packed, align) to the structure to force the layout in a more stringent way.
➜ give it a try