Update RadioLib to V6.0.0

This commit is contained in:
lewishe 2023-05-12 11:27:13 +08:00
commit 04f65f1392
166 changed files with 15126 additions and 10136 deletions

View file

@ -86,9 +86,6 @@ void setup() {
// flag to indicate that a packet was received
volatile bool receivedFlag = false;
// disable interrupt when it's not needed
volatile bool enableInterrupt = true;
// how many bytes are there in total
const int totalLength = 512;
@ -106,11 +103,6 @@ volatile uint8_t rxBuffer[totalLength + 1];
ICACHE_RAM_ATTR
#endif
void fifoGet(void) {
// check if the interrupt is enabled
if(!enableInterrupt) {
return;
}
// set the flag when we receive the full packet
receivedFlag = radio.fifoGet(rxBuffer, totalLength, &receivedLength);
}
@ -118,10 +110,6 @@ void fifoGet(void) {
void loop() {
// check if the flag is set
if(receivedFlag) {
// disable the interrupt service routine while
// processing the data
enableInterrupt = false;
// packet was successfully received
Serial.println(F("[SX1278] Received packet!"));
@ -135,10 +123,5 @@ void loop() {
// put module back to listen mode
radio.startReceive();
// we're ready to receive more packets,
// enable interrupt service routine
enableInterrupt = true;
}
}

View file

@ -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;
}
}