DBG("Transmitting LoRa message of size "+String(sizeof(pkt))+" bytes with CRC 0x"+String(calcCRC,HEX)+" to LoRa MAC 0x"+String(*destMac,HEX));
//printLoraPacket(pkt,sizeof(pkt));
LoRa.beginPacket();
LoRa.write((uint8_t*)&pkt,sizeof(pkt));
LoRa.endPacket();
intstate=radio.startTransmit(pkt,sizeof(pkt));
if(state==RADIOLIB_ERR_NONE){
DBG(" begun successfully!");
}else{
DBG(" failed, code "+String(state));
while(true);
}
// LoRa.beginPacket();
// LoRa.write((uint8_t*)&pkt, sizeof(pkt));
// LoRa.endPacket();
}
#endif //USE_LORA
@ -98,28 +121,10 @@ void begin_lora() {
// #endif // USE_LORA
}
#if defined(ESP8266) || defined(ESP32)
ICACHE_RAM_ATTR
#endif
voidsetFlag(void){
// check if the interrupt is enabled
if(!enableInterrupt){
return;
}
// we got a packet, set the flag
receivedFlag=true;
}
voidparsePacket(){
RADIOLIB_MODULE.getPacketLength();
intstate=radio.readData(str);
}
crcResultgetLoRa(){
#ifdef USE_LORA
enableInterrupt=false;
receivedFlag=false;
intpacketSize=radio.getPacketLength();
if((((packetSize-6)%sizeof(DataReading)==0)||((packetSize-6)%sizeof(SystemPacket)==0))&&packetSize>0){// packet size should be 6 bytes plus multiple of size of DataReading