diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.cpp index 72dbae2e2e0968..b8c1e3b0091bb3 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.cpp +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.cpp @@ -176,7 +176,7 @@ CHIP_ERROR convertJVideoPlayerToTargetVideoPlayerInfo(jobject videoPlayer, Targe if (MACAddress != nullptr) { - chip::CharSpan MACAddressSpan(MACAddress, strlen(MACAddress)); + chip::CharSpan MACAddressSpan(MACAddress, strlen(MACAddress) - 1); outTargetVideoPlayerInfo.SetMACAddress(MACAddressSpan); } @@ -248,7 +248,7 @@ CHIP_ERROR convertTargetVideoPlayerInfoToJVideoPlayer(TargetVideoPlayerInfo * ta jstring MACAddress = nullptr; if (targetVideoPlayerInfo->GetMACAddress() != nullptr && targetVideoPlayerInfo->GetMACAddress()->data() != nullptr) { - char MACAddressWithNil[2 * chip::DeviceLayer::ConfigurationManager::kPrimaryMACAddressLength + 1]; + char MACAddressWithNil[2 * chip::DeviceLayer::ConfigurationManager::kMaxMACAddressLength + 1]; strncpy(MACAddressWithNil, targetVideoPlayerInfo->GetMACAddress()->data(), targetVideoPlayerInfo->GetMACAddress()->size()); MACAddressWithNil[targetVideoPlayerInfo->GetMACAddress()->size()] = '\0'; diff --git a/examples/tv-casting-app/tv-casting-common/include/TargetVideoPlayerInfo.h b/examples/tv-casting-app/tv-casting-common/include/TargetVideoPlayerInfo.h index 21e2ba99971ba1..a3a453821524d1 100644 --- a/examples/tv-casting-app/tv-casting-common/include/TargetVideoPlayerInfo.h +++ b/examples/tv-casting-app/tv-casting-common/include/TargetVideoPlayerInfo.h @@ -194,7 +194,7 @@ class TargetVideoPlayerInfo uint16_t mPort; chip::Inet::IPAddress mIpAddress[chip::Dnssd::CommonResolutionData::kMaxIPAddresses]; chip::CharSpan mMACAddress; - char mMACAddressBuf[2 * chip::DeviceLayer::ConfigurationManager::kPrimaryMACAddressLength]; + char mMACAddressBuf[2 * chip::DeviceLayer::ConfigurationManager::kMaxMACAddressLength]; chip::System::Clock::Timestamp mLastDiscovered; bool mInitialized = false; }; diff --git a/examples/tv-casting-app/tv-casting-common/src/PersistenceManager.cpp b/examples/tv-casting-app/tv-casting-common/src/PersistenceManager.cpp index 1bbba194069ca3..98cae4c03791c8 100644 --- a/examples/tv-casting-app/tv-casting-common/src/PersistenceManager.cpp +++ b/examples/tv-casting-app/tv-casting-common/src/PersistenceManager.cpp @@ -111,6 +111,7 @@ CHIP_ERROR PersistenceManager::WriteAllVideoPlayers(TargetVideoPlayerInfo videoP tlvWriter.Put(TLV::ContextTag(kVideoPlayerLastDiscoveredTag), videoPlayer->GetLastDiscovered().count())); if (videoPlayer->GetMACAddress() != nullptr && videoPlayer->GetMACAddress()->size() > 0) { + ChipLogProgress(AppServer, "PersistenceManager::Write MAC Address Length %zu [%d]", videoPlayer->GetMACAddress()->size(), chip::DeviceLayer::ConfigurationManager::kMaxMACAddressLength); ReturnErrorOnFailure(tlvWriter.PutBytes(TLV::ContextTag(kVideoPlayerMACAddressTag), (const uint8_t *) videoPlayer->GetMACAddress()->data(), static_cast(videoPlayer->GetMACAddress()->size()))); @@ -227,7 +228,7 @@ CHIP_ERROR PersistenceManager::ReadAllVideoPlayers(TargetVideoPlayerInfo outVide size_t numIPs = 0; Inet::IPAddress ipAddress[chip::Dnssd::CommonResolutionData::kMaxIPAddresses]; uint64_t lastDiscoveredTicks = 0; - char MACAddressBuf[2 * chip::DeviceLayer::ConfigurationManager::kPrimaryMACAddressLength] = {}; + char MACAddressBuf[2 * chip::DeviceLayer::ConfigurationManager::kMaxMACAddressLength] = {}; uint32_t MACAddressLength = 0; char instanceName[chip::Dnssd::Commission::kInstanceNameMaxLength + 1] = {}; uint16_t port = 0; @@ -307,8 +308,9 @@ CHIP_ERROR PersistenceManager::ReadAllVideoPlayers(TargetVideoPlayerInfo outVide if (videoPlayersContainerTagNum == kVideoPlayerMACAddressTag) { MACAddressLength = reader.GetLength(); + ChipLogProgress(AppServer, "PersistenceManager::Read MAC Address Length %u [%d]", MACAddressLength, chip::DeviceLayer::ConfigurationManager::kMaxMACAddressLength); ReturnErrorOnFailure(reader.GetBytes(reinterpret_cast(MACAddressBuf), - 2 * chip::DeviceLayer::ConfigurationManager::kPrimaryMACAddressLength)); + 2 * chip::DeviceLayer::ConfigurationManager::kMaxMACAddressLength)); continue; }