Update RadioLib

This commit is contained in:
lewisxhe
2024-09-19 11:12:36 +08:00
parent 210367a171
commit 5794daa8aa
301 changed files with 115546 additions and 12703 deletions
@@ -65,7 +65,7 @@ void setup() {
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while (true);
while (true) { delay(10); }
}
// set the function that will be called
@@ -80,17 +80,17 @@ void setup() {
transmissionState = radio.startTransmit(longPacket);
}
// flag to indicate that a packet was sent
volatile bool transmittedFlag = false;
// flag to indicate we can keep adding more bytes to FIFO
volatile bool fifoEmpty = false;
// disable interrupt when it's not needed
volatile bool enableInterrupt = true;
// flag to indicate that a packet was sent
bool transmittedFlag = false;
// how many bytes are there in total
volatile int totalLength = longPacket.length();
int totalLength = longPacket.length();
// counter to keep track of how many bytes still need to be sent
volatile int remLength = totalLength;
int remLength = totalLength;
// this function is called when the radio transmit buffer
// is empty and ready to be refilled
@@ -100,23 +100,22 @@ volatile int remLength = totalLength;
ICACHE_RAM_ATTR
#endif
void fifoAdd(void) {
// check if the interrupt is enabled
if(!enableInterrupt) {
return;
}
// add more bytes to the transmit buffer
uint8_t* txBuffPtr = (uint8_t*)longPacket.c_str();
transmittedFlag = radio.fifoAdd(txBuffPtr, totalLength, &remLength);
// we can send more bytes
fifoEmpty = true;
}
void loop() {
if(fifoEmpty) {
// reset flag
fifoEmpty = false;
// add more bytes to the transmit buffer
uint8_t* txBuffPtr = (uint8_t*)longPacket.c_str();
transmittedFlag = radio.fifoAdd(txBuffPtr, totalLength, &remLength);
}
// check if the previous transmission finished
if(transmittedFlag) {
// disable the interrupt service routine while
// processing the data
enableInterrupt = false;
// reset flag
transmittedFlag = false;
@@ -148,9 +147,5 @@ void loop() {
// send another one
Serial.print(F("[SX1278] Sending another long packet ... "));
transmissionState = radio.startTransmit(longPacket);
// we're ready to send more packets,
// enable interrupt service routine
enableInterrupt = true;
}
}