mirror of
https://github.com/espressif/openthread.git
synced 2026-07-29 23:27:46 +00:00
otLwf Spinel and Logging Fixes (#1532)
* Fixes some Spinel usage in otLwf and some logging in the core library. * Undo cc2538 config logging change * Fix build error for nrf52840 with all logging enabled. * Update minor version check based off feedback
This commit is contained in:
@@ -61,6 +61,8 @@ otLwfCmdInitialize(
|
||||
{
|
||||
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
|
||||
NTSTATUS NtStatus = STATUS_SUCCESS;
|
||||
uint32_t MajorVersion = 0;
|
||||
uint32_t MinorVersion = 0;
|
||||
uint32_t InterfaceType = 0;
|
||||
|
||||
NET_BUFFER_LIST_POOL_PARAMETERS PoolParams =
|
||||
@@ -107,7 +109,7 @@ otLwfCmdInitialize(
|
||||
pFilter->cmdInitTryCount = 0;
|
||||
while (pFilter->cmdInitTryCount < 10)
|
||||
{
|
||||
NtStatus = otLwfCmdGetProp(pFilter, NULL, SPINEL_PROP_INTERFACE_TYPE, SPINEL_DATATYPE_UINT_PACKED_S, &InterfaceType);
|
||||
NtStatus = otLwfCmdGetProp(pFilter, NULL, SPINEL_PROP_PROTOCOL_VERSION, "ii", &MajorVersion, &MinorVersion);
|
||||
if (!NT_SUCCESS(NtStatus))
|
||||
{
|
||||
pFilter->cmdInitTryCount++;
|
||||
@@ -119,10 +121,27 @@ otLwfCmdInitialize(
|
||||
if (pFilter->cmdInitTryCount >= 10)
|
||||
{
|
||||
#else
|
||||
NtStatus = otLwfCmdGetProp(pFilter, NULL, SPINEL_PROP_INTERFACE_TYPE, SPINEL_DATATYPE_UINT_PACKED_S, &InterfaceType);
|
||||
NtStatus = otLwfCmdGetProp(pFilter, NULL, SPINEL_PROP_PROTOCOL_VERSION, "ii", &MajorVersion, &MinorVersion);
|
||||
if (!NT_SUCCESS(NtStatus))
|
||||
{
|
||||
#endif
|
||||
Status = NDIS_STATUS_NOT_SUPPORTED;
|
||||
LogError(DRIVER_DEFAULT, "Failed to query SPINEL_PROP_PROTOCOL_VERSION, %!STATUS!", NtStatus);
|
||||
break;
|
||||
}
|
||||
if (MajorVersion != SPINEL_PROTOCOL_VERSION_THREAD_MAJOR ||
|
||||
MinorVersion < 3) // TODO - Remove this minor version check with the next major version update
|
||||
{
|
||||
Status = NDIS_STATUS_NOT_SUPPORTED;
|
||||
LogError(DRIVER_DEFAULT, "Protocol Version Mismatch! OsVer: %d.%d DeviceVer: %d.%d",
|
||||
SPINEL_PROTOCOL_VERSION_THREAD_MAJOR, SPINEL_PROTOCOL_VERSION_THREAD_MINOR,
|
||||
MajorVersion, MinorVersion);
|
||||
break;
|
||||
}
|
||||
|
||||
NtStatus = otLwfCmdGetProp(pFilter, NULL, SPINEL_PROP_INTERFACE_TYPE, SPINEL_DATATYPE_UINT_PACKED_S, &InterfaceType);
|
||||
if (!NT_SUCCESS(NtStatus))
|
||||
{
|
||||
Status = NDIS_STATUS_NOT_SUPPORTED;
|
||||
LogError(DRIVER_DEFAULT, "Failed to query SPINEL_PROP_INTERFACE_TYPE, %!STATUS!", NtStatus);
|
||||
break;
|
||||
@@ -931,7 +950,9 @@ otLwfCmdSendMacFrameAsync(
|
||||
SPINEL_CMD_PROP_VALUE_SET,
|
||||
SPINEL_PROP_STREAM_RAW,
|
||||
Packet->mLength + 20,
|
||||
"DCc",
|
||||
SPINEL_DATATYPE_DATA_WLEN_S
|
||||
SPINEL_DATATYPE_UINT8_S
|
||||
SPINEL_DATATYPE_INT8_S,
|
||||
Packet->mPsdu,
|
||||
(uint32_t)Packet->mLength,
|
||||
Packet->mChannel,
|
||||
|
||||
@@ -1009,13 +1009,22 @@ otLwfEventWorkerThread(
|
||||
if (try_spinel_datatype_unpack(
|
||||
Event->Buffer + offset,
|
||||
length,
|
||||
"ccSiCC",
|
||||
SPINEL_DATATYPE_INT8_S
|
||||
SPINEL_DATATYPE_INT8_S
|
||||
SPINEL_DATATYPE_UINT16_S
|
||||
SPINEL_DATATYPE_STRUCT_S( // PHY-data
|
||||
SPINEL_DATATYPE_UINT8_S // 802.15.4 channel
|
||||
SPINEL_DATATYPE_UINT8_S // 802.15.4 LQI
|
||||
)
|
||||
SPINEL_DATATYPE_STRUCT_S( // Vendor-data
|
||||
SPINEL_DATATYPE_UINT_PACKED_S
|
||||
),
|
||||
&pFilter->otReceiveFrame.mPower,
|
||||
&noiseFloor,
|
||||
&flags,
|
||||
&errorCode,
|
||||
&pFilter->otReceiveFrame.mChannel,
|
||||
&pFilter->otReceiveFrame.mLqi))
|
||||
&pFilter->otReceiveFrame.mLqi,
|
||||
&errorCode))
|
||||
{
|
||||
otLwfRadioReceiveFrame(pFilter, errorCode);
|
||||
}
|
||||
|
||||
@@ -192,17 +192,20 @@ void otPlatRadioSetPanId(_In_ otInstance *otCtx, uint16_t panid)
|
||||
|
||||
pFilter->otPanID = panid;
|
||||
|
||||
// Indicate to the miniport
|
||||
status =
|
||||
otLwfCmdSetProp(
|
||||
pFilter,
|
||||
SPINEL_PROP_MAC_15_4_PANID,
|
||||
SPINEL_DATATYPE_UINT16_S,
|
||||
panid
|
||||
);
|
||||
if (!NT_SUCCESS(status))
|
||||
if (pFilter->otPhyState != kStateDisabled)
|
||||
{
|
||||
LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_15_4_PANID failed, %!STATUS!", status);
|
||||
// Indicate to the miniport
|
||||
status =
|
||||
otLwfCmdSetProp(
|
||||
pFilter,
|
||||
SPINEL_PROP_MAC_15_4_PANID,
|
||||
SPINEL_DATATYPE_UINT16_S,
|
||||
panid
|
||||
);
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_15_4_PANID failed, %!STATUS!", status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,17 +249,20 @@ void otPlatRadioSetShortAddress(_In_ otInstance *otCtx, uint16_t address)
|
||||
|
||||
pFilter->otShortAddress = address;
|
||||
|
||||
// Indicate to the miniport
|
||||
status =
|
||||
otLwfCmdSetProp(
|
||||
pFilter,
|
||||
SPINEL_PROP_MAC_15_4_SADDR,
|
||||
SPINEL_DATATYPE_UINT16_S,
|
||||
address
|
||||
);
|
||||
if (!NT_SUCCESS(status))
|
||||
if (pFilter->otPhyState != kStateDisabled)
|
||||
{
|
||||
LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_15_4_SADDR failed, %!STATUS!", status);
|
||||
// Indicate to the miniport
|
||||
status =
|
||||
otLwfCmdSetProp(
|
||||
pFilter,
|
||||
SPINEL_PROP_MAC_15_4_SADDR,
|
||||
SPINEL_DATATYPE_UINT16_S,
|
||||
address
|
||||
);
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_15_4_SADDR failed, %!STATUS!", status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,6 +321,32 @@ 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))
|
||||
{
|
||||
LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_15_4_PANID failed, %!STATUS!", status);
|
||||
}
|
||||
|
||||
// Indicate Short address to the miniport
|
||||
status =
|
||||
otLwfCmdSetProp(
|
||||
pFilter,
|
||||
SPINEL_PROP_MAC_15_4_SADDR,
|
||||
SPINEL_DATATYPE_UINT16_S,
|
||||
pFilter->otShortAddress
|
||||
);
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_15_4_SADDR failed, %!STATUS!", status);
|
||||
}
|
||||
|
||||
return NT_SUCCESS(status) ? kThreadError_None : kThreadError_Failed;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ ThreadError otLinkRawSetEnable(otInstance *aInstance, bool aEnabled)
|
||||
|
||||
VerifyOrExit(!aInstance->mThreadNetif.IsUp(), error = kThreadError_InvalidState);
|
||||
|
||||
otLogInfoPlat("LinkRaw Enabled=%d", aEnabled ? 1 : 0);
|
||||
otLogInfoPlat(aInstance, "LinkRaw Enabled=%d", aEnabled ? 1 : 0);
|
||||
|
||||
aInstance->mLinkRaw.SetEnabled(aEnabled);
|
||||
|
||||
@@ -113,7 +113,7 @@ ThreadError otLinkRawSetPromiscuous(otInstance *aInstance, bool aEnable)
|
||||
|
||||
VerifyOrExit(aInstance->mLinkRaw.IsEnabled(), error = kThreadError_InvalidState);
|
||||
|
||||
otLogInfoPlat("LinkRaw Promiscuous=%d", aEnable ? 1 : 0);
|
||||
otLogInfoPlat(aInstance, "LinkRaw Promiscuous=%d", aEnable ? 1 : 0);
|
||||
|
||||
otPlatRadioSetPromiscuous(aInstance, aEnable);
|
||||
|
||||
@@ -332,6 +332,7 @@ void LinkRaw::InvokeReceiveDone(RadioPacket *aPacket, ThreadError aError)
|
||||
{
|
||||
if (mReceiveDoneCallback)
|
||||
{
|
||||
otLogDebgPlat(&mInstance, "LinkRaw Invoke Receive Done");
|
||||
mReceiveDoneCallback(&mInstance, aPacket, aError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2286,8 +2286,7 @@ void MeshForwarder::LogIp6Message(MessageAction aAction, const Message &aMessage
|
||||
uint16_t checksum = 0;
|
||||
Ip6::Header ip6Header;
|
||||
Ip6::IpProto protocol;
|
||||
char stringBuffer[(Ip6::Address::kIp6AddressStringSize > Mac::Address::kAddressStringSize) ?
|
||||
Ip6::Address::kIp6AddressStringSize : Mac::Address::kAddressStringSize];
|
||||
char stringBuffer[Ip6::Address::kIp6AddressStringSize];
|
||||
|
||||
VerifyOrExit(aMessage.GetType() == Message::kTypeIp6, ;);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user