diff --git a/src/include/platform/CHIPDeviceEvent.h b/src/include/platform/CHIPDeviceEvent.h index 67809adda04c73..437b20e670284f 100644 --- a/src/include/platform/CHIPDeviceEvent.h +++ b/src/include/platform/CHIPDeviceEvent.h @@ -250,6 +250,11 @@ enum PublicEventTypes * Signals that BLE is deinitialized. */ kBLEDeinitialized, + + /** + * Signals that secure session is established. + */ + kSecureSessionEstablished, }; /** @@ -533,6 +538,15 @@ struct ChipDeviceEvent final { OtaState newState; } OtaStateChanged; + + struct + { + uint64_t PeerNodeId; + uint8_t FabricIndex; + uint8_t SecureSessionType; + uint8_t TransportType; + uint16_t LocalSessionId; + } SecureSessionEstablished; }; bool IsPublic() const { return DeviceEventType::IsPublic(Type); } diff --git a/src/protocols/secure_channel/PairingSession.cpp b/src/protocols/secure_channel/PairingSession.cpp index ae4ca272858a78..6176d097c5118a 100644 --- a/src/protocols/secure_channel/PairingSession.cpp +++ b/src/protocols/secure_channel/PairingSession.cpp @@ -22,6 +22,9 @@ #include #include #include +#include +#include +#include #include namespace chip { @@ -78,6 +81,18 @@ void PairingSession::Finish() if (err == CHIP_NO_ERROR) { VerifyOrDie(mSecureSessionHolder); + DeviceLayer::ChipDeviceEvent event; + event.Type = DeviceLayer::DeviceEventType::kSecureSessionEstablished; + event.SecureSessionEstablished.TransportType = to_underlying(address.GetTransportType()); + event.SecureSessionEstablished.SecureSessionType = + to_underlying(mSecureSessionHolder->AsSecureSession()->GetSecureSessionType()); + event.SecureSessionEstablished.LocalSessionId = mSecureSessionHolder->AsSecureSession()->GetLocalSessionId(); + event.SecureSessionEstablished.PeerNodeId = mSecureSessionHolder->GetPeer().GetNodeId(); + event.SecureSessionEstablished.FabricIndex = mSecureSessionHolder->GetPeer().GetFabricIndex(); + if (DeviceLayer::PlatformMgr().PostEvent(&event) != CHIP_NO_ERROR) + { + ChipLogError(SecureChannel, "Failed to post Secure Session established event"); + } // Make sure to null out mDelegate so we don't send it any other // notifications. auto * delegate = mDelegate;