У меня ESP32 и чип lora rn2903a. Я пытаюсь отправить 17 байтов с помощью библиотеки rn2xx3.h (https://github.com/jpmeijers/RN2483-Arduino-Library) Проблема в том, что когда я пытаюсь это сделать, он не работает с кодом 0
14:05:29.794 -> 064978CB0145000000000
14:05:29.827 -> 0
Часть что меня действительно понимает, так это то, что если я установлю строку: Serial.println(myLora.txBytes(txBuffer, 17));
на Serial.println(myLora.txBytes(txBuffer, 11));
Все работает отлично, также использование Serial.println(myLora.txBytes(txBuffer, sizeof(txBuffer));
, очевидно, не сработает, поскольку размер массива заполнит некоторое число более 11 .
Есть идеи? Кто-нибудь знает, как это исправить? Это работало раньше и работает с разными микроконтроллерами. Я здесь очень запутался.
#include <rn2xx3.h>
#define LORA_RESET 4
//create an instance of the rn2xx3 library,
//giving the software serial as port to use
rn2xx3 myLora(Serial2);
uint8_t txBuffer[17];
bool hasSensorValues = false;
// the setup routine runs once when you press reset:
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(115200); //serial port to computer
Serial2.begin(57600); //serial port to radio
Serial.println("Startup");
initialize_radio();
Serial.println("Radio Initialized Complete");
//transmit a startup message
myLora.tx("TTN Mapper on TTN Enschede node");
}
void initialize_radio()
{
//reset rn2483
pinMode(LORA_RESET, OUTPUT);
digitalWrite(LORA_RESET, LOW);
delay(100);
digitalWrite(LORA_RESET, HIGH);
delay(100); //wait for the RN2xx3's startup message
Serial2.flush();
//Autobaud the rn2483 module to 9600. The default would otherwise be 57600.
myLora.autobaud();
//check communication with radio
String hweui = myLora.hweui();
while(hweui.length() != 16)
{
Serial.println("Communication with RN2xx3 unsuccessful. Power cycle the board.");
Serial.println(hweui);
delay(1500);
hweui = myLora.hweui();
}
//print out the HWEUI so that we can register it via ttnctl
Serial.println("When using OTAA, register this DevEUI: ");
Serial.println(myLora.hweui());
Serial.println("RN2xx3 firmware version:");
Serial.println(myLora.sysver());
//configure your keys and join the network
Serial.println("Trying to join TTN");
bool join_result = false;
/*
* OTAA: initOTAA(String AppEUI, String AppKey);
* If you are using OTAA, paste the example code from the TTN console here:
*/
const char *appEui = "Omitted";
const char *appKey = "omitted also";
join_result = myLora.initOTAA(appEui, appKey);
while(!join_result)
{
Serial.println("Unable to join. Are your keys correct, and do you have TTN coverage?");
delay(2000);
join_result = myLora.init();
}
Serial.println("Successfully joined TTN");
}
// the loop routine runs over and over again forever:
void loop() {
if(hasSensorValues == true) {
for (int i = 0; i < sizeof(txBuffer); i++) {
Serial.print(txBuffer[i], HEX);
}
Serial.println("");
Serial.println(myLora.txBytes(txBuffer, 17));
hasSensorValues = false;
} else {
updateData();
}
delay(200);
}
...UpdateData omitted