Skip to content

Commit

Permalink
Restyled by clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits authored and pan-apple committed Aug 19, 2020
1 parent a5c13f9 commit f508a95
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion examples/wifi-echo/server/esp32/main/EchoServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ SecureSessionMgr<Transport::UDP, // IPV6

} // namespace

void PairingComplete(Optional<NodeId> peerNodeId, uint16_t peerKeyId, uint16_t localKeyId, SecurePairingSession* pairing)
void PairingComplete(Optional<NodeId> peerNodeId, uint16_t peerKeyId, uint16_t localKeyId, SecurePairingSession * pairing)
{
Optional<Transport::PeerAddress> peer(Transport::Type::kUndefined);
sessions.NewPairing(peerNodeId, peer, peerKeyId, localKeyId, pairing);
Expand Down
20 changes: 9 additions & 11 deletions examples/wifi-echo/server/esp32/main/RendezvousSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ bool RendezvousSession::mPairingInProgress = false;
SecurePairingSession RendezvousSession::mPairing;

static constexpr uint32_t kSpake2p_Iteration_Count = 50000;
static const char * kSpake2pKeyExchangeSalt = "SPAKE2P Key Exchange Salt";
static const char * kSpake2pKeyExchangeSalt = "SPAKE2P Key Exchange Salt";

extern void PairingComplete(Optional<NodeId> peerNodeId, uint16_t peerKeyId, uint16_t localKeyId, SecurePairingSession* pairing);
extern void PairingComplete(Optional<NodeId> peerNodeId, uint16_t peerKeyId, uint16_t localKeyId, SecurePairingSession * pairing);

RendezvousSession::RendezvousSession(BluetoothWidget * virtualLed, uint32_t setUpPINCode, NodeId myNodeId)
{
Expand All @@ -44,12 +44,11 @@ RendezvousSession::RendezvousSession(BluetoothWidget * virtualLed, uint32_t setU
DeviceLayer::ConnectivityMgr().AddCHIPoBLEConnectionHandler(HandleConnectionOpened);

RendezvousSession::mPairing.WaitForPairing(setUpPINCode, kSpake2p_Iteration_Count,
(const unsigned char*) kSpake2pKeyExchangeSalt,
strlen(kSpake2pKeyExchangeSalt),
Optional<NodeId>::Value(myNodeId), 0, this);
(const unsigned char *) kSpake2pKeyExchangeSalt, strlen(kSpake2pKeyExchangeSalt),
Optional<NodeId>::Value(myNodeId), 0, this);
RendezvousSession::mPairingInProgress = true;
mSetUpPINCode = setUpPINCode;
mNodeId = myNodeId;
mSetUpPINCode = setUpPINCode;
mNodeId = myNodeId;
}

CHIP_ERROR RendezvousSession::OnNewMessageForPeer(System::PacketBuffer * buffer)
Expand All @@ -68,16 +67,15 @@ void RendezvousSession::OnPairingError(CHIP_ERROR error)
ChipLogError(Ble, "RendezvousSession: failed in pairing");
mPaired = false;
RendezvousSession::mPairing.WaitForPairing(mSetUpPINCode, kSpake2p_Iteration_Count,
(const unsigned char*) kSpake2pKeyExchangeSalt,
strlen(kSpake2pKeyExchangeSalt),
Optional<NodeId>::Value(mNodeId), 0, this);
(const unsigned char *) kSpake2pKeyExchangeSalt, strlen(kSpake2pKeyExchangeSalt),
Optional<NodeId>::Value(mNodeId), 0, this);
RendezvousSession::mPairingInProgress = true;
}

void RendezvousSession::OnPairingComplete(Optional<NodeId> peerNodeId, uint16_t peerKeyId, uint16_t localKeyId)
{
ChipLogProgress(Ble, "RendezvousSession: pairing complete");
mPaired = true;
mPaired = true;
RendezvousSession::mPairingInProgress = false;
PairingComplete(peerNodeId, peerKeyId, localKeyId, &RendezvousSession::mPairing);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class RendezvousSession : public SecurePairingSessionDelegate
static SecurePairingSession mPairing;
static bool mPairingInProgress;

bool mPaired = false;
bool mPaired = false;
uint32_t mSetUpPINCode = 0;
NodeId mNodeId;
};
24 changes: 13 additions & 11 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace DeviceController {
using namespace chip::Encoding;

static constexpr uint32_t kSpake2p_Iteration_Count = 50000;
static const char * kSpake2pKeyExchangeSalt = "SPAKE2P Key Exchange Salt";
static const char * kSpake2pKeyExchangeSalt = "SPAKE2P Key Exchange Salt";

ChipDeviceController::ChipDeviceController()
{
Expand Down Expand Up @@ -172,20 +172,21 @@ void ChipDeviceController::OnPairingComplete(Optional<NodeId> peerNodeId, uint16

if (mPairingComplete != nullptr)
{
mPeerKeyId = peerKeyId;
mPeerKeyId = peerKeyId;
mLocalPairedKeyId = localKeyId;
ChipLogProgress(Controller, "Calling mPairingComplete");
mPairingComplete(this, nullptr, mAppReqState);
}
}

void ChipDeviceController::PairingMessageHandler(ChipDeviceController * controller, void * appReqState, System::PacketBuffer * payload)
void ChipDeviceController::PairingMessageHandler(ChipDeviceController * controller, void * appReqState,
System::PacketBuffer * payload)
{
if (controller->mPairingInProgress)
{
MessageHeader header;
size_t headerSize = 0;
CHIP_ERROR err = header.Decode(payload->Start(), payload->DataLength(), &headerSize);
CHIP_ERROR err = header.Decode(payload->Start(), payload->DataLength(), &headerSize);
SuccessOrExit(err);

payload->ConsumeHead(headerSize);
Expand All @@ -201,12 +202,13 @@ void ChipDeviceController::PairingMessageHandler(ChipDeviceController * controll
}

void ChipDeviceController::BLEConnectionHandler(ChipDeviceController * controller, Transport::PeerConnectionState * state,
void * appReqState)
void * appReqState)
{
ChipLogProgress(Controller, "Starting pairing session");
controller->mPairingInProgress = true;
CHIP_ERROR err = controller->mPairingSession.Pair(controller->mSetupPINCode, kSpake2p_Iteration_Count, (const unsigned char*) kSpake2pKeyExchangeSalt,
strlen(kSpake2pKeyExchangeSalt), Optional<NodeId>::Value(controller->mLocalDeviceId), controller->mNextKeyId++, controller);
CHIP_ERROR err = controller->mPairingSession.Pair(
controller->mSetupPINCode, kSpake2p_Iteration_Count, (const unsigned char *) kSpake2pKeyExchangeSalt,
strlen(kSpake2pKeyExchangeSalt), Optional<NodeId>::Value(controller->mLocalDeviceId), controller->mNextKeyId++, controller);
SuccessOrExit(err);

exit:
Expand Down Expand Up @@ -297,7 +299,9 @@ CHIP_ERROR ChipDeviceController::ConnectDevice(NodeId remoteDeviceId, IPAddress
mOnComplete.Response = onMessageReceived;
mOnError = onError;

err = mSessionManager->NewPairing(mRemoteDeviceId, Optional<Transport::PeerAddress>::Value(Transport::PeerAddress::UDP(deviceAddr, devicePort)), mPeerKeyId, mLocalPairedKeyId, &mPairingSession);
err = mSessionManager->NewPairing(mRemoteDeviceId,
Optional<Transport::PeerAddress>::Value(Transport::PeerAddress::UDP(deviceAddr, devicePort)),
mPeerKeyId, mLocalPairedKeyId, &mPairingSession);
SuccessOrExit(err);

mMessageNumber = 1;
Expand Down Expand Up @@ -433,9 +437,7 @@ void ChipDeviceController::ClearRequestState()
}
}

void ChipDeviceController::OnNewConnection(Transport::PeerConnectionState * state, SecureSessionMgrBase * mgr)
{
}
void ChipDeviceController::OnNewConnection(Transport::PeerConnectionState * state, SecureSessionMgrBase * mgr) {}

void ChipDeviceController::OnMessageReceived(const MessageHeader & header, Transport::PeerConnectionState * state,
System::PacketBuffer * msgBuf, SecureSessionMgrBase * mgr)
Expand Down
12 changes: 7 additions & 5 deletions src/controller/CHIPDeviceController.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ typedef void (*ErrorHandler)(ChipDeviceController * deviceController, void * app
typedef void (*MessageReceiveHandler)(ChipDeviceController * deviceController, void * appReqState, System::PacketBuffer * payload);
};

class DLL_EXPORT ChipDeviceController : public SecureSessionMgrCallback, public SecurePairingSessionDelegate, public Transport::BLECallbackHandler
class DLL_EXPORT ChipDeviceController : public SecureSessionMgrCallback,
public SecurePairingSessionDelegate,
public Transport::BLECallbackHandler
{
friend class ChipDeviceControllerCallback;

Expand Down Expand Up @@ -234,7 +236,7 @@ class DLL_EXPORT ChipDeviceController : public SecureSessionMgrCallback, public
ErrorHandler mOnError;
NewConnectionHandler mOnNewConnection;
NewConnectionHandler mPairingComplete = nullptr;
MessageReceiveHandler mAppMsgHandler = nullptr;
MessageReceiveHandler mAppMsgHandler = nullptr;
System::PacketBuffer * mCurReqMsg;

NodeId mLocalDeviceId;
Expand All @@ -244,11 +246,11 @@ class DLL_EXPORT ChipDeviceController : public SecureSessionMgrCallback, public
uint32_t mMessageNumber = 0;

SecurePairingSession mPairingSession;
uint16_t mNextKeyId = 0;
uint16_t mNextKeyId = 0;
bool mPairingInProgress = false;

uint32_t mSetupPINCode = 0;
uint16_t mPeerKeyId = 0;
uint32_t mSetupPINCode = 0;
uint16_t mPeerKeyId = 0;
uint16_t mLocalPairedKeyId = 0;

void ClearRequestState();
Expand Down
4 changes: 1 addition & 3 deletions src/controller/java/CHIPDeviceController-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,7 @@ void HandleSimpleOperationComplete(ChipDeviceController * deviceController, void
env->ExceptionClear();
}

void HandleKeyExchange(ChipDeviceController * deviceController, Transport::PeerConnectionState * state, void * appReqState)
{
}
void HandleKeyExchange(ChipDeviceController * deviceController, Transport::PeerConnectionState * state, void * appReqState) {}

void HandleEchoResponse(ChipDeviceController * deviceController, void * appReqState, System::PacketBuffer * payload)
{
Expand Down

0 comments on commit f508a95

Please sign in to comment.