src/TheThingsNetwork.cpp
// Called by LMIC when an LMIC event (join, join failed, reset etc.) occurs
Called by LMIC when an LMIC event (join, join failed, reset etc.) occurs
Called by LMIC when an LMIC event ( join join failed reset etc . ) occurs
void eventCallback(void* userData, ev_t event)
{
    switch(event)
    {
        case EV_TXSTART:
            currentWindow = kTTNTxWindow;
            saveRFSettings(lastRfSettings[static_cast<int>(kTTNTxWindow)]);
            clearRFSettings(lastRfSettings[static_cast<int>(kTTNRx1Window)]);
            clearRFSettings(lastRfSettings[static_cast<int>(kTTNRx2Window)]);
            break;
        case EV_RXSTART:
            if (currentWindow != kTTNRx1Window)
            {
                currentWindow = kTTNRx1Window;
                saveRFSettings(lastRfSettings[static_cast<int>(kTTNRx1Window)]);
            }
            else
            {
                currentWindow = kTTNRx2Window;
                saveRFSettings(lastRfSettings[static_cast<int>(kTTNRx2Window)]);
            }
            break;
        default:
            currentWindow = kTTNIdleWindow;
            break;
    };
#if LMIC_ENABLE_event_logging
    logging->logEvent(event, eventNames[event], 0);
#elif CONFIG_LOG_DEFAULT_LEVEL >= 3
    ESP_LOGI(TAG, "event %s", eventNames[event]);
#endif
    TTNEvent ttnEvent = eEvtNone;
    if (waitingReason == eWaitingForJoin)
    {
        if (event == EV_JOINED)
        {
            ttnEvent = eEvtJoinCompleted;
        }
        else if (event == EV_REJOIN_FAILED || event == EV_RESET)
        {
            ttnEvent = eEvtJoinFailed;
        }
    }
    if (ttnEvent == eEvtNone)
        return;
    TTNLmicEvent result(ttnEvent);
    waitingReason = eWaitingNone;
    xQueueSend(lmicEventQueue, &result, pdMS_TO_TICKS(100));
}
void eventCallback ( void * userData , ev_t event ) { switch ( event ) { case EV_TXSTART : currentWindow = kTTNTxWindow ; saveRFSettings ( lastRfSettings [ static_cast < int > ( kTTNTxWindow ) ] ) ; clearRFSettings ( lastRfSettings [ static_cast < int > ( kTTNRx1Window ) ] ) ; clearRFSettings ( lastRfSettings [ static_cast < int > ( kTTNRx2Window ) ] ) ; break ; case EV_RXSTART : if ( currentWindow != kTTNRx1Window ) { currentWindow = kTTNRx1Window ; saveRFSettings ( lastRfSettings [ static_cast < int > ( kTTNRx1Window ) ] ) ; } else { currentWindow = kTTNRx2Window ; saveRFSettings ( lastRfSettings [ static_cast < int > ( kTTNRx2Window ) ] ) ; } break ; default : currentWindow = kTTNIdleWindow ; break ; } ; #if LMIC_ENABLE_event_logging logging -> logEvent ( event , eventNames [ event ] , 0 ) ; #elif CONFIG_LOG_DEFAULT_LEVEL >= 3 ESP_LOGI ( TAG , " " , eventNames [ event ] ) ; #endif TTNEvent ttnEvent = eEvtNone ; if ( waitingReason == eWaitingForJoin ) { if ( event == EV_JOINED ) { ttnEvent = eEvtJoinCompleted ; } else if ( event == EV_REJOIN_FAILED || event == EV_RESET ) { ttnEvent = eEvtJoinFailed ; } } if ( ttnEvent == eEvtNone ) return ; TTNLmicEvent result ( ttnEvent ) ; waitingReason = eWaitingNone ; xQueueSend ( lmicEventQueue , & result , pdMS_TO_TICKS ( 100 ) ) ; }
Called by LMIC when an LMIC event (join, join failed, reset etc.)
Called by LMIC when an LMIC event ( join join failed reset etc . )
// update monitoring information