Logging and Raw Link Layer Cleanup (#1541)

* Logging and Raw Link Layer Cleanup

* make pretty
This commit is contained in:
Nick Banks
2017-03-31 08:52:54 -07:00
committed by Jonathan Hui
parent c05830179b
commit 8951a336fe
4 changed files with 41 additions and 27 deletions
+15 -11
View File
@@ -192,7 +192,8 @@ void otPlatRadioSetPanId(_In_ otInstance *otCtx, uint16_t panid)
pFilter->otPanID = panid;
if (pFilter->otPhyState != kStateDisabled)
if (pFilter->otPhyState != kStateDisabled &&
pFilter->otPanID != 0xFFFF)
{
// Indicate to the miniport
status =
@@ -321,17 +322,20 @@ ThreadError otPlatRadioEnable(_In_ otInstance *otCtx)
LogInfo(DRIVER_DEFAULT, "Filter %p PhyState = kStateSleep.", pFilter);
// Indicate PANID to the miniport
status =
otLwfCmdSetProp(
pFilter,
SPINEL_PROP_MAC_15_4_PANID,
SPINEL_DATATYPE_UINT16_S,
pFilter->otPanID
);
if (!NT_SUCCESS(status))
if (pFilter->otPanID != 0xFFFF)
{
LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_15_4_PANID failed, %!STATUS!", status);
// Indicate PANID to the miniport
status =
otLwfCmdSetProp(
pFilter,
SPINEL_PROP_MAC_15_4_PANID,
SPINEL_DATATYPE_UINT16_S,
pFilter->otPanID
);
if (!NT_SUCCESS(status))
{
LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_15_4_PANID failed, %!STATUS!", status);
}
}
// Indicate Short address to the miniport
+1 -1
View File
@@ -112,6 +112,7 @@ private:
otInstance &mInstance;
bool mEnabled;
uint8_t mReceiveChannel;
otLinkRawReceiveDone mReceiveDoneCallback;
otLinkRawTransmitDone mTransmitDoneCallback;
otLinkRawEnergyScanDone mEnergyScanDoneCallback;
@@ -130,7 +131,6 @@ private:
Timer mTimer;
TimerReason mTimerReason;
uint8_t mReceiveChannel;
static void HandleTimer(void *aContext);
void HandleTimer(void);
+25 -11
View File
@@ -127,7 +127,7 @@ ThreadError otLinkRawSleep(otInstance *aInstance)
VerifyOrExit(aInstance->mLinkRaw.IsEnabled(), error = kThreadError_InvalidState);
otLogDebgPlat(aInstance, "LinkRaw Sleep");
otLogInfoPlat(aInstance, "LinkRaw Sleep");
error = otPlatRadioSleep(aInstance);
@@ -137,7 +137,7 @@ exit:
ThreadError otLinkRawReceive(otInstance *aInstance, uint8_t aChannel, otLinkRawReceiveDone aCallback)
{
otLogDebgPlat(aInstance, "LinkRaw Recv (Channel %d)", aChannel);
otLogInfoPlat(aInstance, "LinkRaw Recv (Channel %d)", aChannel);
return aInstance->mLinkRaw.Receive(aChannel, aCallback);
}
@@ -155,7 +155,7 @@ exit:
ThreadError otLinkRawTransmit(otInstance *aInstance, RadioPacket *aPacket, otLinkRawTransmitDone aCallback)
{
otLogDebgPlat(aInstance, "LinkRaw Transmit (%d bytes)", aPacket->mLength);
otLogInfoPlat(aInstance, "LinkRaw Transmit (%d bytes on channel %d)", aPacket->mLength, aPacket->mChannel);
return aInstance->mLinkRaw.Transmit(aPacket, aCallback);
}
@@ -268,13 +268,13 @@ namespace Thread {
LinkRaw::LinkRaw(otInstance &aInstance):
mInstance(aInstance),
mEnabled(false),
mReceiveChannel(OPENTHREAD_CONFIG_DEFAULT_CHANNEL),
mReceiveDoneCallback(NULL),
mTransmitDoneCallback(NULL),
mEnergyScanDoneCallback(NULL)
#if OPENTHREAD_LINKRAW_TIMER_REQUIRED
, mTimer(aInstance.mIp6.mTimerScheduler, &LinkRaw::HandleTimer, this)
, mTimerReason(kTimerReasonNone)
, mReceiveChannel(OPENTHREAD_CONFIG_DEFAULT_CHANNEL)
#endif // OPENTHREAD_LINKRAW_TIMER_REQUIRED
#if OPENTHREAD_CONFIG_ENABLE_SOFTWARE_ENERGY_SCAN
, mEnergyScanTask(aInstance.mIp6.mTaskletScheduler, &LinkRaw::HandleEnergyScanTask, this)
@@ -315,12 +315,7 @@ ThreadError LinkRaw::Receive(uint8_t aChannel, otLinkRawReceiveDone aCallback)
if (mEnabled)
{
#if OPENTHREAD_LINKRAW_TIMER_REQUIRED
// Only need to cache if we implement timer logic that might
// revert the channel on completion.
mReceiveChannel = aChannel;
#endif
mReceiveDoneCallback = aCallback;
error = otPlatRadioReceive(&mInstance, aChannel);
}
@@ -332,7 +327,15 @@ void LinkRaw::InvokeReceiveDone(RadioPacket *aPacket, ThreadError aError)
{
if (mReceiveDoneCallback)
{
otLogDebgPlat(&mInstance, "LinkRaw Invoke Receive Done");
if (aError == kThreadError_None)
{
otLogInfoPlat(&mInstance, "LinkRaw Invoke Receive Done (%d bytes)", aPacket->mLength);
}
else
{
otLogWarnPlat(&mInstance, "LinkRaw Invoke Receive Done (err=0x%x)", aError);
}
mReceiveDoneCallback(&mInstance, aPacket, aError);
}
}
@@ -418,9 +421,20 @@ void LinkRaw::InvokeTransmitDone(RadioPacket *aPacket, bool aFramePending, Threa
#endif
// Transition back to receive state on previous channel
otPlatRadioReceive(&mInstance, mReceiveChannel);
if (mTransmitDoneCallback)
{
otLogDebgPlat(aInstance, "LinkRaw Invoke Transmit Done");
if (aError == kThreadError_None)
{
otLogInfoPlat(aInstance, "LinkRaw Invoke Transmit Done");
}
else
{
otLogWarnPlat(aInstance, "LinkRaw Invoke Transmit Failed (err=0x%x)", aError);
}
mTransmitDoneCallback(&mInstance, aPacket, aFramePending, aError);
mTransmitDoneCallback = NULL;
}
-4
View File
@@ -932,10 +932,6 @@ void NcpBase::LinkRawTransmitDone(RadioPacket *, bool aFramePending, ThreadError
// Clear cached transmit TID
mCurTransmitTID = 0;
}
// Make sure we are back listening on the original receive channel,
// since the transmit could have been on a different channel.
otLinkRawReceive(mInstance, mCurReceiveChannel, &NcpBase::LinkRawReceiveDone);
}
void NcpBase::LinkRawEnergyScanDone(otInstance *, int8_t aEnergyScanMaxRssi)