See the mDot at firmware for an example of setting up custom event handlers.
https://os.mbed.com/teams/MultiTech/code/Dot-AT-Firmware/?platform=MTS-mDot-F411
Using the setEvents function a custom event handler can be provided to the dot library.
CommandTerminal.h and CommandTerminal.cpp define a RadioEvent object inheriting the mDotEvent Class.
Be sure to call the base class functionality to fill the packet _flags and _info objects of the mDotEvent.
CommandTerminal.h
class RadioEvent : public mDotEvent { ...
CommandTerminal.cpp
void CommandTerminal::init() {
_dot->setEvents(_events);
}
void CommandTerminal::RadioEvent::PacketRx(uint8_t port, uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr, lora::DownlinkControl ctrl, uint8_t slot, uint8_t retries) {
mDotEvent::PacketRx(port, payload, size, rssi, snr, ctrl, retries);
if (serial_data_mode) {
logDebug("Rx %d bytes", size);
if (size > 0) {
CommandTerminal::Serial()->write((char*) RxPayload, RxPayloadSize);
}
if (!CommandTerminal::Serial()->readable() && _dot->getAckRequested() && _dot->getClass() == "C") {
_sendAck = true;
}
}
}