diff --git a/examples/drivers/windows/otLwf/command.c b/examples/drivers/windows/otLwf/command.c index 4feaf2ba1..099781b8b 100644 --- a/examples/drivers/windows/otLwf/command.c +++ b/examples/drivers/windows/otLwf/command.c @@ -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, diff --git a/examples/drivers/windows/otLwf/eventprocessing.c b/examples/drivers/windows/otLwf/eventprocessing.c index 9873b1f32..d53fee95a 100644 --- a/examples/drivers/windows/otLwf/eventprocessing.c +++ b/examples/drivers/windows/otLwf/eventprocessing.c @@ -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); } diff --git a/examples/drivers/windows/otLwf/radio.c b/examples/drivers/windows/otLwf/radio.c index a638a1bde..7e2379247 100644 --- a/examples/drivers/windows/otLwf/radio.c +++ b/examples/drivers/windows/otLwf/radio.c @@ -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; } diff --git a/src/core/api/link_raw_api.cpp b/src/core/api/link_raw_api.cpp index e8ec00de9..0ca4f6308 100644 --- a/src/core/api/link_raw_api.cpp +++ b/src/core/api/link_raw_api.cpp @@ -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); } } diff --git a/src/core/thread/mesh_forwarder.cpp b/src/core/thread/mesh_forwarder.cpp index 2af66c0a7..1fcc3eef6 100644 --- a/src/core/thread/mesh_forwarder.cpp +++ b/src/core/thread/mesh_forwarder.cpp @@ -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, ;);