From 304386172a90c47c474e6416151fb69c942ee846 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Sep 2023 08:16:41 +0000 Subject: [PATCH 01/10] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/compile-examples.yml | 4 ++-- .github/workflows/spell-check.yml | 2 +- .github/workflows/sync-labels.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 81e843dd..7f2ed318 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -18,7 +18,7 @@ jobs: - arduino:renesas_uno:unor4wifi steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: arduino/compile-sketches@v1 with: github-token: ${{ secrets.GITHUB_TOKEN }} @@ -39,7 +39,7 @@ jobs: #- esp32:esp32:esp32h2 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: arduino/compile-sketches@v1 with: github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml index 0cbdde58..94b57020 100644 --- a/.github/workflows/spell-check.yml +++ b/.github/workflows/spell-check.yml @@ -8,7 +8,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Spell check uses: arduino/actions/libraries/spell-check@master diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 94938f35..9cde1acc 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -27,7 +27,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Download JSON schema for labels configuration file id: download-schema @@ -105,7 +105,7 @@ jobs: echo "::set-output name=flag::--dry-run" - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Download configuration files artifact uses: actions/download-artifact@v3 From de0bcbbe5ef3522eb2c0652b99d5351212765e95 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Thu, 26 Oct 2023 17:06:06 +0200 Subject: [PATCH 02/10] Fix functionality on Giga CM4 core Requires https://github.com/arduino/ArduinoCore-mbed/pull/741 --- src/local/BLELocalDevice.cpp | 3 +++ src/utility/CordioHCICustomDriver.h | 17 +++++++++++++++++ src/utility/HCICordioTransport.cpp | 10 ++++++---- src/utility/HCIUartTransport.cpp | 4 +++- 4 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 src/utility/CordioHCICustomDriver.h diff --git a/src/local/BLELocalDevice.cpp b/src/local/BLELocalDevice.cpp index 146d99b9..be603364 100644 --- a/src/local/BLELocalDevice.cpp +++ b/src/local/BLELocalDevice.cpp @@ -72,7 +72,10 @@ int BLELocalDevice::begin() #elif defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA) // BT_REG_ON -> HIGH pinMode(BT_REG_ON, OUTPUT); + digitalWrite(BT_REG_ON, LOW); + delay(500); digitalWrite(BT_REG_ON, HIGH); + delay(500); #elif defined(ARDUINO_PORTENTA_C33) #define NINA_GPIO0 (100) #define NINA_RESETN (101) diff --git a/src/utility/CordioHCICustomDriver.h b/src/utility/CordioHCICustomDriver.h new file mode 100644 index 00000000..fc062ee8 --- /dev/null +++ b/src/utility/CordioHCICustomDriver.h @@ -0,0 +1,17 @@ +#if defined(CORE_CM4) + +#include "CyH4TransportDriver.h" + +ble::vendor::cypress_ble::CyH4TransportDriver& ble_cordio_get_h4_transport_driver() +{ + static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver( + /* TX */ CYBSP_BT_UART_TX, /* RX */ CYBSP_BT_UART_RX, + /* cts */ CYBSP_BT_UART_CTS, /* rts */ CYBSP_BT_UART_RTS, NC, DEF_BT_BAUD_RATE, + CYBSP_BT_HOST_WAKE, CYBSP_BT_DEVICE_WAKE + ); + return s_transport_driver; +} + +#define CUSTOM_HCI_DRIVER + +#endif \ No newline at end of file diff --git a/src/utility/HCICordioTransport.cpp b/src/utility/HCICordioTransport.cpp index 947378cf..7848712f 100644 --- a/src/utility/HCICordioTransport.cpp +++ b/src/utility/HCICordioTransport.cpp @@ -17,8 +17,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#if defined(ARDUINO_ARCH_MBED) && !defined(TARGET_NANO_RP2040_CONNECT) - +#if defined(ARDUINO_ARCH_MBED) && !defined(TARGET_NANO_RP2040_CONNECT) // && !defined(CORE_CM4) #include #include @@ -53,6 +52,8 @@ #define BLE_NAMESPACE ble::vendor::cordio #endif +#include "CordioHCICustomDriver.h" + extern BLE_NAMESPACE::CordioHCIDriver& ble_cordio_get_hci_driver(); namespace BLE_NAMESPACE { @@ -181,7 +182,7 @@ HCICordioTransportClass::~HCICordioTransportClass() { } -#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA) +#if (defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA)) && !defined(CUSTOM_HCI_DRIVER) events::EventQueue eventQueue(10 * EVENTS_EVENT_SIZE); void scheduleMbedBleEvents(BLE::OnEventsToProcessCallbackContext *context) { eventQueue.call(mbed::Callback(&context->ble, &BLE::processEvents)); @@ -201,7 +202,8 @@ int HCICordioTransportClass::begin() init_wsf(bufPoolDesc); #endif -#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA) +#if (defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA)) && !defined(CUSTOM_HCI_DRIVER) + BLE &ble = BLE::Instance(); ble.onEventsToProcess(scheduleMbedBleEvents); diff --git a/src/utility/HCIUartTransport.cpp b/src/utility/HCIUartTransport.cpp index d3c44d8f..d6f9ec3e 100644 --- a/src/utility/HCIUartTransport.cpp +++ b/src/utility/HCIUartTransport.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#if !defined(ARDUINO_ARCH_MBED) && !defined(ESP32) && !defined(ARDUINO_UNOR4_WIFI) || defined(TARGET_NANO_RP2040_CONNECT) +#if !defined(ARDUINO_ARCH_MBED) && !defined(ESP32) && !defined(ARDUINO_UNOR4_WIFI) || defined(TARGET_NANO_RP2040_CONNECT) //|| defined(CORE_CM4) #include "HCIUartTransport.h" @@ -33,6 +33,8 @@ #define SerialHCI Serial3 #elif defined(ARDUINO_PORTENTA_C33) #define SerialHCI Serial5 +#elif defined(ARDUINO_GIGA) +arduino::UART SerialHCI(CYBSP_BT_UART_TX, CYBSP_BT_UART_RX, CYBSP_BT_UART_RTS, CYBSP_BT_UART_CTS); #else #error "Unsupported board selected!" #endif From 93802d08dbf2e2b4e61bac8c4098eb502cc212e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 Feb 2024 06:29:02 +0100 Subject: [PATCH 03/10] Bump actions/download-artifact from 3 to 4 (#336) Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/sync-labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 9cde1acc..885a8ac0 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -108,7 +108,7 @@ jobs: uses: actions/checkout@v4 - name: Download configuration files artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: ${{ env.CONFIGURATIONS_ARTIFACT }} path: ${{ env.CONFIGURATIONS_FOLDER }} From 416506ef203dbbf3549ffabeb82ab96d1291ea6e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 Feb 2024 06:29:12 +0100 Subject: [PATCH 04/10] Bump actions/upload-artifact from 3 to 4 (#337) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/sync-labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 885a8ac0..2e1d6e05 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -70,7 +70,7 @@ jobs: file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }} - name: Pass configuration files to next job via workflow artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: path: | *.yaml From 37337ad2405109e573eaaafb49dfac4b6a5eec23 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 Feb 2024 06:29:28 +0100 Subject: [PATCH 05/10] Bump geekyeggo/delete-artifact from 2 to 4 (#340) Bumps [geekyeggo/delete-artifact](https://github.com/geekyeggo/delete-artifact) from 2 to 4. - [Release notes](https://github.com/geekyeggo/delete-artifact/releases) - [Changelog](https://github.com/GeekyEggo/delete-artifact/blob/main/CHANGELOG.md) - [Commits](https://github.com/geekyeggo/delete-artifact/compare/v2...v4) --- updated-dependencies: - dependency-name: geekyeggo/delete-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/sync-labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 2e1d6e05..47ac50a4 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -114,7 +114,7 @@ jobs: path: ${{ env.CONFIGURATIONS_FOLDER }} - name: Remove unneeded artifact - uses: geekyeggo/delete-artifact@v2 + uses: geekyeggo/delete-artifact@v4 with: name: ${{ env.CONFIGURATIONS_ARTIFACT }} From 99159f05e19b583e1464e3087fcbd7071f1e8ea4 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Wed, 21 Feb 2024 10:55:28 +0100 Subject: [PATCH 06/10] Portenta_H7_M4: provide the correct define Fixes #333 again (not only for Giga) --- src/local/BLELocalDevice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/local/BLELocalDevice.cpp b/src/local/BLELocalDevice.cpp index be603364..1d1036be 100644 --- a/src/local/BLELocalDevice.cpp +++ b/src/local/BLELocalDevice.cpp @@ -25,7 +25,7 @@ #include "BLELocalDevice.h" -#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_OPTA) +#if defined(PORTENTA_H7_PINS) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_OPTA) #ifndef BT_REG_ON #define BT_REG_ON PJ_12 #endif @@ -69,7 +69,7 @@ int BLELocalDevice::begin() delay(100); digitalWrite(NINA_RESETN, HIGH); delay(750); -#elif defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA) +#elif defined(PORTENTA_H7_PINS) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA) // BT_REG_ON -> HIGH pinMode(BT_REG_ON, OUTPUT); digitalWrite(BT_REG_ON, LOW); From 4a85fec0ae95462b2d96e824ff6fad6aae6e156a Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Tue, 19 Mar 2024 14:45:48 +0100 Subject: [PATCH 07/10] CI: Add arduino/report-size-deltas action. (#354) This action comments on the pull request with a report on the resulting change in memory usage of the Arduino sketches compiled by the arduino/compile-sketches action. --- .github/workflows/compile-examples.yml | 83 ++++++++++++++++++++---- .github/workflows/report-size-deltas.yml | 24 +++++++ 2 files changed, 94 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/report-size-deltas.yml diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 7f2ed318..706ccb4c 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -1,29 +1,86 @@ name: Compile Examples + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows on: - - push - - pull_request + push: + paths: + - ".github/workflows/compile-examples.yml" + - "examples/**" + - "src/**" + pull_request: + paths: + - ".github/workflows/compile-examples.yml" + - "examples/**" + - "src/**" + schedule: + # Run every Tuesday at 8 AM UTC to catch breakage caused by changes to external resources (libraries, platforms). + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: jobs: build: + name: ${{ matrix.board.fqbn }} runs-on: ubuntu-latest + env: + SKETCHES_REPORTS_PATH: sketches-reports + strategy: + fail-fast: false + matrix: - fqbn: - - arduino:samd:mkrwifi1010 - - arduino:samd:nano_33_iot - - arduino:megaavr:uno2018:mode=on - - arduino:mbed:nano33ble - - arduino:mbed_nano:nanorp2040connect - - arduino:renesas_uno:unor4wifi + board: + - fqbn: arduino:samd:mkrwifi1010 + platforms: | + - name: arduino:samd + artifact-name-suffix: arduino-samd-mkrwifi1010 + - fqbn: arduino:samd:nano_33_iot + platforms: | + - name: arduino:samd + artifact-name-suffix: arduino-samd-nano_33_iot + - fqbn: arduino:megaavr:uno2018:mode=on + platforms: | + - name: arduino:megaavr + artifact-name-suffix: arduino-megaavr-uno2018 + - fqbn: arduino:mbed_nano:nano33ble + platforms: | + - name: arduino:mbed_nano + artifact-name-suffix: arduino-mbed_nano-nano33ble + - fqbn: arduino:mbed_nano:nanorp2040connect + platforms: | + - name: arduino:mbed_nano + artifact-name-suffix: arduino-mbed_nano-nanorp2040connect + - fqbn: arduino:renesas_uno:unor4wifi + platforms: | + - name: arduino:renesas_uno + artifact-name-suffix: arduino-renesas_uno-unor4wifi steps: - - uses: actions/checkout@v4 - - uses: arduino/compile-sketches@v1 + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Compile examples + uses: arduino/compile-sketches@v1 with: github-token: ${{ secrets.GITHUB_TOKEN }} - fqbn: ${{ matrix.fqbn }} - + fqbn: ${{ matrix.board.fqbn }} + platforms: ${{ matrix.board.platforms }} + libraries: | + # Install the library from the local path. + - source-path: ./ + sketch-paths: | + - examples + enable-deltas-report: true + sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} + + - name: Save sketches report as workflow artifact + uses: actions/upload-artifact@v4 + with: + if-no-files-found: error + path: ${{ env.SKETCHES_REPORTS_PATH }} + name: sketches-report-${{ matrix.board.artifact-name-suffix }} + build-for-esp32: runs-on: ubuntu-latest diff --git a/.github/workflows/report-size-deltas.yml b/.github/workflows/report-size-deltas.yml new file mode 100644 index 00000000..39e2a0ad --- /dev/null +++ b/.github/workflows/report-size-deltas.yml @@ -0,0 +1,24 @@ +name: Report Size Deltas + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/report-size-deltas.yml" + schedule: + # Run at the minimum interval allowed by GitHub Actions. + # Note: GitHub Actions periodically has outages which result in workflow failures. + # In this event, the workflows will start passing again once the service recovers. + - cron: "*/5 * * * *" + workflow_dispatch: + repository_dispatch: + +jobs: + report: + runs-on: ubuntu-latest + steps: + - name: Comment size deltas reports to PRs + uses: arduino/report-size-deltas@v1 + with: + # Regex matching the names of the workflow artifacts created by the "Compile Examples" workflow + sketches-reports-source: ^sketches-report-.+ From 98ff550988912ffbaeb1d877970e9e05f1de0599 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Mar 2024 14:46:11 +0100 Subject: [PATCH 08/10] Bump geekyeggo/delete-artifact from 4 to 5 (#356) Bumps [geekyeggo/delete-artifact](https://github.com/geekyeggo/delete-artifact) from 4 to 5. - [Release notes](https://github.com/geekyeggo/delete-artifact/releases) - [Changelog](https://github.com/GeekyEggo/delete-artifact/blob/main/CHANGELOG.md) - [Commits](https://github.com/geekyeggo/delete-artifact/compare/v4...v5) --- updated-dependencies: - dependency-name: geekyeggo/delete-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/sync-labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 47ac50a4..53a9f54f 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -114,7 +114,7 @@ jobs: path: ${{ env.CONFIGURATIONS_FOLDER }} - name: Remove unneeded artifact - uses: geekyeggo/delete-artifact@v4 + uses: geekyeggo/delete-artifact@v5 with: name: ${{ env.CONFIGURATIONS_ARTIFACT }} From 93315a9d727902b1a5c7dcf3f10ac280e07be20f Mon Sep 17 00:00:00 2001 From: Leonardo Cavagnis Date: Fri, 7 Jun 2024 17:01:30 +0200 Subject: [PATCH 09/10] add support for silabs core --- src/BLECharacteristic.cpp | 2 + src/BLEDevice.cpp | 2 + src/BLEService.cpp | 2 + src/utility/ATT.cpp | 2 + src/utility/HCISilabsTransport.cpp | 130 +++++++++++++++++++++++++++++ src/utility/HCISilabsTransport.h | 42 ++++++++++ src/utility/HCIUartTransport.cpp | 2 +- 7 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 src/utility/HCISilabsTransport.cpp create mode 100644 src/utility/HCISilabsTransport.h diff --git a/src/BLECharacteristic.cpp b/src/BLECharacteristic.cpp index cb9783ce..bfaee3ff 100644 --- a/src/BLECharacteristic.cpp +++ b/src/BLECharacteristic.cpp @@ -24,6 +24,8 @@ #include "BLECharacteristic.h" +extern "C" int strcasecmp(char const *a, char const *b); + BLECharacteristic::BLECharacteristic() : BLECharacteristic((BLELocalCharacteristic*)NULL) { diff --git a/src/BLEDevice.cpp b/src/BLEDevice.cpp index 5f64c1d6..e9ca9b99 100644 --- a/src/BLEDevice.cpp +++ b/src/BLEDevice.cpp @@ -25,6 +25,8 @@ #include "BLEDevice.h" +extern "C" int strcasecmp(char const *a, char const *b); + BLEDevice::BLEDevice() : _advertisementTypeMask(0), _eirDataLength(0), diff --git a/src/BLEService.cpp b/src/BLEService.cpp index ed54f9ff..88687b61 100644 --- a/src/BLEService.cpp +++ b/src/BLEService.cpp @@ -22,6 +22,8 @@ #include "BLEService.h" +extern "C" int strcasecmp(char const *a, char const *b); + BLEService::BLEService() : BLEService((BLELocalService*)NULL) { diff --git a/src/utility/ATT.cpp b/src/utility/ATT.cpp index acdf5a9f..b1796c90 100644 --- a/src/utility/ATT.cpp +++ b/src/utility/ATT.cpp @@ -34,6 +34,8 @@ #include "ATT.h" +extern "C" int strcasecmp(char const *a, char const *b); + #define ATT_OP_ERROR 0x01 #define ATT_OP_MTU_REQ 0x02 #define ATT_OP_MTU_RESP 0x03 diff --git a/src/utility/HCISilabsTransport.cpp b/src/utility/HCISilabsTransport.cpp new file mode 100644 index 00000000..135fd020 --- /dev/null +++ b/src/utility/HCISilabsTransport.cpp @@ -0,0 +1,130 @@ +/* + This file is part of the ArduinoBLE library. + Copyright (c) 2024 Arduino SA. All rights reserved. + + 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 Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#if defined(ARDUINO_SILABS) + +#include "HCISilabsTransport.h" +#include "sl_string.h" + +extern "C" { +#include "sl_btctrl_linklayer.h" +#include "sl_hci_common_transport.h" +} + +extern "C" int strcasecmp(char const *a, char const *b) { + return sl_strcasecmp(a, b); +} + +static RingBufferN<512> buf; + +HCISilabsTransportClass::HCISilabsTransportClass() +{ +} + +HCISilabsTransportClass::~HCISilabsTransportClass() +{ +} + +int HCISilabsTransportClass::begin() +{ + if(!sl_btctrl_is_initialized()) { + sl_bt_controller_init(); + } + + /* Initialize adv & scan components */ + sl_btctrl_init_adv(); + sl_btctrl_init_scan(); + sl_btctrl_init_conn(); + sl_btctrl_init_adv_ext(); + sl_btctrl_init_scan_ext(); + + /* Initialize HCI controller */ + sl_bthci_init_upper(); + sl_btctrl_hci_parser_init_default(); + sl_btctrl_hci_parser_init_conn(); + sl_btctrl_hci_parser_init_adv(); + sl_btctrl_hci_parser_init_phy(); + + return 1; +} + +void HCISilabsTransportClass::end() +{ + sl_bt_controller_deinit(); +} + +void HCISilabsTransportClass::wait(unsigned long timeout) +{ + for (unsigned long start = millis(); (millis() - start) < timeout;) { + if (available()) { + break; + } + } +} + +int HCISilabsTransportClass::available() +{ + return buf.available(); +} + +int HCISilabsTransportClass::peek() +{ + return buf.peek(); +} + +int HCISilabsTransportClass::read() +{ + return buf.read_char(); +} + +size_t HCISilabsTransportClass::write(const uint8_t* data, size_t len) +{ + int ret = 0; + ret = hci_common_transport_receive((uint8_t *)data, len, true); + + if (ret == 0) return len; + + return 0; +} + +extern "C" { + /** + * @brief Transmit HCI message using the currently used transport layer. + * The HCI calls this function to transmit a full HCI message. + * @param[in] data Packet type followed by HCI packet data. + * @param[in] len Length of the `data` parameter + * @return 0 - on success, or non-zero on failure. + */ + uint32_t hci_common_transport_transmit(uint8_t *data, int16_t len) + { + for (int i = 0; i < len; i++) { + buf.store_char(data[i]); + if (buf.isFull()) return SL_STATUS_FAIL; + } + + sl_btctrl_hci_transmit_complete(0); + return 0; + } +} + +HCISilabsTransportClass HCISilabsTransport; + +HCITransportInterface& HCITransport = HCISilabsTransport; + +#endif diff --git a/src/utility/HCISilabsTransport.h b/src/utility/HCISilabsTransport.h new file mode 100644 index 00000000..2061e782 --- /dev/null +++ b/src/utility/HCISilabsTransport.h @@ -0,0 +1,42 @@ +/* + This file is part of the ArduinoBLE library. + Copyright (c) 2018 Arduino SA. All rights reserved. + + 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 Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _HCI_SILABS_TRANSPORT_H_ +#define _HCI_SILABS_TRANSPORT_H_ + +#include "HCITransport.h" + +class HCISilabsTransportClass : public HCITransportInterface { +public: + HCISilabsTransportClass(); + virtual ~HCISilabsTransportClass(); + + virtual int begin(); + virtual void end(); + + virtual void wait(unsigned long timeout); + + virtual int available(); + virtual int peek(); + virtual int read(); + + virtual size_t write(const uint8_t* data, size_t length); +}; + +#endif \ No newline at end of file diff --git a/src/utility/HCIUartTransport.cpp b/src/utility/HCIUartTransport.cpp index d6f9ec3e..191811a7 100644 --- a/src/utility/HCIUartTransport.cpp +++ b/src/utility/HCIUartTransport.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#if !defined(ARDUINO_ARCH_MBED) && !defined(ESP32) && !defined(ARDUINO_UNOR4_WIFI) || defined(TARGET_NANO_RP2040_CONNECT) //|| defined(CORE_CM4) +#if !defined(ARDUINO_ARCH_MBED) && !defined(ESP32) && !defined(ARDUINO_SILABS) && !defined(ARDUINO_UNOR4_WIFI) || defined(TARGET_NANO_RP2040_CONNECT) //|| defined(CORE_CM4) #include "HCIUartTransport.h" From 29bef40e214b96dfe0a9043d791ae15b3934cd19 Mon Sep 17 00:00:00 2001 From: Leonardo Cavagnis <45899760+leonardocavagnis@users.noreply.github.com> Date: Thu, 1 Aug 2024 16:24:40 +0200 Subject: [PATCH 10/10] Publish 1.3.7 --- library.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index 5f238fde..543998b7 100644 --- a/library.properties +++ b/library.properties @@ -1,10 +1,10 @@ name=ArduinoBLE -version=1.3.6 +version=1.3.7 author=Arduino maintainer=Arduino sentence=Enables Bluetooth® Low Energy connectivity on the Arduino MKR WiFi 1010, Arduino UNO WiFi Rev.2, Arduino Nano 33 IoT, Arduino Nano 33 BLE, Nicla Sense ME and UNO R4 WiFi. paragraph=This library supports creating a Bluetooth® Low Energy peripheral & central mode. category=Communication url=https://www.arduino.cc/en/Reference/ArduinoBLE -architectures=samd,megaavr,mbed,apollo3,mbed_nano,mbed_portenta,mbed_nicla,esp32,mbed_giga,renesas,renesas_portenta,mbed_opta,renesas_uno +architectures=samd,megaavr,mbed,apollo3,mbed_nano,mbed_portenta,mbed_nicla,esp32,mbed_giga,renesas,renesas_portenta,mbed_opta,renesas_uno,silabs includes=ArduinoBLE.h