From 78e70fe4a264e19c0f04d62bf50c083ffc42477c Mon Sep 17 00:00:00 2001 From: Peter Jakobs Date: Thu, 31 Oct 2024 12:35:08 +0100 Subject: [PATCH 1/2] Fixed network scan on ESP32 (#2906) --- .../Components/Network/Arch/Esp32/Platform/StationImpl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sming/Components/Network/Arch/Esp32/Platform/StationImpl.cpp b/Sming/Components/Network/Arch/Esp32/Platform/StationImpl.cpp index 1c4af61451..bbaddc46c9 100644 --- a/Sming/Components/Network/Arch/Esp32/Platform/StationImpl.cpp +++ b/Sming/Components/Network/Arch/Esp32/Platform/StationImpl.cpp @@ -418,12 +418,12 @@ void StationImpl::staticScanCompleted(wifi_event_sta_scan_done_t* event, uint8_t if(station.scanCompletedCallback) { uint16_t number = event->number; wifi_ap_record_t ap_info[number]; - uint16_t ap_count{0}; + memset(ap_info, 0, sizeof(ap_info)); ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&number, ap_info)); - ESP_ERROR_CHECK(esp_wifi_scan_get_ap_num(&ap_count)); + // TODO: Handle hidden APs - for(unsigned i = 0; (i < event->number) && (i < ap_count); i++) { + for(unsigned i = 0; i < number; i++) { list.addElement(new BssInfoImpl(&ap_info[i])); } station.scanCompletedCallback(true, list); From 20b4865d7c9f1d81b1522cf1269356b0c4c90d17 Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 31 Oct 2024 20:23:32 +0000 Subject: [PATCH 2/2] Update documentation for `clang-format` (#2907) This PR updates the Sming coding style documentation as discussed in https://github.com/SmingHub/Sming/pull/2898#issuecomment-2441279933 and https://github.com/SmingHub/Sming/pull/2904#discussion_r1824291374. Sming requires version 8 which is generally no longer available in the standard repositories for recent GNU/Linux distributions. Different versions of clang-format produce different output with the same configuration. This is such a common problem that a kind soul has provided standalone builds here https://github.com/muttleyxd/clang-tools-static-binaries/releases. The default name of the clang-format executable has been changed to `clang-format-8`. This is because `clang-format` is now very unlikely to be the default installed version, and so avoids the subtle issues with running the wrong version. --- Sming/build.mk | 2 +- .../information/develop/clang-tools.rst | 42 +++++++++++++------ 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/Sming/build.mk b/Sming/build.mk index b4d50a34f9..2dc96401f2 100644 --- a/Sming/build.mk +++ b/Sming/build.mk @@ -140,7 +140,7 @@ CMAKE ?= cmake # clang-format command DEBUG_VARS += CLANG_FORMAT -CLANG_FORMAT ?= clang-format +CLANG_FORMAT ?= clang-format-8 # more tools DEBUG_VARS += AWK diff --git a/docs/source/information/develop/clang-tools.rst b/docs/source/information/develop/clang-tools.rst index 683a89bfc5..41e5606794 100644 --- a/docs/source/information/develop/clang-tools.rst +++ b/docs/source/information/develop/clang-tools.rst @@ -15,16 +15,25 @@ Note that *clang-format* is part of the main **Clang** project, whilst *clang-ti found in **clang-tools-extra**. -Installation +clang-format ------------ -In Ubuntu you should be able to install them using the following command:: +Installation +~~~~~~~~~~~~ - sudo apt-get install clang-format clang-tidy +Sming requires version 8 which is generally no longer available in the standard repositories for recent GNU/Linux distributions. +You can find standalone builds at https://github.com/muttleyxd/clang-tools-static-binaries/releases. + +For example: + +``` +export CLANG_FORMAT=/opt/clang-format-8 +wget https://github.com/muttleyxd/clang-tools-static-binaries/releases/download/master-32d3ac78/clang-format-8_linux-amd64 -O /opt/clang-format-8 +chmod +x $CLANG_FORMAT +``` + +You should persist the definition for :envvar:`CLANG_FORMAT` as Sming uses this when running the ``make cs`` commands (see below). -See the the `download `__ page -of the Clang project for installation instructions for other operating -systems. .. important:: @@ -37,10 +46,6 @@ systems. You should install the same version on your development computer. - -clang-format ------------- - Rules ~~~~~ @@ -57,6 +62,8 @@ IDE integration There are multiple existing integrations for IDEs. You can find details in the `ClangFormat documentation `__. +For VS Code/Codium install the **clang-format** extension and configure the path with the location of the **clang-format-8** executable. + For the Eclipse IDE we recommend installing the `CppStyle plugin `__. You can configure your IDE to auto-format the code on "Save" using the @@ -114,12 +121,23 @@ C, C++ or header file or a selection in it and run the ``Format`` command clang-tidy ---------- -Configuration -~~~~~~~~~~~~~ +Installation +~~~~~~~~~~~~ No specific version is required but generally you should aim to use the most recent version available in your distribution. Version 17.0.6 was used at time of writing these notes. +In Ubuntu you should be able install using the following command:: + + sudo apt-get install clang-tidy + +See the the `download `__ page +of the Clang project for installation instructions for other operating +systems. + +Configuration +~~~~~~~~~~~~~ + The default tool configuration is defined in the `.clang-tidy `__ file, located in the root directory of the framework.