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 crlonxp committed Jun 28, 2024
1 parent 391dd07 commit 75a54c5
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 28 deletions.
5 changes: 3 additions & 2 deletions src/controller/AutoCommissioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,9 @@ CHIP_ERROR AutoCommissioner::StartCommissioning(DeviceCommissioner * commissione
CHIP_ERROR err = CHIP_NO_ERROR;
CommissioningStage nextStage = GetNextCommissioningStage(CommissioningStage::kSecurePairing, err);
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
mNeedsNetworkSetup = mNeedsNetworkSetup || (mCommissioneeDeviceProxy->GetSecureSession().Value()->AsSecureSession()->GetPeerAddress().GetTransportType() ==
Transport::Type::kWiFiPAF);
mNeedsNetworkSetup = mNeedsNetworkSetup ||
(mCommissioneeDeviceProxy->GetSecureSession().Value()->AsSecureSession()->GetPeerAddress().GetTransportType() ==
Transport::Type::kWiFiPAF);
#endif
mCommissioner->PerformCommissioningStep(mCommissioneeDeviceProxy, nextStage, mParams, this, GetEndpoint(nextStage),
GetCommandTimeout(mCommissioneeDeviceProxy, nextStage));
Expand Down
6 changes: 4 additions & 2 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,8 @@ CHIP_ERROR DeviceCommissioner::EstablishPASEConnection(NodeId remoteDeviceId, Re
ExitNow(CHIP_ERROR_INTERNAL);
}
mRendezvousParametersForDeviceDiscoveredOverWiFiPAF = params;
DeviceLayer::ConnectivityMgr().WiFiPAFConnect(params.GetSetupDiscriminator().value(), this, OnWiFiPAFSubscribeComplete, OnWiFiPAFSubscribeError);
DeviceLayer::ConnectivityMgr().WiFiPAFConnect(params.GetSetupDiscriminator().value(), this, OnWiFiPAFSubscribeComplete,
OnWiFiPAFSubscribeError);
ExitNow(CHIP_NO_ERROR);
}
}
Expand Down Expand Up @@ -922,7 +923,8 @@ void DeviceCommissioner::OnWiFiPAFSubscribeError(void * appState, CHIP_ERROR err

if (nullptr != device && device->GetDeviceTransportType() == Transport::Type::kWiFiPAF)
{
ChipLogError(Controller, "WiFi-PAF: Subscription Error, id = %lu, err = %" CHIP_ERROR_FORMAT, device->GetDeviceId(), err.Format());
ChipLogError(Controller, "WiFi-PAF: Subscription Error, id = %lu, err = %" CHIP_ERROR_FORMAT, device->GetDeviceId(),
err.Format());
self->ReleaseCommissioneeDevice(device);
self->mRendezvousParametersForDeviceDiscoveredOverWiFiPAF = RendezvousParameters();
if (self->mPairingDelegate != nullptr)
Expand Down
7 changes: 4 additions & 3 deletions src/include/platform/ConnectivityManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ class ConnectivityManager

typedef void (*OnConnectionCompleteFunct)(void * appState);
typedef void (*OnConnectionErrorFunct)(void * appState, CHIP_ERROR err);
CHIP_ERROR WiFiPAFConnect(const SetupDiscriminator & connDiscriminator, void * appState, OnConnectionCompleteFunct onSuccess, OnConnectionErrorFunct onError);
CHIP_ERROR WiFiPAFConnect(const SetupDiscriminator & connDiscriminator, void * appState, OnConnectionCompleteFunct onSuccess,
OnConnectionErrorFunct onError);
CHIP_ERROR WiFiPAFSend(System::PacketBufferHandle && msgBuf);
Transport::WiFiPAFBase * GetWiFiPAF();
void SetWiFiPAF(Transport::WiFiPAFBase * pmWiFiPAF);
Expand Down Expand Up @@ -426,8 +427,8 @@ inline CHIP_ERROR ConnectivityManager::SetWiFiPAFAdvertisingEnabled(bool val)
return static_cast<ImplClass *>(this)->_SetWiFiPAFAdvertisingEnabled(val);
}

inline CHIP_ERROR ConnectivityManager::WiFiPAFConnect(const SetupDiscriminator & connDiscriminator, void * appState, OnConnectionCompleteFunct onSuccess,
OnConnectionErrorFunct onError)
inline CHIP_ERROR ConnectivityManager::WiFiPAFConnect(const SetupDiscriminator & connDiscriminator, void * appState,
OnConnectionCompleteFunct onSuccess, OnConnectionErrorFunct onError)
{
return static_cast<ImplClass *>(this)->_WiFiPAFConnect(connDiscriminator, appState, onSuccess, onError);
}
Expand Down
29 changes: 17 additions & 12 deletions src/platform/Linux/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ CHIP_ERROR ConnectivityManagerImpl::_WiFiPAFPublish()
}
strcat(args, NAN_PUBLISH_SSI_TAG);
ret = Encoding::BytesToUppercaseHexString((uint8_t *) &PafPublish_ssi, sizeof(PafPublish_ssi), &args[strlen(args)],
MAX_PAF_PUBLISH_SSI_BUFLEN - strlen(args));
MAX_PAF_PUBLISH_SSI_BUFLEN - strlen(args));
VerifyOrReturnError(ret == CHIP_NO_ERROR, ret);
ChipLogProgress(DeviceLayer, "WiFi-PAF: publish: [%s]", args);
wpa_fi_w1_wpa_supplicant1_interface_call_nanpublish_sync(mWpaSupplicant.iface, args, &publish_id, nullptr, &err.GetReceiver());
Expand All @@ -887,12 +887,14 @@ CHIP_ERROR ConnectivityManagerImpl::_WiFiPAFCancelPublish()
return CHIP_NO_ERROR;
}


CHIP_ERROR ConnectivityManagerImpl::_SetWiFiPAFAdvertisingEnabled(bool val)
{
if (val == true) {
if (val == true)
{
return _WiFiPAFPublish();
} else {
}
else
{
return _WiFiPAFCancelPublish();
}
}
Expand Down Expand Up @@ -1355,7 +1357,8 @@ void ConnectivityManagerImpl::OnDiscoveryResult(gboolean success, GVariant * dis
return;
}

if (success == true) {
if (success == true)
{
GAutoPtr<GVariant> dataValue(g_variant_lookup_value(discov_info, "discov_info", G_VARIANT_TYPE_BYTESTRING));
size_t bufferLen;
auto buffer = g_variant_get_fixed_array(dataValue.get(), &bufferLen, sizeof(uint8_t));
Expand All @@ -1374,7 +1377,9 @@ void ConnectivityManagerImpl::OnDiscoveryResult(gboolean success, GVariant * dis
ChipDeviceEvent event;
event.Type = DeviceEventType::kCHIPoWiFiPAFConnected;
PlatformMgr().PostEventOrDie(&event);
} else {
}
else
{
GetWiFiPAF()->SetWiFiPAFState(Transport::WiFiPAFBase::State::kInitialized);
if (mOnPafSubscribeError != nullptr)
{
Expand Down Expand Up @@ -1421,8 +1426,8 @@ void ConnectivityManagerImpl::OnNanReceive(GVariant * obj)
return;
}

CHIP_ERROR ConnectivityManagerImpl::_WiFiPAFConnect(const SetupDiscriminator & connDiscriminator, void * appState, OnConnectionCompleteFunct onSuccess,
OnConnectionErrorFunct onError)
CHIP_ERROR ConnectivityManagerImpl::_WiFiPAFConnect(const SetupDiscriminator & connDiscriminator, void * appState,
OnConnectionCompleteFunct onSuccess, OnConnectionErrorFunct onError)
{
ChipLogProgress(Controller, "WiFi-PAF: Try to subscribe the NAN-USD devices");
gchar args[MAX_PAF_SUBSCRIBE_SSI_BUFLEN];
Expand All @@ -1434,9 +1439,9 @@ CHIP_ERROR ConnectivityManagerImpl::_WiFiPAFConnect(const SetupDiscriminator & c
VerifyOrReturnError(
(strlen(args) + strlen(NAN_PUBLISH_SSI_TAG) + (sizeof(struct PAFPublishSSI) * 2) < MAX_PAF_PUBLISH_SSI_BUFLEN),
CHIP_ERROR_BUFFER_TOO_SMALL);
mAppState = appState;
mAppState = appState;
PafPublish_ssi.DevOpCode = 0;
PafPublish_ssi.DevInfo = connDiscriminator.GetLongValue();
PafPublish_ssi.DevInfo = connDiscriminator.GetLongValue();
if (DeviceLayer::GetDeviceInstanceInfoProvider()->GetProductId(PafPublish_ssi.ProductId) != CHIP_NO_ERROR)
{
PafPublish_ssi.ProductId = 0;
Expand All @@ -1447,7 +1452,7 @@ CHIP_ERROR ConnectivityManagerImpl::_WiFiPAFConnect(const SetupDiscriminator & c
}
strcat(args, NAN_PUBLISH_SSI_TAG);
ret = Encoding::BytesToUppercaseHexString((uint8_t *) &PafPublish_ssi, sizeof(PafPublish_ssi), &args[strlen(args)],
MAX_PAF_PUBLISH_SSI_BUFLEN - strlen(args));
MAX_PAF_PUBLISH_SSI_BUFLEN - strlen(args));
VerifyOrReturnError(ret == CHIP_NO_ERROR, ret);
ChipLogProgress(DeviceLayer, "WiFi-PAF: subscribe: [%s]", args);

Expand All @@ -1457,7 +1462,7 @@ CHIP_ERROR ConnectivityManagerImpl::_WiFiPAFConnect(const SetupDiscriminator & c
+[](GObject * sourceObject_, GAsyncResult * res_, ConnectivityManagerImpl * self) { return; }),
&err.GetReceiver());
mOnPafSubscribeComplete = onSuccess;
mOnPafSubscribeError = onError;
mOnPafSubscribeError = onError;
g_signal_connect(mWpaSupplicant.iface, "discovery-result",
G_CALLBACK(+[](WpaFiW1Wpa_supplicant1Interface * proxy, gboolean success, GVariant * obj,
ConnectivityManagerImpl * self) { return self->OnDiscoveryResult(success, obj); }),
Expand Down
9 changes: 5 additions & 4 deletions src/platform/Linux/ConnectivityManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ class ConnectivityManagerImpl final : public ConnectivityManager,
NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * connectCallback);
#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_PDC
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
CHIP_ERROR _WiFiPAFConnect(const SetupDiscriminator & connDiscriminator, void * appState, OnConnectionCompleteFunct onSuccess, OnConnectionErrorFunct onError);
CHIP_ERROR _WiFiPAFConnect(const SetupDiscriminator & connDiscriminator, void * appState, OnConnectionCompleteFunct onSuccess,
OnConnectionErrorFunct onError);
void OnDiscoveryResult(gboolean success, GVariant * obj);
void OnNanReceive(GVariant * obj);

Expand Down Expand Up @@ -245,12 +246,12 @@ class ConnectivityManagerImpl final : public ConnectivityManager,
struct wpa_dbus_nanrx_info mpaf_nanrx_info;

OnConnectionCompleteFunct mOnPafSubscribeComplete;
OnConnectionErrorFunct mOnPafSubscribeError;
OnConnectionErrorFunct mOnPafSubscribeError;
Transport::WiFiPAFBase * pmWiFiPAF;
void * mAppState;
CHIP_ERROR _SetWiFiPAFAdvertisingEnabled(bool val);
CHIP_ERROR _WiFiPAFPublish();
CHIP_ERROR _WiFiPAFCancelPublish();
CHIP_ERROR _WiFiPAFPublish();
CHIP_ERROR _WiFiPAFCancelPublish();
#endif

bool _GetBssInfo(const gchar * bssPath, NetworkCommissioning::WiFiScanResponse & result);
Expand Down
2 changes: 1 addition & 1 deletion src/setup_payload/SetupPayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ enum class RendezvousInformationFlag : uint8_t
kSoftAP = 1 << 0, ///< Device supports Wi-Fi softAP
kBLE = 1 << 1, ///< Device supports BLE
kOnNetwork = 1 << 2, ///< Device supports Setup on network
kWiFiPAF = 1 << 3, ///< Device supports Wi-Fi Public Action Frame for discovery
kWiFiPAF = 1 << 3, ///< Device supports Wi-Fi Public Action Frame for discovery
};
using RendezvousInformationFlags = chip::BitFlags<RendezvousInformationFlag, uint8_t>;

Expand Down
7 changes: 4 additions & 3 deletions src/transport/raw/WiFiPAF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
*
*/

#include <transport/raw/WiFiPAF.h>
#include <inttypes.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/logging/CHIPLogging.h>
#include <platform/ConnectivityManager.h>
#include <transport/raw/MessageHeader.h>
#include <inttypes.h>
#include <transport/raw/WiFiPAF.h>

using namespace chip::System;

Expand All @@ -51,7 +51,8 @@ CHIP_ERROR WiFiPAFBase::Init(const WiFiPAFListenParameters & param)
DeviceLayer::ConnectivityMgr().SetWiFiPAF(this);
mState = State::kInitialized;

if (!DeviceLayer::ConnectivityMgrImpl().IsWiFiManagementStarted()) {
if (!DeviceLayer::ConnectivityMgrImpl().IsWiFiManagementStarted())
{
ChipLogError(Inet, "Wi-Fi Management has not started, do it now.");
static constexpr useconds_t kWiFiStartCheckTimeUsec = WIFI_START_CHECK_TIME_USEC;
static constexpr uint8_t kWiFiStartCheckAttempts = WIFI_START_CHECK_ATTEMPTS;
Expand Down
2 changes: 1 addition & 1 deletion src/transport/raw/WiFiPAF.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@

#pragma once

#include <utility>
#include <lib/core/CHIPCore.h>
#include <lib/support/DLLUtil.h>
#include <system/SystemPacketBuffer.h>
#include <transport/raw/Base.h>
#include <utility>

namespace chip {
namespace Transport {
Expand Down

0 comments on commit 75a54c5

Please sign in to comment.