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 nivi-apple committed Sep 24, 2024
1 parent 0a5f615 commit d344a19
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 37 deletions.
6 changes: 3 additions & 3 deletions src/darwin/Framework/CHIP/MTROTAImageTransferHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class MTROTAImageTransferHandler : public chip::bdx::AsyncResponder
chip::System::PacketBufferHandle && payload) override;

private:
CHIP_ERROR PrepareForTransfer(chip::System::Layer * layer, chip::Messaging::ExchangeContext * exchangeCtx, chip::FabricIndex fabricIndex,
chip::NodeId nodeId);
CHIP_ERROR PrepareForTransfer(chip::System::Layer * layer, chip::Messaging::ExchangeContext * exchangeCtx,
chip::FabricIndex fabricIndex, chip::NodeId nodeId);

CHIP_ERROR ConfigureState(chip::FabricIndex fabricIndex, chip::NodeId nodeId);

Expand All @@ -67,7 +67,7 @@ class MTROTAImageTransferHandler : public chip::bdx::AsyncResponder

// The OTA provider delegate used by the controller.
id<MTROTAProviderDelegate> mDelegate = nil;
chip::System::Layer * mSystemLayer = nil;
chip::System::Layer * mSystemLayer = nil;

// The OTA provider delegate queue used by the controller.
dispatch_queue_t mDelegateNotificationQueue = nil;
Expand Down
5 changes: 2 additions & 3 deletions src/darwin/Framework/CHIP/MTROTAImageTransferHandler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
MTROTAUnsolicitedBDXMessageHandler::DecrementNumberOfDelegates();
}


CHIP_ERROR MTROTAImageTransferHandler::OnTransferSessionBegin(TransferSession::OutputEvent & event)
{
assertChipStackLockedByCurrentThread();
Expand Down Expand Up @@ -291,8 +290,8 @@
case TransferSession::OutputEventType::kQueryReceived:
err = OnBlockQuery(event);
if (err != CHIP_NO_ERROR) {
LogErrorOnFailure(err);
AsyncResponder::NotifyEventHandled(event, err);
LogErrorOnFailure(err);
AsyncResponder::NotifyEventHandled(event, err);
}
break;
case TransferSession::OutputEventType::kNone:
Expand Down
3 changes: 1 addition & 2 deletions src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
#include <MTRError_Internal.h>
#include <messaging/ExchangeMgr.h>
#include <platform/LockTracker.h>
#include <protocols/bdx/BdxUri.h>
#include <protocols/bdx/AsyncTransferFacilitator.h>
#include <protocols/bdx/BdxUri.h>

using namespace chip;
using namespace chip::app;
Expand Down Expand Up @@ -93,7 +93,6 @@
mOtaUnsolicitedBDXMsgHandler.ControllerShuttingDown(controller);
}


namespace {
// Return false if we could not get peer node info (a running controller for
// the fabric and a node id). In that case we will have already added an
Expand Down
15 changes: 8 additions & 7 deletions src/darwin/Framework/CHIP/MTROTAUnsolicitedBDXMessageHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ NS_ASSUME_NONNULL_BEGIN
* returns CHIP_ERROR_INCORRECT_STATE.
*
*/
class MTROTAUnsolicitedBDXMessageHandler : public chip::Messaging::UnsolicitedMessageHandler
{
class MTROTAUnsolicitedBDXMessageHandler : public chip::Messaging::UnsolicitedMessageHandler {
public:
MTROTAUnsolicitedBDXMessageHandler() : mExchangeMgr(nullptr) {}
MTROTAUnsolicitedBDXMessageHandler()
: mExchangeMgr(nullptr)
{
}
~MTROTAUnsolicitedBDXMessageHandler() { mExchangeMgr = nullptr; }

CHIP_ERROR Init(chip::Messaging::ExchangeManager * exchangeManager);
Expand All @@ -50,14 +52,13 @@ class MTROTAUnsolicitedBDXMessageHandler : public chip::Messaging::UnsolicitedMe
// Decrease the number of delegates handling BDX transfers by 1.
static void DecrementNumberOfDelegates();

void Shutdown();
void Shutdown();

void ControllerShuttingDown(MTRDeviceController * controller);
void ControllerShuttingDown(MTRDeviceController * controller);

private:

CHIP_ERROR OnUnsolicitedMessageReceived(const chip::PayloadHeader & payloadHeader, const chip::SessionHandle & session,
chip::Messaging::ExchangeDelegate * _Nonnull & newDelegate) override;
chip::Messaging::ExchangeDelegate * _Nonnull & newDelegate) override;

void OnExchangeCreationFailed(chip::Messaging::ExchangeDelegate * _Nonnull delegate) override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
}

CHIP_ERROR MTROTAUnsolicitedBDXMessageHandler::OnUnsolicitedMessageReceived(const PayloadHeader & payloadHeader, const SessionHandle & session,
ExchangeDelegate * _Nonnull & newDelegate)
ExchangeDelegate * _Nonnull & newDelegate)
{
assertChipStackLockedByCurrentThread();

Expand All @@ -65,14 +65,12 @@

VerifyOrReturnError(mExchangeMgr != nullptr, CHIP_ERROR_INCORRECT_STATE);

if (GetNumberOfDelegates() >= 1)
{
if (GetNumberOfDelegates() >= 1) {
return CHIP_ERROR_BUSY;
}

// Only proceed if there is a valid fabric index for the SessionHandle.
if (session->IsSecureSession() && session->AsSecureSession() != nullptr && session->AsSecureSession()->GetFabricIndex() != kUndefinedFabricIndex)
{
if (session->IsSecureSession() && session->AsSecureSession() != nullptr && session->AsSecureSession()->GetFabricIndex() != kUndefinedFabricIndex) {
// If we receive a ReceiveInit BDX message, create a new MTROTAImageTransferHandler and register it
// as the handler for all BDX messages that will come over this exchange and increment the number of delegates.
if (payloadHeader.HasMessageType(MessageType::ReceiveInit)) {
Expand Down
20 changes: 10 additions & 10 deletions src/protocols/bdx/AsyncTransferFacilitator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ void AsyncTransferFacilitator::CleanUp()
this);
}

AsyncTransferFacilitator::~AsyncTransferFacilitator()
{
}
AsyncTransferFacilitator::~AsyncTransferFacilitator() {}

bdx::StatusCode AsyncTransferFacilitator::GetBdxStatusCodeFromChipError(CHIP_ERROR err)
{
Expand All @@ -57,9 +55,10 @@ bdx::StatusCode AsyncTransferFacilitator::GetBdxStatusCodeFromChipError(CHIP_ERR
}

/**
* Calls the GetNextAction on the TransferSession to get the next output events until it receives TransferSession::OutputEventType::kNone
* If the output event is of type TransferSession::OutputEventType::kMsgToSend, it sends the message over the exchange context, otherwise it
* calls the HandleTransferSessionOutput method implemented by the subclass to handle the BDX message.
* Calls the GetNextAction on the TransferSession to get the next output events until it receives
* TransferSession::OutputEventType::kNone If the output event is of type TransferSession::OutputEventType::kMsgToSend, it sends the
* message over the exchange context, otherwise it calls the HandleTransferSessionOutput method implemented by the subclass to
* handle the BDX message.
*/
void AsyncTransferFacilitator::HandleNextOutputEvents()
{
Expand Down Expand Up @@ -92,7 +91,8 @@ void AsyncTransferFacilitator::HandleNextOutputEvents()
mHandlingOutputEvents = false;
}

CHIP_ERROR AsyncTransferFacilitator::SendMessage(const TransferSession::MessageTypeData msgTypeData, System::PacketBufferHandle & msgBuf)
CHIP_ERROR AsyncTransferFacilitator::SendMessage(const TransferSession::MessageTypeData msgTypeData,
System::PacketBufferHandle & msgBuf)
{
VerifyOrReturnError(mExchange, CHIP_ERROR_INCORRECT_STATE);

Expand Down Expand Up @@ -138,7 +138,6 @@ CHIP_ERROR AsyncTransferFacilitator::OnMessageReceived(Messaging::ExchangeContex
// This should notify the tranfer object to abort transfer so it can send a status report across the exchange
// when we call HandleNextOutputEvents below.
mTransfer.AbortTransfer(AsyncResponder::GetBdxStatusCodeFromChipError(err));

}
else if (!payloadHeader.HasMessageType(MessageType::BlockAckEOF))
{
Expand Down Expand Up @@ -171,7 +170,7 @@ CHIP_ERROR AsyncResponder::PrepareForTransfer(System::Layer * layer, Messaging::
VerifyOrReturnError(!mExchange, CHIP_ERROR_INCORRECT_STATE);

mSystemLayer = layer;
mTimeout = timeout;
mTimeout = timeout;

ReturnErrorOnFailure(mTransfer.WaitForTransfer(role, xferControlOpts, maxBlockSize, mTimeout));

Expand All @@ -195,7 +194,8 @@ void AsyncResponder::NotifyEventHandled(TransferSession::OutputEvent & event, CH
return;
}

// If there was an error handling the output event, this should notify the tranfer object to abort transfer so it can send a status report
// If there was an error handling the output event, this should notify the tranfer object to abort transfer so it can send a
// status report
// across the exchange when we call HandleNextOutputEvents below.
if (error != CHIP_NO_ERROR)
{
Expand Down
14 changes: 7 additions & 7 deletions src/protocols/bdx/AsyncTransferFacilitator.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ namespace bdx {
/**
* An abstract class with methods for handling BDX messages received from an ExchangeContext. Once a message is receievd, this
* class passes the message to the TransferSession to process the received message and gets the next output events from the
* TransferSession state machine and either sends a message accross the exchange or calls the HandleTransferSessionOutput virtual method
* to notify the subclass of the event generated. It keeps getting the next output event until it receieves an output event of type
* TransferSession::OutputEventType::kNone. For messages that are sent to the HandleTransferSessionOutput method, the subclass must call the
* NotifyEventHandled to notify the AsyncTransferFacilitator that the event has been handled and returns an error code for error cases or success.
* TransferSession state machine and either sends a message accross the exchange or calls the HandleTransferSessionOutput virtual
* method to notify the subclass of the event generated. It keeps getting the next output event until it receieves an output event
* of type TransferSession::OutputEventType::kNone. For messages that are sent to the HandleTransferSessionOutput method, the
* subclass must call the NotifyEventHandled to notify the AsyncTransferFacilitator that the event has been handled and returns an
* error code for error cases or success.
*
* This class does not define any methods for beginning a transfer or initializing the underlying TransferSession object.
* See AsyncResponder for a class that does.
Expand Down Expand Up @@ -85,7 +86,6 @@ class AsyncTransferFacilitator : public Messaging::ExchangeDelegate
System::Layer * mSystemLayer;

private:

bool mHandlingOutputEvents;
};

Expand Down Expand Up @@ -116,8 +116,8 @@ class AsyncResponder : public AsyncTransferFacilitator
/**
* This is called by the subclass implementing HandleTransferSessionOutput to notify the AsyncTransferFacilitator
* that it has handled the OutputEvent specified in event and returns an error code (if any) or success in the error paramter.
* Once this is called the AsyncTransferFacilitator either aborts the transfer if an error has ocurred or drives the TransferSession
* state machine to generate the next output events to establish and continue the BDX session further.
* Once this is called the AsyncTransferFacilitator either aborts the transfer if an error has ocurred or drives the
* TransferSession state machine to generate the next output events to establish and continue the BDX session further.
*
*
* @param[in] event The OutputEvent that was handled by the subclass.
Expand Down

0 comments on commit d344a19

Please sign in to comment.