Skip to content

Commit

Permalink
Add custom event handler for MCCI LMIC
Browse files Browse the repository at this point in the history
  • Loading branch information
lnlp committed May 16, 2021
1 parent bbe3111 commit 7f13b52
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/LMIC-node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,10 +520,20 @@ void initLmic(bit_t adrEnabled = 1,
serial.println(")");
#endif
#endif

#ifdef MCCI_LMIC
// Register a custom eventhandler and don't use default onEvent() to enable
// additional features (e.g. make EV_RXSTART available). User data pointer is omitted.
LMIC_registerEventCb(&onLmicEvent, nullptr);
#endif
}


#ifdef MCCI_LMIC
void onLmicEvent(void *pUserData, ev_t ev)
#else
void onEvent(ev_t ev)
#endif
{
// LMIC event handler
ostime_t timestamp = os_getTime();
Expand Down
1 change: 1 addition & 0 deletions src/LMIC-node.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ enum class PrintTarget { All, Serial, Display };
// Forward declarations
void processWork(ostime_t timestamp);
void processDownlink(ostime_t eventTimestamp, uint8_t fPort, uint8_t* data, uint8_t dataLength);
void onLmicEvent(void *pUserData, ev_t ev);
void displayTxSymbol(bool visible);

#ifndef DO_WORK_INTERVAL_SECONDS // Should be set in platformio.ini
Expand Down

0 comments on commit 7f13b52

Please sign in to comment.