Modified the main app to make use of the LoRa transceiver. Added the mailbox TEST event and some debugging traces when traces are enabled

This commit is contained in:
Th3maz1ng 2025-12-26 12:31:37 +01:00
parent e1d67b9b7a
commit d090887342

View File

@ -52,42 +52,38 @@ void loop()
#if SERIAL_DEBUG_ENABLED #if SERIAL_DEBUG_ENABLED
Serial.print("MBP Ext Peripheral : "); Serial.println(rCode); Serial.print("MBP Ext Peripheral : "); Serial.println(rCode);
debugStruct(&payload); debugStruct(&payload);
uint8_t buffer[32];
memset(buffer, 0xFF, sizeof buffer);
memcpy(buffer, &payload, sizeof payload);
for(size_t i = 0; i < sizeof buffer; i++)
{
Serial.print('[');Serial.print(i);Serial.print("]=0x");Serial.println(buffer[i], HEX);
}
#endif #endif
if(MBP.getRadio().isChipConnected()) if(rCode)
{ {
MBP.applyRadioConfig(); MBP.applyRadioConfig();
MBP.getRadio().setRetries(15, 15);
MBP.getRadio().openWritingPipe((const uint8_t *)RADIO_NODE_ADDRESS);
MBP.getRadio().stopListening(); //Very important, if not called, no ack will be received !
for(uint8_t i(0); i < MAX_SEND_ROUND_RETRIES; i++) for(uint8_t i(0); i < MAX_SEND_ROUND_RETRIES; i++)
{ {
if(MBP.getRadio().write(&payload, sizeof payload)) MBP.getRadio().beginPacket();
{ MBP.getRadio().write(reinterpret_cast<uint8_t *>(&payload), sizeof payload);
#if SERIAL_DEBUG_ENABLED MBP.getRadio().endPacket();
Serial.println("Payload sent !");
delay(100);
#endif
break;
}
#if SERIAL_DEBUG_ENABLED #if SERIAL_DEBUG_ENABLED
else Serial.print("Sending frame: ");Serial.println(i);
{ delay(100);
Serial.println("Failed to send payload !");
delay(100);
}
#endif #endif
} }
} }
#if SERIAL_DEBUG_ENABLED #if SERIAL_DEBUG_ENABLED
else else
{ {
Serial.println("NRF missing !"); Serial.println("RFM95W missing !");
delay(100); delay(100);
} }
#endif #endif
MBP.deinitExternalPeripherals();
MBP.externalPeripherals(MBPeripherals::State::OFF); MBP.externalPeripherals(MBPeripherals::State::OFF);
//We wait for some time before allowing next trigger //We wait for some time before allowing next trigger
@ -133,6 +129,9 @@ void debugStruct(MailboxDataPacket *p)
case MAILBOX_COLLECTED: case MAILBOX_COLLECTED:
Serial.println("COLLECTED"); Serial.println("COLLECTED");
break; break;
case MAILBOX_TEST:
Serial.println("TEST");
break;
default: default:
Serial.println("UNKNOWN"); Serial.println("UNKNOWN");
break; break;