From 555e137f498c984b02ea2a4aeb7d8fd8a328fd95 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Wed, 5 Jun 2024 09:11:46 +0100 Subject: [PATCH] Updates for arduino-esp32 v3.0.1 --- .../workflows/non-release-build_v3.0.0.yml | 14 +- Firmware/RTK_Everywhere/Patch/WiFiScan.cpp | 280 ------------------ Firmware/RTK_Everywhere/Patch/WiFiScan.h | 71 ----- Firmware/RTK_Everywhere/makefile | 6 +- 4 files changed, 3 insertions(+), 368 deletions(-) delete mode 100644 Firmware/RTK_Everywhere/Patch/WiFiScan.cpp delete mode 100644 Firmware/RTK_Everywhere/Patch/WiFiScan.h diff --git a/.github/workflows/non-release-build_v3.0.0.yml b/.github/workflows/non-release-build_v3.0.0.yml index 0c13f3e78..1530b2ad1 100644 --- a/.github/workflows/non-release-build_v3.0.0.yml +++ b/.github/workflows/non-release-build_v3.0.0.yml @@ -9,7 +9,7 @@ env: FIRMWARE_VERSION_MINOR: 99 POINTPERFECT_LBAND_TOKEN: ${{ secrets.POINTPERFECT_LBAND_TOKEN }} POINTPERFECT_IP_TOKEN: ${{ secrets.POINTPERFECT_IP_TOKEN }} - CORE_VERSION: 3.0.0 + CORE_VERSION: 3.0.1 jobs: build: @@ -64,18 +64,8 @@ jobs: - name: Update library index run: arduino-cli lib update-index - # We need v3.0.1-rc1 to fix the WiFiMulti.run timeout issue - but it is not yet available - #- name: Install platform - # run: arduino-cli core install esp32:esp32@${{ env.CORE_VERSION }} - - # So, right now, we need to use v3.0.0 and patch it - name: Install platform - run: arduino-cli core install esp32:esp32@3.0.0 - - name: Patch v3.0.0 - run: | - cd Firmware/RTK_Everywhere/Patch/ - cp WiFiScan.h /home/runner/.arduino15/packages/esp32/hardware/esp32/3.0.0/libraries/WiFi/src/WiFiScan.h - cp WiFiScan.cpp /home/runner/.arduino15/packages/esp32/hardware/esp32/3.0.0/libraries/WiFi/src/WiFiScan.cpp + run: arduino-cli core install esp32:esp32@${{ env.CORE_VERSION }} - name: Get Known Libraries run: arduino-cli lib install diff --git a/Firmware/RTK_Everywhere/Patch/WiFiScan.cpp b/Firmware/RTK_Everywhere/Patch/WiFiScan.cpp deleted file mode 100644 index 70d3fb31c..000000000 --- a/Firmware/RTK_Everywhere/Patch/WiFiScan.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/* - ESP8266WiFiScan.cpp - WiFi library for esp8266 - - Copyright (c) 2014 Ivan Grokhotkov. All rights reserved. - This file is part of the esp8266 core for Arduino environment. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - 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, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Reworked on 28 Dec 2015 by Markus Sattler - - */ - -#include "WiFi.h" -#include "WiFiGeneric.h" -#include "WiFiScan.h" -#if SOC_WIFI_SUPPORTED - -extern "C" { -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "lwip/err.h" -} - -bool WiFiScanClass::_scanAsync = false; -uint32_t WiFiScanClass::_scanStarted = 0; -uint32_t WiFiScanClass::_scanTimeout = 60000; -uint16_t WiFiScanClass::_scanCount = 0; -void *WiFiScanClass::_scanResult = 0; - -void WiFiScanClass::setScanTimeout(uint32_t ms) { - WiFiScanClass::_scanTimeout = ms; -} - -/** - * Start scan WiFi networks available - * @param async run in async mode - * @param show_hidden show hidden networks - * @return Number of discovered networks - */ -int16_t - WiFiScanClass::scanNetworks(bool async, bool show_hidden, bool passive, uint32_t max_ms_per_chan, uint8_t channel, const char *ssid, const uint8_t *bssid) { - if (WiFiGenericClass::getStatusBits() & WIFI_SCANNING_BIT) { - return WIFI_SCAN_RUNNING; - } - - WiFiScanClass::_scanAsync = async; - - WiFi.enableSTA(true); - - scanDelete(); - - wifi_scan_config_t config; - config.ssid = (uint8_t *)ssid; - config.bssid = (uint8_t *)bssid; - config.channel = channel; - config.show_hidden = show_hidden; - if (passive) { - config.scan_type = WIFI_SCAN_TYPE_PASSIVE; - config.scan_time.passive = max_ms_per_chan; - } else { - config.scan_type = WIFI_SCAN_TYPE_ACTIVE; - config.scan_time.active.min = 100; - config.scan_time.active.max = max_ms_per_chan; - } - if (esp_wifi_scan_start(&config, false) == ESP_OK) { - _scanStarted = millis(); - if (!_scanStarted) { //Prevent 0 from millis overflow - ++_scanStarted; - } - - WiFiGenericClass::clearStatusBits(WIFI_SCAN_DONE_BIT); - WiFiGenericClass::setStatusBits(WIFI_SCANNING_BIT); - - if (WiFiScanClass::_scanAsync) { - return WIFI_SCAN_RUNNING; - } - if (WiFiGenericClass::waitStatusBits(WIFI_SCAN_DONE_BIT, _scanTimeout)) { - return (int16_t)WiFiScanClass::_scanCount; - } - } - return WIFI_SCAN_FAILED; -} - -/** - * private - * scan callback - * @param result void *arg - * @param status STATUS - */ -void WiFiScanClass::_scanDone() { - esp_wifi_scan_get_ap_num(&(WiFiScanClass::_scanCount)); - if (WiFiScanClass::_scanCount) { - WiFiScanClass::_scanResult = new wifi_ap_record_t[WiFiScanClass::_scanCount]; - if (!WiFiScanClass::_scanResult || esp_wifi_scan_get_ap_records(&(WiFiScanClass::_scanCount), (wifi_ap_record_t *)_scanResult) != ESP_OK) { - WiFiScanClass::_scanCount = 0; - } - } - WiFiScanClass::_scanStarted = 0; //Reset after a scan is completed for normal behavior - WiFiGenericClass::setStatusBits(WIFI_SCAN_DONE_BIT); - WiFiGenericClass::clearStatusBits(WIFI_SCANNING_BIT); -} - -/** - * - * @param i specify from which network item want to get the information - * @return bss_info * - */ -void *WiFiScanClass::_getScanInfoByIndex(int i) { - if (!WiFiScanClass::_scanResult || (size_t)i >= WiFiScanClass::_scanCount) { - return 0; - } - return reinterpret_cast(WiFiScanClass::_scanResult) + i; -} - -/** - * called to get the scan state in Async mode - * @return scan result or status - * -1 if scan not fin - * -2 if scan not triggered - */ -int16_t WiFiScanClass::scanComplete() { - if (WiFiGenericClass::getStatusBits() & WIFI_SCAN_DONE_BIT) { - return WiFiScanClass::_scanCount; - } - - if (WiFiGenericClass::getStatusBits() & WIFI_SCANNING_BIT) { - return WIFI_SCAN_RUNNING; - } - // last one to avoid time affecting Async mode - if (WiFiScanClass::_scanStarted - && (millis() - WiFiScanClass::_scanStarted) - > WiFiScanClass::_scanTimeout) { //Check is scan was started and if the delay expired, return WIFI_SCAN_FAILED in this case - WiFiGenericClass::clearStatusBits(WIFI_SCANNING_BIT); - return WIFI_SCAN_FAILED; - } - - return WIFI_SCAN_FAILED; -} - -/** - * delete last scan result from RAM - */ -void WiFiScanClass::scanDelete() { - WiFiGenericClass::clearStatusBits(WIFI_SCAN_DONE_BIT); - if (WiFiScanClass::_scanResult) { - delete[] reinterpret_cast(WiFiScanClass::_scanResult); - WiFiScanClass::_scanResult = 0; - WiFiScanClass::_scanCount = 0; - } -} - -/** - * loads all infos from a scanned wifi in to the ptr parameters - * @param networkItem uint8_t - * @param ssid const char** - * @param encryptionType uint8_t * - * @param RSSI int32_t * - * @param BSSID uint8_t ** - * @param channel int32_t * - * @return (true if ok) - */ -bool WiFiScanClass::getNetworkInfo(uint8_t i, String &ssid, uint8_t &encType, int32_t &rssi, uint8_t *&bssid, int32_t &channel) { - wifi_ap_record_t *it = reinterpret_cast(_getScanInfoByIndex(i)); - if (!it) { - return false; - } - ssid = (const char *)it->ssid; - encType = it->authmode; - rssi = it->rssi; - bssid = it->bssid; - channel = it->primary; - return true; -} - -/** - * Return the SSID discovered during the network scan. - * @param i specify from which network item want to get the information - * @return ssid string of the specified item on the networks scanned list - */ -String WiFiScanClass::SSID(uint8_t i) { - wifi_ap_record_t *it = reinterpret_cast(_getScanInfoByIndex(i)); - if (!it) { - return String(); - } - return String(reinterpret_cast(it->ssid)); -} - -/** - * Return the encryption type of the networks discovered during the scanNetworks - * @param i specify from which network item want to get the information - * @return encryption type (enum wl_enc_type) of the specified item on the networks scanned list - */ -wifi_auth_mode_t WiFiScanClass::encryptionType(uint8_t i) { - wifi_ap_record_t *it = reinterpret_cast(_getScanInfoByIndex(i)); - if (!it) { - return WIFI_AUTH_OPEN; - } - return it->authmode; -} - -/** - * Return the RSSI of the networks discovered during the scanNetworks - * @param i specify from which network item want to get the information - * @return signed value of RSSI of the specified item on the networks scanned list - */ -int32_t WiFiScanClass::RSSI(uint8_t i) { - wifi_ap_record_t *it = reinterpret_cast(_getScanInfoByIndex(i)); - if (!it) { - return 0; - } - return it->rssi; -} - -/** - * return MAC / BSSID of scanned wifi - * @param i specify from which network item want to get the information - * @param buff optional buffer for the result uint8_t array with length 6 - * @return uint8_t * MAC / BSSID of scanned wifi - */ -uint8_t *WiFiScanClass::BSSID(uint8_t i, uint8_t *buff) { - wifi_ap_record_t *it = reinterpret_cast(_getScanInfoByIndex(i)); - if (buff != NULL) { - if (!it) { - memset(buff, 0, 6); - } else { - memcpy(buff, it->bssid, 6); - } - return buff; - } - if (!it) { - return 0; - } - return it->bssid; -} - -/** - * return MAC / BSSID of scanned wifi - * @param i specify from which network item want to get the information - * @return String MAC / BSSID of scanned wifi - */ -String WiFiScanClass::BSSIDstr(uint8_t i) { - char mac[18] = {0}; - wifi_ap_record_t *it = reinterpret_cast(_getScanInfoByIndex(i)); - if (!it) { - return String(); - } - sprintf(mac, "%02X:%02X:%02X:%02X:%02X:%02X", it->bssid[0], it->bssid[1], it->bssid[2], it->bssid[3], it->bssid[4], it->bssid[5]); - return String(mac); -} - -int32_t WiFiScanClass::channel(uint8_t i) { - wifi_ap_record_t *it = reinterpret_cast(_getScanInfoByIndex(i)); - if (!it) { - return 0; - } - return it->primary; -} - -#endif /* SOC_WIFI_SUPPORTED */ diff --git a/Firmware/RTK_Everywhere/Patch/WiFiScan.h b/Firmware/RTK_Everywhere/Patch/WiFiScan.h deleted file mode 100644 index 5e09a9335..000000000 --- a/Firmware/RTK_Everywhere/Patch/WiFiScan.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - ESP8266WiFiScan.h - esp8266 Wifi support. - Based on WiFi.h from Ardiono WiFi shield library. - Copyright (c) 2011-2014 Arduino. All right reserved. - Modified by Ivan Grokhotkov, December 2014 - Reworked by Markus Sattler, December 2015 - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - 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, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#pragma once - -#include "soc/soc_caps.h" -#if SOC_WIFI_SUPPORTED - -#include "WiFiType.h" -#include "WiFiGeneric.h" - -class WiFiScanClass { - -public: - void setScanTimeout(uint32_t ms); - - int16_t scanNetworks( - bool async = false, bool show_hidden = false, bool passive = false, uint32_t max_ms_per_chan = 300, uint8_t channel = 0, const char *ssid = nullptr, - const uint8_t *bssid = nullptr - ); - - int16_t scanComplete(); - void scanDelete(); - - // scan result - bool getNetworkInfo(uint8_t networkItem, String &ssid, uint8_t &encryptionType, int32_t &RSSI, uint8_t *&BSSID, int32_t &channel); - - String SSID(uint8_t networkItem); - wifi_auth_mode_t encryptionType(uint8_t networkItem); - int32_t RSSI(uint8_t networkItem); - uint8_t *BSSID(uint8_t networkItem, uint8_t *bssid = NULL); - String BSSIDstr(uint8_t networkItem); - int32_t channel(uint8_t networkItem); - static void *getScanInfoByIndex(int i) { - return _getScanInfoByIndex(i); - }; - - static void _scanDone(); - -protected: - static bool _scanAsync; - - static uint32_t _scanStarted; - static uint32_t _scanTimeout; - static uint16_t _scanCount; - - static void *_scanResult; - - static void *_getScanInfoByIndex(int i); -}; - -#endif /* SOC_WIFI_SUPPORTED */ diff --git a/Firmware/RTK_Everywhere/makefile b/Firmware/RTK_Everywhere/makefile index cfac5d2df..c552492dd 100644 --- a/Firmware/RTK_Everywhere/makefile +++ b/Firmware/RTK_Everywhere/makefile @@ -38,7 +38,7 @@ arduino-config: .PHONY: lib-update -ESP_CORE_VERSION=3.0.0 +ESP_CORE_VERSION=3.0.1 lib-update: arduino-cli core update-index @@ -75,13 +75,9 @@ endif patch: Patch/* ifeq ($(OS),Windows_NT) - copy Patch\WiFiScan.h C:\Users\$(USERNAME)\AppData\Local\Arduino15\packages\esp32\hardware\esp32\$(ESP_CORE_VERSION)\libraries\WiFi\src\WiFiScan.h - copy Patch\WiFiScan.cpp C:\Users\$(USERNAME)\AppData\Local\Arduino15\packages\esp32\hardware\esp32\$(ESP_CORE_VERSION)\libraries\WiFi\src\WiFiScan.cpp copy Patch\BleSerial.cpp C:\Users\$(USERNAME)\Documents\Arduino\libraries\ESP32_BleSerial\src\BleSerial.cpp else # Linux may need something like: - cp Patch/WiFiScan.h ~/.arduino15/packages/esp32/hardware/esp32/$(ESP_CORE_VERSION)/libraries/WiFi/src/WiFiScan.h - cp Patch/WiFiScan.cpp ~/.arduino15/packages/esp32/hardware/esp32/$(ESP_CORE_VERSION)/libraries/WiFi/src/WiFiScan.cpp cp Patch/BleSerial.cpp ~/Arduino/libraries/ESP32_BleSerial/src/BleSerial.cpp endif