Skip to content

Commit 972b7f5

Browse files
Fix warning in lwip_ESPHost, add to styler (#1998)
1 parent fc894fb commit 972b7f5

File tree

5 files changed

+35
-26
lines changed

5 files changed

+35
-26
lines changed

libraries/lwIP_ESPHost/src/ESPHost.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
/*
2-
WiFi <-> LWIP for ESPHost library in RP2040 Core
2+
WiFi <-> LWIP for ESPHost library in RP2040 Core
33
4-
Copyright (c) 2024 Juraj Andrassy
4+
Copyright (c) 2024 Juraj Andrassy
55
6-
This library is free software; you can redistribute it and/or
7-
modify it under the terms of the GNU Lesser General Public
8-
License as published by the Free Software Foundation; either
9-
version 2.1 of the License, or (at your option) any later version.
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
1010
11-
This library is distributed in the hope that it will be useful,
12-
but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14-
Lesser General Public License for more details.
11+
This library is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
Lesser General Public License for more details.
1515
16-
You should have received a copy of the GNU Lesser General Public
17-
License along with this library; if not, write to the Free Software
18-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19-
*/
16+
You should have received a copy of the GNU Lesser General Public
17+
License along with this library; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*/
2020

2121
#include "ESPHost.h"
2222
#include "CEspControl.h"

libraries/lwIP_ESPHost/src/ESPHost.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
You should have received a copy of the GNU Lesser General Public
1717
License along with this library; if not, write to the Free Software
1818
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19-
*/
19+
*/
2020

2121
#pragma once
2222

libraries/lwIP_ESPHost/src/lwIP_ESPHost.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,16 @@ int ESPHostLwIP::disconnectEventCb(CCtrlMsgWrapper *resp) {
9595
}
9696

9797
bool ESPHostLwIP::initHW() {
98-
if (wifiHwInitialized)
98+
if (wifiHwInitialized) {
9999
return true;
100+
}
100101
instance = this;
101102

102103
CEspControl::getInstance().listenForStationDisconnectEvent(disconnectEventCb);
103104
CEspControl::getInstance().listenForInitEvent(initEventCb);
104-
if (CEspControl::getInstance().initSpiDriver() != 0)
105+
if (CEspControl::getInstance().initSpiDriver() != 0) {
105106
return false;
107+
}
106108

107109
uint32_t start = millis();
108110
while (!wifiHwInitialized && (millis() - start < timeout)) {
@@ -117,8 +119,9 @@ bool ESPHostLwIP::initHW() {
117119
}
118120

119121
bool ESPHostLwIP::begin() {
120-
if (!initHW())
122+
if (!initHW()) {
121123
return false;
124+
}
122125
ethernet_arch_lwip_begin();
123126
if (!apMode) {
124127
CEspControl::getInstance().setWifiMode(WIFI_MODE_STA);
@@ -131,7 +134,7 @@ bool ESPHostLwIP::begin() {
131134
} else {
132135
CEspControl::getInstance().setWifiMode(WIFI_MODE_AP);
133136
if (softAP.channel == 0 || softAP.channel > MAX_CHNL_NO) {
134-
softAP.channel = 1;
137+
softAP.channel = 1;
135138
}
136139
softAP.max_connections = MAX_SOFTAP_CONNECTION_DEF;
137140
softAP.encryption_mode = softAP.pwd[0] == 0 ? WIFI_AUTH_OPEN : WIFI_AUTH_WPA_WPA2_PSK;
@@ -198,8 +201,9 @@ uint8_t ESPHostLwIP::status() {
198201
}
199202

200203
uint8_t* ESPHostLwIP::macAddress(bool apMode, uint8_t *mac) {
201-
if (!initHW())
204+
if (!initHW()) {
202205
return mac;
206+
}
203207
WifiMac_t MAC;
204208
MAC.mode = apMode ? WIFI_MODE_AP : WIFI_MODE_STA;
205209
ethernet_arch_lwip_begin();
@@ -220,8 +224,9 @@ int ESPHostLwIP::channel() {
220224
}
221225

222226
int32_t ESPHostLwIP::RSSI() {
223-
if (!joined)
227+
if (!joined) {
224228
return 0;
229+
}
225230
ethernet_arch_lwip_begin();
226231
CEspControl::getInstance().getAccessPointConfig(ap);
227232
ethernet_arch_lwip_end();
@@ -254,15 +259,18 @@ uint8_t ESPHostLwIP::encryptionType() {
254259
}
255260

256261
int8_t ESPHostLwIP::scanNetworks(bool async) {
262+
(void) async;
257263
accessPoints.clear();
258-
if (!initHW())
264+
if (!initHW()) {
259265
return -1;
266+
}
260267
ethernet_arch_lwip_begin();
261268
int res = CEspControl::getInstance().getAccessPointScanList(accessPoints);
262269
ethernet_arch_lwip_end();
263270
wifiStatus = WL_SCAN_COMPLETED;
264-
if (res != ESP_CONTROL_OK)
271+
if (res != ESP_CONTROL_OK) {
265272
return -1;
273+
}
266274
return accessPoints.size();
267275
}
268276

@@ -310,8 +318,9 @@ int32_t ESPHostLwIP::RSSI(uint8_t networkItem) {
310318
}
311319

312320
void ESPHostLwIP::lowPowerMode() {
313-
if (!initHW())
321+
if (!initHW()) {
314322
return;
323+
}
315324
ethernet_arch_lwip_begin();
316325
CEspControl::getInstance().setPowerSaveMode(1);
317326
ethernet_arch_lwip_end();

libraries/lwIP_ESPHost/src/lwIP_ESPHost.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
You should have received a copy of the GNU Lesser General Public
1717
License along with this library; if not, write to the Free Software
1818
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19-
*/
19+
*/
2020

2121
#pragma once
2222

tests/restyle.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ for dir in ./cores/rp2040 ./libraries/EEPROM ./libraries/I2S ./libraries/SingleF
1414
./libraries/MouseBT ./libraries/SerialBT ./libraries/HID_Bluetooth \
1515
./libraries/JoystickBLE ./libraries/KeyboardBLE ./libraries/MouseBLE \
1616
./libraries/lwIP_w5500 ./libraries/lwIP_w5100 ./libraries/lwIP_enc28j60 \
17-
./libraries/SPISlave ; do
17+
./libraries/SPISlave ./libraries/lwIP_ESPHost; do
1818
find $dir -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" \) -a \! -path '*api*' -exec astyle --suffix=none --options=./tests/astyle_core.conf \{\} \;
1919
find $dir -type f -name "*.ino" -exec astyle --suffix=none --options=./tests/astyle_examples.conf \{\} \;
2020
done

0 commit comments

Comments
 (0)