Unverified Commit 972b7f53 authored by Earle F. Philhower, III's avatar Earle F. Philhower, III Committed by GitHub

Fix warning in lwip_ESPHost, add to styler (#1998)

parent fc894fba
/* /*
WiFi <-> LWIP for ESPHost library in RP2040 Core WiFi <-> LWIP for ESPHost library in RP2040 Core
Copyright (c) 2024 Juraj Andrassy Copyright (c) 2024 Juraj Andrassy
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version. version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details. Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "ESPHost.h" #include "ESPHost.h"
#include "CEspControl.h" #include "CEspControl.h"
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
You should have received a copy of the GNU Lesser General Public You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#pragma once #pragma once
......
...@@ -95,14 +95,16 @@ int ESPHostLwIP::disconnectEventCb(CCtrlMsgWrapper *resp) { ...@@ -95,14 +95,16 @@ int ESPHostLwIP::disconnectEventCb(CCtrlMsgWrapper *resp) {
} }
bool ESPHostLwIP::initHW() { bool ESPHostLwIP::initHW() {
if (wifiHwInitialized) if (wifiHwInitialized) {
return true; return true;
}
instance = this; instance = this;
CEspControl::getInstance().listenForStationDisconnectEvent(disconnectEventCb); CEspControl::getInstance().listenForStationDisconnectEvent(disconnectEventCb);
CEspControl::getInstance().listenForInitEvent(initEventCb); CEspControl::getInstance().listenForInitEvent(initEventCb);
if (CEspControl::getInstance().initSpiDriver() != 0) if (CEspControl::getInstance().initSpiDriver() != 0) {
return false; return false;
}
uint32_t start = millis(); uint32_t start = millis();
while (!wifiHwInitialized && (millis() - start < timeout)) { while (!wifiHwInitialized && (millis() - start < timeout)) {
...@@ -117,8 +119,9 @@ bool ESPHostLwIP::initHW() { ...@@ -117,8 +119,9 @@ bool ESPHostLwIP::initHW() {
} }
bool ESPHostLwIP::begin() { bool ESPHostLwIP::begin() {
if (!initHW()) if (!initHW()) {
return false; return false;
}
ethernet_arch_lwip_begin(); ethernet_arch_lwip_begin();
if (!apMode) { if (!apMode) {
CEspControl::getInstance().setWifiMode(WIFI_MODE_STA); CEspControl::getInstance().setWifiMode(WIFI_MODE_STA);
...@@ -131,7 +134,7 @@ bool ESPHostLwIP::begin() { ...@@ -131,7 +134,7 @@ bool ESPHostLwIP::begin() {
} else { } else {
CEspControl::getInstance().setWifiMode(WIFI_MODE_AP); CEspControl::getInstance().setWifiMode(WIFI_MODE_AP);
if (softAP.channel == 0 || softAP.channel > MAX_CHNL_NO) { if (softAP.channel == 0 || softAP.channel > MAX_CHNL_NO) {
softAP.channel = 1; softAP.channel = 1;
} }
softAP.max_connections = MAX_SOFTAP_CONNECTION_DEF; softAP.max_connections = MAX_SOFTAP_CONNECTION_DEF;
softAP.encryption_mode = softAP.pwd[0] == 0 ? WIFI_AUTH_OPEN : WIFI_AUTH_WPA_WPA2_PSK; softAP.encryption_mode = softAP.pwd[0] == 0 ? WIFI_AUTH_OPEN : WIFI_AUTH_WPA_WPA2_PSK;
...@@ -198,8 +201,9 @@ uint8_t ESPHostLwIP::status() { ...@@ -198,8 +201,9 @@ uint8_t ESPHostLwIP::status() {
} }
uint8_t* ESPHostLwIP::macAddress(bool apMode, uint8_t *mac) { uint8_t* ESPHostLwIP::macAddress(bool apMode, uint8_t *mac) {
if (!initHW()) if (!initHW()) {
return mac; return mac;
}
WifiMac_t MAC; WifiMac_t MAC;
MAC.mode = apMode ? WIFI_MODE_AP : WIFI_MODE_STA; MAC.mode = apMode ? WIFI_MODE_AP : WIFI_MODE_STA;
ethernet_arch_lwip_begin(); ethernet_arch_lwip_begin();
...@@ -220,8 +224,9 @@ int ESPHostLwIP::channel() { ...@@ -220,8 +224,9 @@ int ESPHostLwIP::channel() {
} }
int32_t ESPHostLwIP::RSSI() { int32_t ESPHostLwIP::RSSI() {
if (!joined) if (!joined) {
return 0; return 0;
}
ethernet_arch_lwip_begin(); ethernet_arch_lwip_begin();
CEspControl::getInstance().getAccessPointConfig(ap); CEspControl::getInstance().getAccessPointConfig(ap);
ethernet_arch_lwip_end(); ethernet_arch_lwip_end();
...@@ -254,15 +259,18 @@ uint8_t ESPHostLwIP::encryptionType() { ...@@ -254,15 +259,18 @@ uint8_t ESPHostLwIP::encryptionType() {
} }
int8_t ESPHostLwIP::scanNetworks(bool async) { int8_t ESPHostLwIP::scanNetworks(bool async) {
(void) async;
accessPoints.clear(); accessPoints.clear();
if (!initHW()) if (!initHW()) {
return -1; return -1;
}
ethernet_arch_lwip_begin(); ethernet_arch_lwip_begin();
int res = CEspControl::getInstance().getAccessPointScanList(accessPoints); int res = CEspControl::getInstance().getAccessPointScanList(accessPoints);
ethernet_arch_lwip_end(); ethernet_arch_lwip_end();
wifiStatus = WL_SCAN_COMPLETED; wifiStatus = WL_SCAN_COMPLETED;
if (res != ESP_CONTROL_OK) if (res != ESP_CONTROL_OK) {
return -1; return -1;
}
return accessPoints.size(); return accessPoints.size();
} }
...@@ -310,8 +318,9 @@ int32_t ESPHostLwIP::RSSI(uint8_t networkItem) { ...@@ -310,8 +318,9 @@ int32_t ESPHostLwIP::RSSI(uint8_t networkItem) {
} }
void ESPHostLwIP::lowPowerMode() { void ESPHostLwIP::lowPowerMode() {
if (!initHW()) if (!initHW()) {
return; return;
}
ethernet_arch_lwip_begin(); ethernet_arch_lwip_begin();
CEspControl::getInstance().setPowerSaveMode(1); CEspControl::getInstance().setPowerSaveMode(1);
ethernet_arch_lwip_end(); ethernet_arch_lwip_end();
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
You should have received a copy of the GNU Lesser General Public You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#pragma once #pragma once
......
...@@ -14,7 +14,7 @@ for dir in ./cores/rp2040 ./libraries/EEPROM ./libraries/I2S ./libraries/SingleF ...@@ -14,7 +14,7 @@ for dir in ./cores/rp2040 ./libraries/EEPROM ./libraries/I2S ./libraries/SingleF
./libraries/MouseBT ./libraries/SerialBT ./libraries/HID_Bluetooth \ ./libraries/MouseBT ./libraries/SerialBT ./libraries/HID_Bluetooth \
./libraries/JoystickBLE ./libraries/KeyboardBLE ./libraries/MouseBLE \ ./libraries/JoystickBLE ./libraries/KeyboardBLE ./libraries/MouseBLE \
./libraries/lwIP_w5500 ./libraries/lwIP_w5100 ./libraries/lwIP_enc28j60 \ ./libraries/lwIP_w5500 ./libraries/lwIP_w5100 ./libraries/lwIP_enc28j60 \
./libraries/SPISlave ; do ./libraries/SPISlave ./libraries/lwIP_ESPHost; do
find $dir -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" \) -a \! -path '*api*' -exec astyle --suffix=none --options=./tests/astyle_core.conf \{\} \; find $dir -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" \) -a \! -path '*api*' -exec astyle --suffix=none --options=./tests/astyle_core.conf \{\} \;
find $dir -type f -name "*.ino" -exec astyle --suffix=none --options=./tests/astyle_examples.conf \{\} \; find $dir -type f -name "*.ino" -exec astyle --suffix=none --options=./tests/astyle_examples.conf \{\} \;
done done
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment