Exemple #1
0
static void handleRx(void)
{
    if (sRxDone)
    {
        sRxDone = false;

        if (otPlatRadioGetPromiscuous(sInstance))
        {
            // Timestamp
            sReceiveFrame.mInfo.mRxInfo.mMsec = otPlatAlarmMilliGetNow();
            sReceiveFrame.mInfo.mRxInfo.mUsec = 0; // Don't support microsecond timer for now.
        }

#if OPENTHREAD_ENABLE_DIAG

        if (otPlatDiagModeGet())
        {
            otPlatDiagRadioReceiveDone(sInstance, &sReceiveFrame, OT_ERROR_NONE);
        }
        else
#endif
        {
            // signal MAC layer for each received frame if promiscous is enabled
            // otherwise only signal MAC layer for non-ACK frame
            if (sPromiscuous || sReceiveFrame.mLength > IEEE802154_ACK_LENGTH)
            {
                otLogDebgPlat(sInstance, "Radio receive done, rssi: %d", sReceiveFrame.mInfo.mRxInfo.mRssi);

                otPlatRadioReceiveDone(sInstance, &sReceiveFrame, OT_ERROR_NONE);
            }
        }
    }
}
Exemple #2
0
ThreadError otEnable(void)
{
    ThreadError error = kThreadError_None;

    // cannot enable the Thread stack if IEEE 802.15.4 promiscuous mode is enabled
    VerifyOrExit(otPlatRadioGetPromiscuous() == false, error = kThreadError_Busy);

    SuccessOrExit(error = sThreadNetif->Up());

exit:
    return error;
}
Exemple #3
0
void nrf_802154_received_raw(uint8_t *p_data, int8_t power, uint8_t lqi)
#endif
{
    otRadioFrame *receivedFrame = NULL;

    for (uint32_t i = 0; i < NRF_802154_RX_BUFFERS; i++)
    {
        if (sReceivedFrames[i].mPsdu == NULL)
        {
            receivedFrame = &sReceivedFrames[i];

            memset(receivedFrame, 0, sizeof(*receivedFrame));
#if OPENTHREAD_CONFIG_HEADER_IE_SUPPORT
            receivedFrame->mIeInfo = &sReceivedIeInfos[i];
#endif
            break;
        }
    }

    assert(receivedFrame != NULL);

    receivedFrame->mPsdu               = &p_data[1];
    receivedFrame->mLength             = p_data[0];
    receivedFrame->mInfo.mRxInfo.mRssi = power;
    receivedFrame->mInfo.mRxInfo.mLqi  = lqi;
    receivedFrame->mChannel            = nrf_802154_channel_get();
    if (otPlatRadioGetPromiscuous(sInstance))
    {
        uint64_t timestamp                 = nrf5AlarmGetCurrentTime();
        receivedFrame->mInfo.mRxInfo.mMsec = timestamp / US_PER_MS;
        receivedFrame->mInfo.mRxInfo.mUsec = timestamp - receivedFrame->mInfo.mRxInfo.mMsec * US_PER_MS;
    }
#if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC
    // Get the timestamp when the SFD was received.
    uint32_t offset =
        (int32_t)otPlatAlarmMicroGetNow() - (int32_t)nrf_802154_first_symbol_timestamp_get(time, p_data[0]);
    receivedFrame->mIeInfo->mTimestamp = otPlatTimeGet() - offset;
#endif

    otSysEventSignalPending();
}