Skip to content

Commit

Permalink
sack off string for static memory allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
tyeth committed Nov 26, 2024
1 parent a1ea262 commit bf2f1bb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 20 deletions.
31 changes: 18 additions & 13 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ framework = arduino
monitor_speed = 115200
lib_compat_mode = strict
lib_deps =
;;;;;;;;;;; FunHouse / LVGL Boards uncomment these ;;;;;;;;;;;;;;
; https://github.com/adafruit/Adafruit_HX8357_Library.git
; https://github.com/adafruit/Adafruit_ILI9341.git
; https://github.com/adafruit/Adafruit_STMPE610.git
; https://github.com/adafruit/Adafruit-ST7735-Library.git
; https://github.com/adafruit/Adafruit_TouchScreen.git
; https://github.com/brentru/lvgl.git#wippersnapper
; https://github.com/brentru/Adafruit_LvGL_Glue.git#development
;;;;;;;;;;; All Boards need these libraries included ;;;;;;;;;;;;;;
adafruit/Adafruit Zero DMA Library
https://github.com/adafruit/Adafruit_TinyUSB_Arduino.git
adafruit/Adafruit NeoPixel
adafruit/Adafruit SPIFlash
adafruit/Adafruit DotStar
Expand Down Expand Up @@ -78,14 +86,8 @@ lib_deps =
https://github.com/Sensirion/arduino-i2c-sen5x.git
https://github.com/adafruit/WiFiNINA.git
https://github.com/Starmbi/hp_BH1750.git
;;;;;;;;;;; FunHouse / LVGL Boards ;;;;;;;;;;;;;;
https://github.com/adafruit/Adafruit_HX8357_Library.git
https://github.com/adafruit/Adafruit_ILI9341.git
https://github.com/adafruit/Adafruit_STMPE610.git
https://github.com/adafruit/Adafruit-ST7735-Library.git
https://github.com/adafruit/Adafruit_TouchScreen.git
https://github.com/brentru/lvgl.git#wippersnapper
https://github.com/brentru/Adafruit_LvGL_Glue.git#development
https://github.com/adafruit/Adafruit_TinyUSB_Arduino.git



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

[common:rp2040]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
Expand Down Expand Up @@ -418,8 +421,9 @@ upload_port = /dev/cu.SLAB_USBtoUART
[env:adafruit_pyportal_m4]
extends = common:atsamd
board = adafruit_pyportal_m4
build_flags = -DUSE_TINYUSB=1
build_flags = -DUSE_TINYUSB
-DADAFRUIT_PYPORTAL
extra_scripts = pre:rename_usb_config.py

; Adafruit PyPortal M4 Titano
[env:adafruit_pyportal_m4_titano]
Expand Down Expand Up @@ -463,8 +467,9 @@ build_flags = -DUSE_TINYUSB
[env:adafruit_metro_m4_airliftlite]
extends = common:atsamd
board = adafruit_metro_m4_airliftlite
build_flags = -DUSE_TINYUSB=1
build_flags = -DUSE_TINYUSB
-DADAFRUIT_METRO_M4_AIRLIFT_LITE
; extra_scripts = pre:rename_usb_config.py
upload_port = /dev/cu.usbmodem1201


Expand Down
22 changes: 15 additions & 7 deletions src/network_interfaces/Wippersnapper_AIRLIFT.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ class Wippersnapper_AIRLIFT : public Wippersnapper {
_pass = WS._config.network.pass;
}

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

Expand Down Expand Up @@ -148,9 +148,17 @@ class Wippersnapper_AIRLIFT : public Wippersnapper {
WiFiNetwork networks[WS_MAX_SORTED_NETWORKS];

// Store the scanned networks in the array
for (int i = 0; i < n && i < WS_MAX_SORTED_NETWORKS; ++i) {
strncpy(networks[i].ssid, WiFi.SSID(i), sizeof(networks[i].ssid));
networks[i].rssi = WiFi.RSSI(i);
for (int i = 0; i < n; ++i) {
if (i < WS_MAX_SORTED_NETWORKS){
strncpy(networks[i].ssid, WiFi.SSID(i), sizeof(networks[i].ssid));
networks[i].ssid[sizeof(networks[i].ssid) - 1] = '\0';
networks[i].rssi = WiFi.RSSI(i);
} else {
WS_DEBUG_PRINT("ERROR: Too many networks found! (>");
WS_DEBUG_PRINT(WS_MAX_SORTED_NETWORKS);
WS_DEBUG_PRINT(") Ignoring ");
WS_DEBUG_PRINT(WiFi.SSID(i));
}
}

// Sort the networks by RSSI in descending order
Expand Down

0 comments on commit bf2f1bb

Please sign in to comment.