Skip to content

Commit

Permalink
fix restyle
Browse files Browse the repository at this point in the history
  • Loading branch information
wy-hh committed Jul 27, 2023
1 parent db6901b commit cef9400
Show file tree
Hide file tree
Showing 17 changed files with 82 additions and 81 deletions.
2 changes: 1 addition & 1 deletion examples/lighting-app/bouffalolab/bl602/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import("${bouffalolab_iot_sdk_build_root}/bl602/bl_iot_sdk.gni")
import("${bouffalolab_iot_sdk_build_root}/common/bouffalolab_executable.gni")
import("${build_root}/config/defaults.gni")
import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
import("${chip_root}/src/platform/device.gni")
import("${chip_root}/src/platform/bouffalolab/common/args.gni")
import("${chip_root}/src/platform/device.gni")

import("${chip_root}/src/app/chip_data_model.gni")

Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/bouffalolab/bl702/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ bouffalolab_executable("lighting_app") {
defines += [ "BL706_WIFI" ]
}


if (defined(enable_cdc_module) && enable_cdc_module) {
defines += [ "CFG_USB_CDC_ENABLE" ]
}
Expand Down
1 change: 0 additions & 1 deletion examples/platform/bouffalolab/common/plat/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ extern "C" {
#include <rom_lmac154_ext.h>
#endif

#include <uart.h>
#include "board.h"
#include <uart.h>
}
Expand Down
1 change: 0 additions & 1 deletion scripts/examples/gn_bouffalolab_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ bl702l_boards=("BL704L-DVK")
bl702l_modules=("BL702L")
bl702l_module_type="BL704l"


print_help() {
bl602_boards_help=""
for board in "${bl602_boards[@]}"; do
Expand Down
4 changes: 2 additions & 2 deletions src/platform/bouffalolab/BL702/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ static_library("BL702") {
if (chip_enable_wifi) {
sources += [
"ConfigurationManagerImpl.cpp",
"WiFiInterface.c",
"ConnectivityManagerImpl.cpp",
"NetworkCommissioningDriver.cpp"
"NetworkCommissioningDriver.cpp",
"WiFiInterface.c",
]

deps = [ "${chip_root}/src/lib/dnssd:platform_header" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ CHIP_ERROR ConfigurationManagerImpl::GetPrimaryMACAddress(MutableByteSpan buf)
#endif

} // namespace DeviceLayer
} // namespace chip
} // namespace chip
28 changes: 17 additions & 11 deletions src/platform/bouffalolab/BL702/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ void ConnectivityManagerImpl::OnWiFiStationDisconnected()

NetworkCommissioning::BLWiFiDriver::GetInstance().SetLastDisconnectReason(NULL);
uint16_t reason = NetworkCommissioning::BLWiFiDriver::GetInstance().GetLastDisconnectReason();
uint8_t associationFailureCause = chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCauseEnum::kUnknown);
uint8_t associationFailureCause =
chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCauseEnum::kUnknown);
WiFiDiagnosticsDelegate * delegate = GetDiagnosticDataProvider().GetWiFiDiagnosticsDelegate();
if (delegate)
{
Expand All @@ -57,13 +58,13 @@ void ConnectivityManagerImpl::OnWiFiStationDisconnected()
}
}

extern "C" void wifiInterface_eventConnected(struct netif * interface)
extern "C" void wifiInterface_eventConnected(struct netif * interface)
{
ChipLogProgress(DeviceLayer, "wifiInterface_eventConnected");
ConnectivityMgrImpl().ChangeWiFiStationState(ConnectivityManager::kWiFiStationState_Connecting_Succeeded);
}

extern "C" void wifiInterface_eventDisconnected(struct netif * interface)
extern "C" void wifiInterface_eventDisconnected(struct netif * interface)
{
ChipLogProgress(DeviceLayer, "wifiInterface_eventDisconnected");
if (ConnectivityManager::kWiFiStationState_Connecting == ConnectivityMgrImpl().GetWiFiStationState())
Expand All @@ -76,37 +77,42 @@ extern "C" void wifiInterface_eventDisconnected(struct netif * interface)
}
}

extern "C" void wifiInterface_eventLinkStatusDone(struct netif * interface, netbus_fs_link_status_ind_cmd_msg_t *pkg_data)
extern "C" void wifiInterface_eventLinkStatusDone(struct netif * interface, netbus_fs_link_status_ind_cmd_msg_t * pkg_data)
{
ChipLogProgress(DeviceLayer, "wifiInterface_eventLinkStatusDone");

struct bflbwifi_ap_record* record = &pkg_data->record;
if (record->link_status == BF1B_WIFI_LINK_STATUS_UP) {
struct bflbwifi_ap_record * record = &pkg_data->record;
if (record->link_status == BF1B_WIFI_LINK_STATUS_UP)
{
ChipLogProgress(DeviceLayer, "link status up!");
} else if (record->link_status == BF1B_WIFI_LINK_STATUS_DOWN){
}
else if (record->link_status == BF1B_WIFI_LINK_STATUS_DOWN)
{
ChipLogProgress(DeviceLayer, "link status down!");
ConnectivityMgrImpl().ChangeWiFiStationState(ConnectivityManager::kWiFiStationState_Disconnecting);
} else {
}
else
{
ChipLogProgress(DeviceLayer, "link status unknown!");
}
}

extern "C" void wifiInterface_eventGotIP(struct netif * interface)
extern "C" void wifiInterface_eventGotIP(struct netif * interface)
{
ChipLogProgress(DeviceLayer, "wifiInterface_eventGotIP");
ConnectivityMgrImpl().OnConnectivityChanged(interface);
ConnectivityMgrImpl().ChangeWiFiStationState(ConnectivityManager::kWiFiStationState_Connected);
}

extern "C" void wifiInterface_eventScanDone(struct netif * interface, netbus_fs_scan_ind_cmd_msg_t* pmsg)
extern "C" void wifiInterface_eventScanDone(struct netif * interface, netbus_fs_scan_ind_cmd_msg_t * pmsg)
{
ChipLogProgress(DeviceLayer, "wifiInterface_eventScanDone");
NetworkCommissioning::BLWiFiDriver::GetInstance().OnScanWiFiNetworkDone(pmsg);
}
#endif

#if !CHIP_DEVICE_CONFIG_ENABLE_THREAD
extern "C" void ethernetInterface_eventGotIP(struct netif * interface)
extern "C" void ethernetInterface_eventGotIP(struct netif * interface)
{
ChipLogProgress(DeviceLayer, "ethernetInterface_eventGotIP");
ConnectivityMgrImpl().OnConnectivityChanged(interface);
Expand Down
8 changes: 4 additions & 4 deletions src/platform/bouffalolab/BL702/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBssId(MutableByteSpan & BssId)
{
struct bflbwifi_ap_record ap_info;

if(!wifiInterface_getApInfo(&ap_info))
if (!wifiInterface_getApInfo(&ap_info))
{
ChipLogError(DeviceLayer, "Failed to get ap info.");
return CHIP_ERROR_INTERNAL;
Expand All @@ -74,7 +74,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiSecurityType(app::Clusters::WiFiNe
using app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum;
struct bflbwifi_ap_record ap_info;

if(!wifiInterface_getApInfo(&ap_info))
if (!wifiInterface_getApInfo(&ap_info))
{
ChipLogError(DeviceLayer, "Failed to get ap info.");
return CHIP_ERROR_INTERNAL;
Expand All @@ -101,7 +101,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiChannelNumber(uint16_t & channelNu
{
struct bflbwifi_ap_record ap_info;

if(!wifiInterface_getApInfo(&ap_info))
if (!wifiInterface_getApInfo(&ap_info))
{
ChipLogError(DeviceLayer, "Failed to get ap info.");
return CHIP_ERROR_INTERNAL;
Expand All @@ -116,7 +116,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiRssi(int8_t & rssi)
{
struct bflbwifi_ap_record ap_info;

if(!wifiInterface_getApInfo(&ap_info))
if (!wifiInterface_getApInfo(&ap_info))
{
ChipLogError(DeviceLayer, "Failed to get ap info.");
return CHIP_ERROR_INTERNAL;
Expand Down
65 changes: 35 additions & 30 deletions src/platform/bouffalolab/BL702/NetworkCommissioningDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@ CHIP_ERROR BLWiFiDriver::Init(NetworkStatusChangeCallback * networkStatusChangeC
size_t ssidLen = 0;
size_t credentialsLen = 0;

err = PersistedStorage::KeyValueStoreMgr().Get(BLConfig::kConfigKey_WiFiSSID, mSavedNetwork.ssid,
sizeof(mSavedNetwork.ssid), &ssidLen);
err = PersistedStorage::KeyValueStoreMgr().Get(BLConfig::kConfigKey_WiFiSSID, mSavedNetwork.ssid, sizeof(mSavedNetwork.ssid),
&ssidLen);
SuccessOrExit(err);
err = PersistedStorage::KeyValueStoreMgr().Get(BLConfig::kConfigKey_WiFiPassword, mSavedNetwork.credentials, sizeof(mSavedNetwork.credentials), &credentialsLen);
err = PersistedStorage::KeyValueStoreMgr().Get(BLConfig::kConfigKey_WiFiPassword, mSavedNetwork.credentials,
sizeof(mSavedNetwork.credentials), &credentialsLen);
SuccessOrExit(err);

mSavedNetwork.credentialsLen = credentialsLen;
mSavedNetwork.ssidLen = ssidLen;
mSavedNetwork.credentialsLen = credentialsLen;
mSavedNetwork.ssidLen = ssidLen;
mSavedNetwork.credentials[mSavedNetwork.credentialsLen] = '\0';
mSavedNetwork.ssid[mSavedNetwork.ssidLen] = '\0';
mSavedNetwork.ssid[mSavedNetwork.ssidLen] = '\0';

mStagingNetwork = mSavedNetwork;
mpScanCallback = nullptr;
Expand Down Expand Up @@ -70,7 +71,8 @@ void BLWiFiDriver::Shutdown()
CHIP_ERROR BLWiFiDriver::CommitConfiguration()
{
ChipLogProgress(NetworkProvisioning, "BLWiFiDriver::CommitConfiguration");
ReturnErrorOnFailure(PersistedStorage::KeyValueStoreMgr().Put(BLConfig::kConfigKey_WiFiSSID, mStagingNetwork.ssid, mStagingNetwork.ssidLen));
ReturnErrorOnFailure(
PersistedStorage::KeyValueStoreMgr().Put(BLConfig::kConfigKey_WiFiSSID, mStagingNetwork.ssid, mStagingNetwork.ssidLen));
ReturnErrorOnFailure(PersistedStorage::KeyValueStoreMgr().Put(BLConfig::kConfigKey_WiFiPassword, mStagingNetwork.credentials,
mStagingNetwork.credentialsLen));
mSavedNetwork = mStagingNetwork;
Expand All @@ -93,7 +95,7 @@ Status BLWiFiDriver::AddOrUpdateNetwork(ByteSpan ssid, ByteSpan credentials, Mut
{
outDebugText.reduce_size(0);
outNetworkIndex = 0;

VerifyOrReturnError(mStagingNetwork.ssidLen == 0 || NetworkMatch(mStagingNetwork, ssid), Status::kBoundsExceeded);
VerifyOrReturnError(credentials.size() <= sizeof(mStagingNetwork.credentials), Status::kOutOfRange);
VerifyOrReturnError(ssid.size() <= sizeof(mStagingNetwork.ssid), Status::kOutOfRange);
Expand All @@ -111,7 +113,7 @@ Status BLWiFiDriver::RemoveNetwork(ByteSpan networkId, MutableCharSpan & outDebu
{
outDebugText.reduce_size(0);
outNetworkIndex = 0;

VerifyOrReturnError(NetworkMatch(mStagingNetwork, networkId), Status::kNetworkIDNotFound);

mStagingNetwork.ssidLen = 0;
Expand All @@ -130,20 +132,22 @@ Status BLWiFiDriver::ReorderNetwork(ByteSpan networkId, uint8_t index, MutableCh
CHIP_ERROR BLWiFiDriver::ConnectWiFiNetwork(const char * ssid, uint8_t ssidLen, const char * key, uint8_t keyLen)
{
ChipLogProgress(NetworkProvisioning, "ConnectWiFiNetwork");
wifiInterface_connect((char *)ssid, (char *)key);
wifiInterface_connect((char *) ssid, (char *) key);
ConnectivityMgrImpl().ChangeWiFiStationState(ConnectivityManager::kWiFiStationState_Connecting);
return CHIP_NO_ERROR;
}

void BLWiFiDriver::OnConnectWiFiNetwork(bool isConnected)
{
ChipLogProgress(NetworkProvisioning, "BLWiFiDriver::OnConnectWiFiNetwork, isConnected=%d\r\n", isConnected);
ChipLogProgress(NetworkProvisioning, "BLWiFiDriver::OnConnectWiFiNetwork, isConnected=%d\r\n", isConnected);
if (mpConnectCallback)
{
if (isConnected) {
if (isConnected)
{
mpConnectCallback->OnResult(Status::kSuccess, CharSpan(), 0);
}
else {
else
{
mpConnectCallback->OnResult(Status::kUnknownError, CharSpan(), 0);
}
mpConnectCallback = nullptr;
Expand All @@ -157,13 +161,13 @@ void BLWiFiDriver::ConnectNetwork(ByteSpan networkId, ConnectCallback * callback

VerifyOrExit(NetworkMatch(mStagingNetwork, networkId), networkingStatus = Status::kNetworkIDNotFound);
VerifyOrExit(mpConnectCallback == nullptr, networkingStatus = Status::kUnknownError);
ChipLogProgress(NetworkProvisioning, "BL702 Network Commissioning ConnectNetwork: SSID: %.*s", static_cast<int>(networkId.size()),
networkId.data());
ChipLogProgress(NetworkProvisioning, "BL702 Network Commissioning ConnectNetwork: SSID: %.*s",
static_cast<int>(networkId.size()), networkId.data());

mStagingNetwork.ssid[mStagingNetwork.ssidLen] = '\0';
mStagingNetwork.ssid[mStagingNetwork.ssidLen] = '\0';
mStagingNetwork.credentials[mStagingNetwork.credentialsLen] = '\0';
err = ConnectWiFiNetwork(reinterpret_cast<const char *>(mStagingNetwork.ssid), mStagingNetwork.ssidLen,
reinterpret_cast<const char *>(mStagingNetwork.credentials), mStagingNetwork.credentialsLen);
err = ConnectWiFiNetwork(reinterpret_cast<const char *>(mStagingNetwork.ssid), mStagingNetwork.ssidLen,
reinterpret_cast<const char *>(mStagingNetwork.credentials), mStagingNetwork.credentialsLen);
mpConnectCallback = callback;

exit:
Expand All @@ -179,15 +183,15 @@ void BLWiFiDriver::ConnectNetwork(ByteSpan networkId, ConnectCallback * callback
}
}

void BLWiFiDriver::OnScanWiFiNetworkDone(void *arg)
void BLWiFiDriver::OnScanWiFiNetworkDone(void * arg)
{
netbus_fs_scan_ind_cmd_msg_t* pmsg = (netbus_fs_scan_ind_cmd_msg_t*) arg;
netbus_fs_scan_ind_cmd_msg_t * pmsg = (netbus_fs_scan_ind_cmd_msg_t *) arg;
size_t i = 0, ap_num = pmsg->num;
WiFiScanResponse * pScanResponse, *p;
WiFiScanResponse *pScanResponse, *p;

for (i = 0; i < pmsg->num; i++)
{
if (mScanSpecific && !strcmp(mScanSSID, (char *)(pmsg->records[i].ssid)))
if (mScanSpecific && !strcmp(mScanSSID, (char *) (pmsg->records[i].ssid)))
{
ap_num = 1;
break;
Expand All @@ -205,24 +209,25 @@ void BLWiFiDriver::OnScanWiFiNetworkDone(void *arg)
return;
}

p = pScanResponse = (WiFiScanResponse *)malloc(sizeof(WiFiScanResponse) * ap_num);
p = pScanResponse = (WiFiScanResponse *) malloc(sizeof(WiFiScanResponse) * ap_num);
for (i = 0; i < pmsg->num; i++)
{
if(mScanSpecific && strcmp(mScanSSID, (char *)(pmsg->records[i].ssid)))
if (mScanSpecific && strcmp(mScanSSID, (char *) (pmsg->records[i].ssid)))
{
continue;
}

p->security.SetRaw(pmsg->records[i].auth_mode);
p->ssidLen = strlen((char *)pmsg->records[i].ssid) < chip::DeviceLayer::Internal::kMaxWiFiSSIDLength
? strlen((char *)pmsg->records[i].ssid) : chip::DeviceLayer::Internal::kMaxWiFiSSIDLength;
p->ssidLen = strlen((char *) pmsg->records[i].ssid) < chip::DeviceLayer::Internal::kMaxWiFiSSIDLength
? strlen((char *) pmsg->records[i].ssid)
: chip::DeviceLayer::Internal::kMaxWiFiSSIDLength;
p->channel = pmsg->records[i].channel;
p->wiFiBand = chip::DeviceLayer::NetworkCommissioning::WiFiBand::k2g4;
p->rssi = pmsg->records[i].rssi;
memcpy(p->ssid, pmsg->records[i].ssid, p->ssidLen);
memcpy(p->bssid, pmsg->records[i].bssid, 6);

if(mScanSpecific)
if (mScanSpecific)
{
break;
}
Expand Down Expand Up @@ -270,7 +275,7 @@ CHIP_ERROR GetConfiguredNetwork(Network & network)

ChipLogProgress(DeviceLayer, "GetConfiguredNetwork");

if(!wifiInterface_getApInfo(&ap_info))
if (!wifiInterface_getApInfo(&ap_info))
{
return CHIP_ERROR_INTERNAL;
}
Expand Down Expand Up @@ -318,7 +323,7 @@ void BLWiFiDriver::OnNetworkStatusChange()

CHIP_ERROR BLWiFiDriver::SetLastDisconnectReason(const ChipDeviceEvent * event)
{
//TODO: to be added
// TODO: to be added
mLastDisconnectedReason = 0;

return CHIP_NO_ERROR;
Expand Down Expand Up @@ -355,7 +360,7 @@ bool BLWiFiDriver::WiFiNetworkIterator::Next(Network & item)
item.connected = true;
}
}

return true;
}

Expand Down
3 changes: 0 additions & 3 deletions src/platform/bouffalolab/BL702/NetworkCommissioningDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ constexpr uint8_t kWiFiScanNetworksTimeOutSeconds = 10;
constexpr uint8_t kWiFiConnectNetworkTimeoutSeconds = 20;
} // namespace


class BLScanResponseIterator : public Iterator<WiFiScanResponse>
{
public:
Expand All @@ -55,7 +54,6 @@ class BLScanResponseIterator : public Iterator<WiFiScanResponse>
WiFiScanResponse * mpScanResults;
};


class BLWiFiDriver final : public WiFiDriver
{
public:
Expand Down Expand Up @@ -117,7 +115,6 @@ class BLWiFiDriver final : public WiFiDriver
}

private:

bool NetworkMatch(const WiFiNetwork & network, ByteSpan networkId);
CHIP_ERROR StartScanWiFiNetworks(ByteSpan ssid);

Expand Down
2 changes: 1 addition & 1 deletion src/platform/bouffalolab/BL702/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)

// Initialize LwIP.
tcpip_init(NULL, NULL);

#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
wifiInterface_init();
#elif CHIP_DEVICE_CONFIG_ENABLE_THREAD
Expand Down
4 changes: 2 additions & 2 deletions src/platform/bouffalolab/BL702/WiFiInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ bool wifiInterface_init()
}

virt_net_setup_callback(vnet_spi, virt_net_spi_event_cb, NULL);
netifapi_netif_set_default((struct netif *)&vnet_spi->netif);
netifapi_netif_set_default((struct netif *) &vnet_spi->netif);

bl_route_hook_init();

Expand Down Expand Up @@ -158,4 +158,4 @@ bool wifiInterface_getApInfo(struct bflbwifi_ap_record * ap_info)
void wifiInterface_startScan(void)
{
virt_net_scan(vnet_spi);
}
}
Loading

0 comments on commit cef9400

Please sign in to comment.