Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI Test: Sorting one commit ago - a single esp32 include broke samd #669

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
513de11
Update network scan to sort by RSSI
tyeth Nov 13, 2024
a5cd10f
correct ssid access for some platforms
tyeth Nov 14, 2024
34a4834
clang format "sort networks by RSSI"
tyeth Nov 14, 2024
a2dbddf
Doxygen comments for compareByRSSI
tyeth Nov 14, 2024
e493f6a
Document wifi network struct for sorting
tyeth Nov 14, 2024
747f025
Swap dynamic memory for static in wifi rssi sorting
tyeth Nov 21, 2024
3528b3f
sack off string for static memory allocation
tyeth Nov 26, 2024
4335f34
Update logging and logic
tyeth Nov 26, 2024
db43d0f
Update pico and WIFININA(arduino versions)
tyeth Nov 26, 2024
644aff9
Remove unnecessary includes + fixup esp8266
tyeth Nov 26, 2024
0f09cfd
A comes before V
tyeth Nov 26, 2024
16188e8
Fix haltError to actually enable WDT to attempt to reset
tyeth Nov 26, 2024
9c666e1
ESP8266: WiFiMulti does RSSI sorting, normal wifi begin would require…
tyeth Nov 26, 2024
c834456
remove wifi.begin from esp8266
tyeth Nov 26, 2024
37d3a91
Format ESP8266 + tweak pio target
tyeth Nov 27, 2024
d290af7
Report BSSID's to help distinguish wifi networks
tyeth Dec 10, 2024
d35508f
Update reported network not found to include BSSID/Channel
tyeth Dec 10, 2024
4ceb091
Add Mac Length define for non-picos
tyeth Dec 10, 2024
537a70a
Move wifi defines to Ws_networking
tyeth Dec 10, 2024
f155cb1
Fix SAMD bug with tinyUSB attach being called second time
tyeth Dec 11, 2024
a741846
Attempt to get Huzzah matching arduino-cli ram usage
tyeth Dec 11, 2024
5aa4a73
Correct tinyusb attach/detach usage
tyeth Dec 11, 2024
4d4dea2
Correct ++i to i++ for esp8266
tyeth Dec 11, 2024
21f893a
Remove scan print sort in favour of BSSID/RSSI/Channel (airlift)
tyeth Dec 11, 2024
f2ea9cd
Pico1w not reattaching
tyeth Dec 11, 2024
2ac1767
include defines
tyeth Dec 12, 2024
4aa19d8
Clear null secrets as some text readers wont open binary
tyeth Dec 12, 2024
314fd38
Add ESP32 include
tyeth Dec 12, 2024
eb5f05d
Flush serial when printing debug info
tyeth Dec 12, 2024
f284c16
Stop SAMD21 from flushing (overflows flash with extra routine)
tyeth Dec 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 36 additions & 15 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 @@ -408,7 +411,23 @@ extra_scripts = pre:rename_usb_config.py
[env:huzzah]
extends=common:esp8266
board = huzzah
build_flags = -DARDUINO_ESP8266_ADAFRUIT_HUZZAH
board_build.f_cpu = 80000000L
; Arduino CLI uses this from adafruit_ci#ci-wippersnapper
; esp8266:esp8266:huzzah:xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,eesz=4M2M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=115200
build_flags =
-Wl,--gc-sections
-Wl,-Map=output.map
-DARDUINO_ESP8266_ADAFRUIT_HUZZAH
-DDEBUG_ESP_PORT=Serial
-DVTABLES_IN_FLASH
-DNO_EXCEPTIONS
-DNO_STACK_SMASH_PROTECTION
-DSSL_ALL
-DMMU_3232
-DNON32XFER_FAST
-DDEBUG_DISABLED
-DDEBUG_LEVEL_NONE
board_build.eesz=4M2M
board_build.filesystem = littlefs
upload_port = /dev/cu.SLAB_USBtoUART

Expand All @@ -418,8 +437,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 +483,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 Expand Up @@ -494,7 +515,7 @@ build_flags =
-DDEBUG_RP2040_CORE
-DDEBUG_RP2040_WIFI
-DNDEBUG
-DLWIP_DEBUG
-DLWIP_DEBUG=1
-DDEBUG_RP2040_PORT=Serial1
-DDEBUG_RP2040_UART_1
-DDEBUG_RP2040_UART=1
Expand Down
14 changes: 12 additions & 2 deletions src/Wippersnapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2500,8 +2500,10 @@ void Wippersnapper::runNetFSM() {
*/
/**************************************************************************/
void Wippersnapper::haltError(String error, ws_led_status_t ledStatusColor) {
for (;;) {
WS_DEBUG_PRINT("ERROR [WDT RESET]: ");
for (int i=0;;i++) {
WS_DEBUG_PRINT("ERROR [WDT RESET IN ");
WS_DEBUG_PRINT(25 - i);
WS_DEBUG_PRINTLN("]: ");
WS_DEBUG_PRINTLN(error);
// let the WDT fail out and reset!
statusLEDSolid(ledStatusColor);
Expand All @@ -2512,6 +2514,12 @@ void Wippersnapper::haltError(String error, ws_led_status_t ledStatusColor) {
// hardware and software watchdog timers, delayMicroseconds does not.
delayMicroseconds(1000000);
#endif
if (i < 20) {
yield();
WS.feedWDT(); // feed the WDT for the first 20 seconds
} else if (i == 20) {
WS.enableWDT(5000);
}
}
}

Expand Down Expand Up @@ -2711,8 +2719,10 @@ void print_reset_reason(int reason) {
*/
/**************************************************************************/
void printDeviceInfo() {
WS_PRINTER.flush();
WS_DEBUG_PRINTLN("-------Device Information-------");
WS_DEBUG_PRINT("Firmware Version: ");
WS_PRINTER.flush();
WS_DEBUG_PRINTLN(WS_VERSION);
WS_DEBUG_PRINT("Board ID: ");
WS_DEBUG_PRINTLN(BOARD_ID);
Expand Down
19 changes: 15 additions & 4 deletions src/Wippersnapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define WIPPERSNAPPER_H

// Cpp STD
#include <algorithm>
#include <vector>

// Nanopb dependencies
Expand Down Expand Up @@ -46,17 +47,28 @@

// Define actual debug output functions when necessary.
#ifdef WS_DEBUG
#if defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRWIFI1010)
#define WS_DEBUG_PRINT(...) \
{ WS_PRINTER.print(__VA_ARGS__); } ///< Prints debug output.
{ WS_PRINTER.print(__VA_ARGS__); yield(); } ///< Prints line from debug output.
#define WS_DEBUG_PRINTLN(...) \
{ WS_PRINTER.println(__VA_ARGS__); } ///< Prints line from debug output.
{ WS_PRINTER.println(__VA_ARGS__); yield(); } ///< Prints line from debug output.
#define WS_DEBUG_PRINTHEX(...) \
{ WS_PRINTER.print(__VA_ARGS__, HEX); } ///< Prints debug output.
{ WS_PRINTER.print(__VA_ARGS__, HEX); yield(); } ///< Prints debug output.
#else
#define WS_DEBUG_PRINT(...) \
{ WS_PRINTER.print(__VA_ARGS__); WS_PRINTER.flush(); yield(); } ///< Prints line from debug output.
#define WS_DEBUG_PRINTLN(...) \
{ WS_PRINTER.println(__VA_ARGS__); WS_PRINTER.flush(); yield(); } ///< Prints line from debug output.
#define WS_DEBUG_PRINTHEX(...) \
{ WS_PRINTER.print(__VA_ARGS__, HEX); WS_PRINTER.flush(); yield(); } ///< Prints debug output.
#endif
#else
#define WS_DEBUG_PRINT(...) \
{} ///< Prints debug output
#define WS_DEBUG_PRINTLN(...) \
{} ///< Prints line from debug output.
#define WS_DEBUG_PRINTHEX(...) \
{} ///< Prints debug output.
#endif

#define WS_DELAY_WITH_WDT(timeout) \
Expand Down Expand Up @@ -215,7 +227,6 @@ typedef enum {
} fsm_net_t;

#define WS_WDT_TIMEOUT 60000 ///< WDT timeout
#define WS_MAX_ALT_WIFI_NETWORKS 3 ///< Maximum number of alternative networks
/* MQTT Configuration */
#define WS_KEEPALIVE_INTERVAL_MS \
5000 ///< Session keepalive interval time, in milliseconds
Expand Down
93 changes: 50 additions & 43 deletions src/Wippersnapper_Networking.h
Original file line number Diff line number Diff line change
@@ -1,44 +1,51 @@
/*!
* @file Wippersnapper_Networking.h
*
* This file includes network interfaces at compile-time.
*
* Adafruit invests time and resources providing this open source code,
* please support Adafruit and open-source hardware by purchasing
* products from Adafruit!
*
* Copyright (c) Brent Rubell 2020-2021 for Adafruit Industries.
*
* BSD license, all text here must be included in any redistribution.
*
*/

#ifndef WIPPERSNAPPER_NETWORKING_H
#define WIPPERSNAPPER_NETWORKING_H

#if defined(ADAFRUIT_METRO_M4_EXPRESS) || \
defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) || defined(ADAFRUIT_PYPORTAL) || \
defined(ADAFRUIT_PYPORTAL_M4_TITANO) || defined(USE_AIRLIFT)
#include "network_interfaces/Wippersnapper_AIRLIFT.h"
/** Nina-FW (adafruit fork) networking class */
typedef Wippersnapper_AIRLIFT Wippersnapper_WiFi;
#elif defined(ARDUINO_ARCH_ESP8266)
#include "network_interfaces/Wippersnapper_ESP8266.h"
/** ESP8266's networking class */
typedef Wippersnapper_ESP8266 Wippersnapper_WiFi;
#elif defined(ARDUINO_ARCH_ESP32)
#include "network_interfaces/Wippersnapper_ESP32.h"
/** ESP32's networking class */
typedef Wippersnapper_ESP32 Wippersnapper_WiFi;
#elif defined(ARDUINO_ARCH_RP2040)
#include "network_interfaces/ws_networking_pico.h"
typedef ws_networking_pico Wippersnapper_WiFi;
#elif defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRWIFI1010)
/** Nina-FW (arduino) networking class */
#include "network_interfaces/Wippersnapper_WIFININA.h"
typedef Wippersnapper_WIFININA Wippersnapper_WiFi;
#else
#warning "Must define network interface in config.h!"
#endif

/*!
* @file Wippersnapper_Networking.h
*
* This file includes network interfaces at compile-time.
*
* Adafruit invests time and resources providing this open source code,
* please support Adafruit and open-source hardware by purchasing
* products from Adafruit!
*
* Copyright (c) Brent Rubell 2020-2021 for Adafruit Industries.
*
* BSD license, all text here must be included in any redistribution.
*
*/

#ifndef WIPPERSNAPPER_NETWORKING_H
#define WIPPERSNAPPER_NETWORKING_H

#ifndef WL_MAC_ADDR_LENGTH
#define WL_MAC_ADDR_LENGTH 6 // MAC address length - from RP2040 BSP
#endif
#define WS_MAX_SORTED_NETWORKS 15 ///< Maximum number of networks to sort
#define WS_MAX_ALT_WIFI_NETWORKS 3 ///< Maximum number of alternative networks


#if defined(ADAFRUIT_METRO_M4_EXPRESS) || \
defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) || defined(ADAFRUIT_PYPORTAL) || \
defined(ADAFRUIT_PYPORTAL_M4_TITANO) || defined(USE_AIRLIFT)
#include "network_interfaces/Wippersnapper_AIRLIFT.h"
/** Nina-FW (adafruit fork) networking class */
typedef Wippersnapper_AIRLIFT Wippersnapper_WiFi;
#elif defined(ARDUINO_ARCH_ESP8266)
#include "network_interfaces/Wippersnapper_ESP8266.h"
/** ESP8266's networking class */
typedef Wippersnapper_ESP8266 Wippersnapper_WiFi;
#elif defined(ARDUINO_ARCH_ESP32)
#include "network_interfaces/Wippersnapper_ESP32.h"
/** ESP32's networking class */
typedef Wippersnapper_ESP32 Wippersnapper_WiFi;
#elif defined(ARDUINO_ARCH_RP2040)
#include "network_interfaces/ws_networking_pico.h"
typedef ws_networking_pico Wippersnapper_WiFi;
#elif defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRWIFI1010)
/** Nina-FW (arduino) networking class */
#include "network_interfaces/Wippersnapper_WIFININA.h"
typedef Wippersnapper_WIFININA Wippersnapper_WiFi;
#else
#warning "Must define network interface in config.h!"
#endif

#endif // WIPPERSNAPPER_NETWORKING_H
67 changes: 50 additions & 17 deletions src/network_interfaces/Wippersnapper_AIRLIFT.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,34 @@ class Wippersnapper_AIRLIFT : public Wippersnapper {
_pass = WS._config.network.pass;
}

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

/*******************************************************************/
/*!
@brief Comparison function to sort by RSSI in descending order
@param a
WiFiNetwork object
@param b
WiFiNetwork object
@returns True if a.rssi > b.rssi
*/
/*******************************************************************/
bool static compareByRSSI(const WiFiNetwork &a, const WiFiNetwork &b) {
return a.rssi > b.rssi;
}

/***********************************************************/
/*!
@brief Performs a scan of local WiFi networks.
@returns True if `_network_ssid` is found, False otherwise.
@brief Performs a scan of local WiFi networks.
@returns True if `_network_ssid` is found, False otherwise.
*/
/***********************************************************/
bool check_valid_ssid() {
Expand All @@ -119,26 +143,35 @@ class Wippersnapper_AIRLIFT : public Wippersnapper {
return false;
}

// Was the network within secrets.json found?
for (int i = 0; i < n; ++i) {
if (strcmp(_ssid, WiFi.SSID(i)) == 0) {
WS_DEBUG_PRINT("SSID found! RSSI: ");
WS_DEBUG_PRINTLN(WiFi.RSSI(i));
return true;
}
}
bool foundNetwork = false;

// User-set network not found, print scan results to serial console
WS_DEBUG_PRINTLN("ERROR: Your requested WiFi network was not found!");
WS_DEBUG_PRINTLN("WipperSnapper found these WiFi networks: ");
for (int i = 0; i < n; ++i) {
WS_DEBUG_PRINTLN("WipperSnapper found these WiFi networks:");
for (uint8_t i = 0; i < n; i++) {
if (strcmp(WiFi.SSID(i), _ssid) == 0) {
foundNetwork = true;
break;
}
WS_DEBUG_PRINT(WiFi.SSID(i));
WS_DEBUG_PRINT(" ");
WS_DEBUG_PRINT(" (");
uint8_t BSSID[WL_MAC_ADDR_LENGTH];
WiFi.BSSID(i, BSSID);
for (int m = 0; m < WL_MAC_ADDR_LENGTH; m++) {
if (m != 0)
WS_DEBUG_PRINT(":");
WS_DEBUG_PRINTHEX(BSSID[m]);
}
WS_DEBUG_PRINT(") ");
WS_DEBUG_PRINT(WiFi.RSSI(i));
WS_DEBUG_PRINTLN("dB");
WS_DEBUG_PRINT("dB (ch");
WS_DEBUG_PRINT(WiFi.channel(i))
WS_DEBUG_PRINTLN(")");
}

return false;
if(foundNetwork == 0) {
WS_DEBUG_PRINTLN("ERROR: Your requested WiFi network was not found!");
return false;
}
return true;
}

/********************************************************/
Expand Down
Loading
Loading