From 6e39c6a1c039ed5db3c2790e403d3a827d5bd940 Mon Sep 17 00:00:00 2001 From: Maximilian Paulsen Date: Wed, 28 Feb 2024 13:08:40 +0100 Subject: [PATCH 1/4] Moves CI to github --- .github/workflows/arduino.yml | 21 ++++++++++++++++ .github/workflows/platformio.yml | 39 +++++++++++++++++++++++++++++ .gitlab-ci.yml | 42 -------------------------------- 3 files changed, 60 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/arduino.yml create mode 100644 .github/workflows/platformio.yml delete mode 100644 .gitlab-ci.yml diff --git a/.github/workflows/arduino.yml b/.github/workflows/arduino.yml new file mode 100644 index 0000000..19af482 --- /dev/null +++ b/.github/workflows/arduino.yml @@ -0,0 +1,21 @@ +name: Arduino Lib + +on: + pull_request: + branches: + - master + +jobs: + arduino-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: arduino/arduino-lint-action@v1 + + arduino-ci: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: Arduino-CI/action@stable-1.x + env: + EXPECT_EXAMPLES: true diff --git a/.github/workflows/platformio.yml b/.github/workflows/platformio.yml new file mode 100644 index 0000000..7bb9bbf --- /dev/null +++ b/.github/workflows/platformio.yml @@ -0,0 +1,39 @@ +name: PIO Lib + +on: + pull_request: + branches: + - main + push: + branches: + - main + tags: + - "[0-9]+.[0-9]+.[0-9]+" + +jobs: + PlatformIO-Check: + uses: sensirion/.github/.github/workflows/platformio_check.yml@main + with: + pio-environment-list: '["GetLiveValues"]' + + PlatformIO-Build: + uses: sensirion/.github/.github/workflows/platformio_build.yml@main + needs: PlatformIO-Check + with: + pio-environment-list: '["GetLiveValues"]' + + PlatformIO-Package: + if: ${{ (github.ref_type != 'tag') && (github.ref_name == 'main') }} + needs: PlatformIO-Build + uses: sensirion/.github/.github/workflows/platformio_publish.yml@main + with: + should-publish: false + + PlatformIO-Publish: + uses: sensirion/.github/.github/workflows/platformio_publish.yml@main + if: github.ref_type == 'tag' + needs: PlatformIO-Build + with: + should-publish: true + secrets: + pio-registry-token: ${{ secrets.PIO_MKTSW_TOKEN }} diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 00645cf..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,42 +0,0 @@ -stages: - - validate - - compile - -compile_pio: - stage: compile - image: - name: registry.gitlab.sensirion.lokal/sensirion/docker/docker-arduino:0.6.0 - tags: [docker, linux] - parallel: - matrix: - - env: [GetLiveValues, develop] - script: - - pio run --environment ${env} - -syntax_check: - stage: validate - image: - name: registry.gitlab.sensirion.lokal/sensirion/docker/docker-ubuntu:22.04-1.6.0 - tags: [linux, docker] - before_script: - - apt update - - apt-get install -yq clang-format-14 - script: - - find . -type f -iregex ".*\.\(c\|h\|cpp\|ino\)" -exec clang-format-14 -i -style=file {} \; && git diff --exit-code - -cppcheck: - stage: validate - image: - name: registry.gitlab.sensirion.lokal/mso-sw/drivers/docker-driver-generator:0.2.0 - tags: [linux, docker] - script: - - cppcheck --std=c++11 --language=c++ --error-exitcode=1 --enable=warning,style,performance,portability --suppressions-list=.cppcheck_suppressions.txt src/* examples/* - -TODO_check: - stage: validate - image: - name: registry.gitlab.sensirion.lokal/mso-sw/drivers/docker-driver-generator:0.2.0 - tags: [linux, docker] - script: - - '! grep -rnw --exclude=.gitlab-ci.yml --exclude-dir=.git . -e "TODO"' - \ No newline at end of file From 0078e25cd1e2885b64c15b2b4389623cdd925713 Mon Sep 17 00:00:00 2001 From: Maximilian Paulsen Date: Wed, 28 Feb 2024 16:39:35 +0100 Subject: [PATCH 2/4] Use i2c AD python scripts --- py_scripts/make_cpp_files.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/py_scripts/make_cpp_files.py b/py_scripts/make_cpp_files.py index 389c629..405468d 100644 --- a/py_scripts/make_cpp_files.py +++ b/py_scripts/make_cpp_files.py @@ -1,5 +1,16 @@ import os +import shutil + +ARDUINO_FILE_EXTENSION = ".ino" +TARGET_FILE_EXTENSION = ".cpp" +EXAMPLE_FOLDER = "examples" # Create a .cpp file for all the .ino files in the examples dir (CAUTION: will overwrite existing) print("PRE_SCRIPT: Copying .ino file contents to .cpp files.") -os.system(f'find examples -type f -name "*.ino" -exec bash -c \'for file; do cp "$file" "$(dirname "$file")/$(basename "$file" .ino).cpp"; done\' _ {{}} +') +for e in os.listdir(EXAMPLE_FOLDER): + if os.path.isdir(f"{EXAMPLE_FOLDER}/{e}") and os.path.isfile(f"{EXAMPLE_FOLDER}/{e}/{e}{ARDUINO_FILE_EXTENSION}"): + arduino_file =f"{EXAMPLE_FOLDER}/{e}/{e}{ARDUINO_FILE_EXTENSION}" + cpp_file = f"{EXAMPLE_FOLDER}/{e}/{e}{TARGET_FILE_EXTENSION}" + shutil.copyfile(arduino_file, cpp_file) + print(f'\tcopied {arduino_file} to {cpp_file}') +print("\t>> Done.") From cf0919a45ab130e66471793fcb17bb8a9da6bc5f Mon Sep 17 00:00:00 2001 From: Quentin Fisch Date: Fri, 1 Mar 2024 19:35:32 +0100 Subject: [PATCH 3/4] Improve credits to MBjoern --- README.md | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index ebd2d11..6b06981 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,29 @@ # Arduino Sensirion UPT BLE Auto Detection -This library enables you to retrieve live measurements form your own Do-It-Yourself BLE enabled sensor gadget or most Sensirion Gadgets on the ESP32 platform. +This library enables you to retrieve live measurements form your own Do-It-Yourself BLE enabled sensor gadget or most Sensirion Gadgets on the ESP32 platform. ## Supported Gadgets -* AQ Minion -* MyCO2 -* SHT3X Gadget -* SHT40 Gadget -* SHT43 Gadget -* [DIY BLE Gadget](https://github.com/Sensirion/arduino-ble-gadget) + +- AQ Minion +- MyCO2 +- SHT3X Gadget +- SHT40 Gadget +- SHT43 Gadget +- [DIY BLE Gadget](https://github.com/Sensirion/arduino-ble-gadget) ### Key features are **Please see [the example provided as reference](examples/GetLiveValues/GetLiveValues.ino) on how to use this library.** ## How to use + ### Recommended Hardware This project was developed and tested on Espressif [ESP32 DevKitC](https://www.espressif.com/en/products/devkits/esp32-devkitc) hardware (see e.g. [ESP32-DevKitC-32D](https://www.digikey.com/en/products/detail/espressif-systems/ESP32-DEVKITC-32D/9356990)). This library requires standard library compatibility. Some boards such as Arduino AVR Uno do not ship with this functionnality. ### Arduino + Install the software from the [official website](https://www.arduino.cc/en/software) and read [this short tutorial](https://docs.arduino.cc/software/ide-v2/tutorials/getting-started-ide-v2/) to get an introduction to the IDE. Next, select your board and port in the Board Manager by following [these instructions](https://support.arduino.cc/hc/en-us/articles/4406856349970-Select-board-and-port-in-Arduino-IDE). @@ -30,8 +33,9 @@ Start the [Arduino IDE](http://www.arduino.cc/en/main/software) and open the Lib Sketch => Include Library => Manage Libraries... Search for the `Sensirion UPT BLE Auto Detection` library in the `Filter your search...` field and install it by clicking the `install` button. Make sure to click "Install All", lest you'll have to manually search for and install the dependencies: -* [NimBLE-Arduino](https://www.arduino.cc/reference/en/libraries/nimble-arduino/). -* [Sensirion UPT Core](https://www.arduino.cc/reference/en/libraries/sensirion-upt-core/) + +- [NimBLE-Arduino](https://www.arduino.cc/reference/en/libraries/nimble-arduino/). +- [Sensirion UPT Core](https://www.arduino.cc/reference/en/libraries/sensirion-upt-core/) Alternatively, the library can also be added manually. To do this, download the latest release from github as a .zip file via @@ -44,6 +48,7 @@ and add it to the [Arduino IDE](http://www.arduino.cc/en/main/software) via In this second case, you'll have to also add all dependencies the same way. ### PlatformIO + An often more straightforward alternative to the Arduino IDE is the PlatformIO framework, which is the recommended approach on Linux/Unix systems and is detailed in the following. The most straight-forward way to use [PlatformIO](https://platformio.org/platformio-ide) is as an extension to Microsoft's [Visual Studio Code](https://code.visualstudio.com/), you'll find it easily among the extensions available for it. Please refer to the official installation instructions [here](https://platformio.org/install/ide?install=vscode). @@ -54,18 +59,23 @@ To use the library, add the following dependencies to your `platformio.ini`'s `l lib_deps = Sensirion UPT BLE Auto Detection ``` + PlatformIO will automatically fetch the latest version of the dependencies during the build process. Alternatively, to install this library in your project environment execute the following command in a terminal: + ```bash pio pkg install --library "Sensirion UPT BLE Auto Detection" ``` To test the default example (`GetLiveValues`), use the following platformio command from the project's root directory (the one containing the `platformio.ini` file): + ```bash pio run -t upload ``` + and start the Serial monitor with + ```bash pio device monitor ``` @@ -78,4 +88,4 @@ See [LICENSE](LICENSE). ## Credits -https://github.com/MBjoern/arduino-ble-sensiscan +This repository is based on the great work of @MBjoern called [arduino-ble-sensiscan](https://github.com/MBjoern/arduino-ble-sensiscan). Kudos to him ! From eee5bb88471f76a3d4fcefa5719f33f4d94d2bd6 Mon Sep 17 00:00:00 2001 From: Quentin Fisch Date: Fri, 1 Mar 2024 19:35:43 +0100 Subject: [PATCH 4/4] add URL to lib properties --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index d561d4d..986c60a 100644 --- a/library.properties +++ b/library.properties @@ -5,7 +5,7 @@ maintainer=Sensirion AG sentence=Automatically detects Sensirion Gadgets via Bluetooth and reads out measurement data. paragraph=Automatically detects Sensirion Gadgets via Bluetooth and reads out measurement data. category=Communication, Sensors -url= +url=https://github.com/Sensirion/arduino-upt-ble-auto-detection architectures=esp32 depends=NimBLE-Arduino, Sensirion UPT Core includes=Sensirion_upt_ble_auto_detection.h