Skip to content

Commit 4ea2094

Browse files
committed
Post SecureSessionEstablished event when secure session is established
1 parent 7c04979 commit 4ea2094

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/include/platform/CHIPDeviceEvent.h

+13
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ enum PublicEventTypes
250250
* Signals that BLE is deinitialized.
251251
*/
252252
kBLEDeinitialized,
253+
254+
/**
255+
* Signals that secure session is established.
256+
*/
257+
kSecureSessionEstablished,
253258
};
254259

255260
/**
@@ -533,6 +538,14 @@ struct ChipDeviceEvent final
533538
{
534539
OtaState newState;
535540
} OtaStateChanged;
541+
542+
struct
543+
{
544+
uint64_t PeerNodeId;
545+
uint8_t FabricIndex;
546+
uint8_t SecureSessionType;
547+
uint8_t TransportType;
548+
} SecureSessionEstablished;
536549
};
537550

538551
bool IsPublic() const { return DeviceEventType::IsPublic(Type); }

src/protocols/secure_channel/PairingSession.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
#include <lib/core/CHIPConfig.h>
2323
#include <lib/core/TLVTypes.h>
2424
#include <lib/support/SafeInt.h>
25+
#include <lib/support/TypeTraits.h>
26+
#include <platform/CHIPDeviceEvent.h>
27+
#include <platform/PlatformManager.h>
2528
#include <transport/SessionManager.h>
2629

2730
namespace chip {
@@ -78,6 +81,20 @@ void PairingSession::Finish()
7881
if (err == CHIP_NO_ERROR)
7982
{
8083
VerifyOrDie(mSecureSessionHolder);
84+
DeviceLayer::ChipDeviceEvent event;
85+
event.Type = DeviceLayer::DeviceEventType::kSecureSessionEstablished;
86+
event.SecureSessionEstablished.TransportType = to_underlying(address.GetTransportType());
87+
event.SecureSessionEstablished.SecureSessionType =
88+
to_underlying(mSecureSessionHolder->AsSecureSession()->GetSecureSessionType());
89+
if (mSecureSessionHolder->AsSecureSession()->GetSecureSessionType() == Transport::SecureSession::Type::kCASE)
90+
{
91+
event.SecureSessionEstablished.PeerNodeId = mSecureSessionHolder->GetPeer().GetNodeId();
92+
event.SecureSessionEstablished.FabricIndex = mSecureSessionHolder->GetPeer().GetFabricIndex();
93+
}
94+
if (DeviceLayer::PlatformMgr().PostEvent(&event) != CHIP_NO_ERROR)
95+
{
96+
ChipLogError(SecureChannel, "Failed to post Secure Session established event");
97+
}
8198
// Make sure to null out mDelegate so we don't send it any other
8299
// notifications.
83100
auto * delegate = mDelegate;

0 commit comments

Comments
 (0)