Skip to content

Commit bf2f1bb

Browse files
committed
sack off string for static memory allocation
1 parent a1ea262 commit bf2f1bb

File tree

2 files changed

+33
-20
lines changed

2 files changed

+33
-20
lines changed

platformio.ini

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,16 @@ framework = arduino
1616
monitor_speed = 115200
1717
lib_compat_mode = strict
1818
lib_deps =
19+
;;;;;;;;;;; FunHouse / LVGL Boards uncomment these ;;;;;;;;;;;;;;
20+
; https://github.com/adafruit/Adafruit_HX8357_Library.git
21+
; https://github.com/adafruit/Adafruit_ILI9341.git
22+
; https://github.com/adafruit/Adafruit_STMPE610.git
23+
; https://github.com/adafruit/Adafruit-ST7735-Library.git
24+
; https://github.com/adafruit/Adafruit_TouchScreen.git
25+
; https://github.com/brentru/lvgl.git#wippersnapper
26+
; https://github.com/brentru/Adafruit_LvGL_Glue.git#development
27+
;;;;;;;;;;; All Boards need these libraries included ;;;;;;;;;;;;;;
1928
adafruit/Adafruit Zero DMA Library
20-
https://github.com/adafruit/Adafruit_TinyUSB_Arduino.git
2129
adafruit/Adafruit NeoPixel
2230
adafruit/Adafruit SPIFlash
2331
adafruit/Adafruit DotStar
@@ -78,14 +86,8 @@ lib_deps =
7886
https://github.com/Sensirion/arduino-i2c-sen5x.git
7987
https://github.com/adafruit/WiFiNINA.git
8088
https://github.com/Starmbi/hp_BH1750.git
81-
;;;;;;;;;;; FunHouse / LVGL Boards ;;;;;;;;;;;;;;
82-
https://github.com/adafruit/Adafruit_HX8357_Library.git
83-
https://github.com/adafruit/Adafruit_ILI9341.git
84-
https://github.com/adafruit/Adafruit_STMPE610.git
85-
https://github.com/adafruit/Adafruit-ST7735-Library.git
86-
https://github.com/adafruit/Adafruit_TouchScreen.git
87-
https://github.com/brentru/lvgl.git#wippersnapper
88-
https://github.com/brentru/Adafruit_LvGL_Glue.git#development
89+
https://github.com/adafruit/Adafruit_TinyUSB_Arduino.git
90+
8991

9092

9193
; Common build environment for ESP32 platform
@@ -107,9 +109,10 @@ platform = atmelsam
107109
platform_packages =
108110
platformio/framework-arduino-samd-adafruit@^1.7.13
109111
platformio/tool-jlink@^1.78811.0
110-
lib_ldf_mode = deep
112+
lib_ldf_mode = chain+
113+
lib_compat_mode = strict
111114
lib_archive = no ; debug timer issues see https://community.platformio.org/t/choose-usb-stack-as-tiny-usb/22451/5
112-
lib_ignore = OneWire
115+
lib_ignore = OneWire, USBHost
113116

114117
[common:rp2040]
115118
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
@@ -418,8 +421,9 @@ upload_port = /dev/cu.SLAB_USBtoUART
418421
[env:adafruit_pyportal_m4]
419422
extends = common:atsamd
420423
board = adafruit_pyportal_m4
421-
build_flags = -DUSE_TINYUSB=1
424+
build_flags = -DUSE_TINYUSB
422425
-DADAFRUIT_PYPORTAL
426+
extra_scripts = pre:rename_usb_config.py
423427

424428
; Adafruit PyPortal M4 Titano
425429
[env:adafruit_pyportal_m4_titano]
@@ -463,8 +467,9 @@ build_flags = -DUSE_TINYUSB
463467
[env:adafruit_metro_m4_airliftlite]
464468
extends = common:atsamd
465469
board = adafruit_metro_m4_airliftlite
466-
build_flags = -DUSE_TINYUSB=1
470+
build_flags = -DUSE_TINYUSB
467471
-DADAFRUIT_METRO_M4_AIRLIFT_LITE
472+
; extra_scripts = pre:rename_usb_config.py
468473
upload_port = /dev/cu.usbmodem1201
469474

470475

src/network_interfaces/Wippersnapper_AIRLIFT.h

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ class Wippersnapper_AIRLIFT : public Wippersnapper {
103103
_pass = WS._config.network.pass;
104104
}
105105

106-
/****************************************************************/
106+
/*******************************************************************/
107107
/*!
108-
@brief a structure to hold network information for sorting
108+
@brief fixed size structure to hold network information for sorting
109109
*/
110-
/****************************************************************/
110+
/*******************************************************************/
111111
struct WiFiNetwork {
112-
String ssid[32]; /*!< SSID (Max 32 characters + null terminator */
112+
char ssid[33]; /*!< SSID (Max 32 characters + null terminator */
113113
int32_t rssi = -99; /*!< Received Signal Strength Indicator */
114114
};
115115

@@ -148,9 +148,17 @@ class Wippersnapper_AIRLIFT : public Wippersnapper {
148148
WiFiNetwork networks[WS_MAX_SORTED_NETWORKS];
149149

150150
// Store the scanned networks in the array
151-
for (int i = 0; i < n && i < WS_MAX_SORTED_NETWORKS; ++i) {
152-
strncpy(networks[i].ssid, WiFi.SSID(i), sizeof(networks[i].ssid));
153-
networks[i].rssi = WiFi.RSSI(i);
151+
for (int i = 0; i < n; ++i) {
152+
if (i < WS_MAX_SORTED_NETWORKS){
153+
strncpy(networks[i].ssid, WiFi.SSID(i), sizeof(networks[i].ssid));
154+
networks[i].ssid[sizeof(networks[i].ssid) - 1] = '\0';
155+
networks[i].rssi = WiFi.RSSI(i);
156+
} else {
157+
WS_DEBUG_PRINT("ERROR: Too many networks found! (>");
158+
WS_DEBUG_PRINT(WS_MAX_SORTED_NETWORKS);
159+
WS_DEBUG_PRINT(") Ignoring ");
160+
WS_DEBUG_PRINT(WiFi.SSID(i));
161+
}
154162
}
155163

156164
// Sort the networks by RSSI in descending order

0 commit comments

Comments
 (0)