Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/include/platform/CHIPDeviceEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@ enum PublicEventTypes
* Signals that BLE is deinitialized.
*/
kBLEDeinitialized,

/**
* Signals that secure session is established.
*/
kSecureSessionEstablished,
};

/**
Expand Down Expand Up @@ -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); }
Expand Down
15 changes: 15 additions & 0 deletions src/protocols/secure_channel/PairingSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#include <lib/core/CHIPConfig.h>
#include <lib/core/TLVTypes.h>
#include <lib/support/SafeInt.h>
#include <lib/support/TypeTraits.h>
#include <platform/CHIPDeviceEvent.h>
#include <platform/PlatformManager.h>
#include <transport/SessionManager.h>

namespace chip {
Expand Down Expand Up @@ -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;
Expand Down