From 879ef4430672e17191181e59d9f04a64930b8dd0 Mon Sep 17 00:00:00 2001 From: Cristiano Brudna Date: Sat, 6 Apr 2024 16:15:43 -0300 Subject: [PATCH] feat: creates Particle IO project --- .github/workflows/main.yaml | 37 +++++++++++++ .gitignore | 55 ++++++++++++++++++++ .vscode/launch.json | 80 +++++++++++++++++++++++++++++ .vscode/settings.json | 9 ++++ README-ParticleIO.md | 100 ++++++++++++++++++++++++++++++++++++ project.properties | 2 + src/main.cpp | 38 ++++++++++++++ 7 files changed, 321 insertions(+) create mode 100644 .github/workflows/main.yaml create mode 100644 .gitignore create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 README-ParticleIO.md create mode 100644 project.properties create mode 100644 src/main.cpp diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..f2e599a --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,37 @@ +# Particle Compile Action Workflow +# This workflow uses the Particle compile-action to compile Particle application firmware. +# Make sure to set the particle-platform-name for your project. +# For complete documentation, please refer to https://github.com/particle-iot/compile-action + +name: Particle Compile + +on: + push: + branches: + - main + +jobs: + compile: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + # Particle Compile Action + - name: Compile Firmware + id: compile + uses: particle-iot/compile-action@v1 + with: + # Set the particle-platform-name to the platform you're targeting. + # Allowed values: core, photon, p1, electron, argon, boron, xenon, esomx, bsom, b5som, tracker, trackerm, p2, msom + particle-platform-name: 'photon' + + # Optional: Upload compiled firmware as an artifact on GitHub. + - name: Upload Firmware as Artifact + uses: actions/upload-artifact@v3 + with: + name: firmware-artifact + path: | + ${{ steps.compile.outputs.firmware-path }} + ${{ steps.compile.outputs.target-path }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2f0f79e --- /dev/null +++ b/.gitignore @@ -0,0 +1,55 @@ +# Key files +*.der +*.pem + +# Ignore build results and bundles +*.bin +*.zip +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ +target/* + +# Platform-specific settings +.DS_Store +*.crc_block +*.no_crc + +# VisualStudioCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Ignore all local history of files +**/.history + +# Windows +Thumbs.db +*.stackdump +[Dd]esktop.ini + +# C Prerequisites +*.d + +# C Object files +*.o +*.ko +*.obj +*.elf + +# C Linker output +*.map + +# C Debug files +*.dSYM/ +*.su +*.idb +*.pdb diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..763c773 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,80 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "cortex-debug", + "request": "attach", + "servertype": "openocd", + "name": "Particle Debugger", + "cwd": "${workspaceRoot}", + "rtos": "FreeRTOS", + "armToolchainPath": "${command:particle.getDebuggerCompilerDir}", + "executable": "${command:particle.getDebuggerExecutable}", + "serverpath": "${command:particle.getDebuggerOpenocdPath}", + "preLaunchTask": "Particle: Flash application for debug (local)", + "searchDir": [ + "${command:particle.getDebuggerSearchDir}" + ], + "configFiles": [ + "${command:particle.getDebuggerConfigFiles}" + ], + "postAttachCommands": [ + "${command:particle.getDebuggerPostAttachCommands}" + ], + "particle": { + "version": "1.0.1", + "debugger": "particle-debugger" + } + }, + { + "type": "cortex-debug", + "request": "attach", + "servertype": "openocd", + "name": "Particle Programmer Shield", + "cwd": "${workspaceRoot}", + "rtos": "FreeRTOS", + "armToolchainPath": "${command:particle.getDebuggerCompilerDir}", + "executable": "${command:particle.getDebuggerExecutable}", + "serverpath": "${command:particle.getDebuggerOpenocdPath}", + "preLaunchTask": "Particle: Flash application for debug (local)", + "searchDir": [ + "${command:particle.getDebuggerSearchDir}" + ], + "configFiles": [ + "${command:particle.getDebuggerConfigFiles}" + ], + "postAttachCommands": [ + "${command:particle.getDebuggerPostAttachCommands}" + ], + "particle": { + "version": "1.0.1", + "debugger": "particle-programmer-shield" + } + }, + { + "type": "cortex-debug", + "request": "attach", + "servertype": "openocd", + "name": "Generic DAPLink Compatible Debugger", + "cwd": "${workspaceRoot}", + "rtos": "FreeRTOS", + "armToolchainPath": "${command:particle.getDebuggerCompilerDir}", + "executable": "${command:particle.getDebuggerExecutable}", + "serverpath": "${command:particle.getDebuggerOpenocdPath}", + "preLaunchTask": "Particle: Flash application for debug (local)", + "searchDir": [ + "${command:particle.getDebuggerSearchDir}" + ], + "configFiles": [ + "${command:particle.getDebuggerConfigFiles}" + ], + "postAttachCommands": [ + "${command:particle.getDebuggerPostAttachCommands}" + ], + "particle": { + "version": "1.0.1", + "debugger": "generic-cmsis-dap" + } + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..d77c064 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "extensions.ignoreRecommendations": true, + "C_Cpp.default.configurationProvider": "particle.particle-vscode-core", + "files.associations": { + "*.ino": "cpp" + }, + "workbench.colorCustomizations": {}, + "particle.targetDevice": "Quantachuva_dev" +} \ No newline at end of file diff --git a/README-ParticleIO.md b/README-ParticleIO.md new file mode 100644 index 0000000..882a66b --- /dev/null +++ b/README-ParticleIO.md @@ -0,0 +1,100 @@ +# photon-iot-hello-world + +This firmware project was created using [Particle Developer Tools](https://www.particle.io/developer-tools/) and is compatible with all [Particle Devices](https://www.particle.io/devices/). + +Feel free to replace this README.md file with your own content, or keep it for reference. + +## Table of Contents +- [Introduction](#introduction) +- [Prerequisites To Use This Template](#prerequisites-to-use-this-repository) +- [Getting Started](#getting-started) +- [Particle Firmware At A Glance](#particle-firmware-at-a-glance) + - [Logging](#logging) + - [Setup and Loop](#setup-and-loop) + - [Delays and Timing](#delays-and-timing) + - [Testing and Debugging](#testing-and-debugging) + - [GitHub Actions (CI/CD)](#github-actions-cicd) + - [OTA](#ota) +- [Support and Feedback](#support-and-feedback) +- [Version](#version) + +## Introduction + +For an in-depth understanding of this project template, please refer to our [documentation](https://docs.particle.io/firmware/best-practices/firmware-template/). + +## Prerequisites To Use This Repository + +To use this software/firmware on a device, you'll need: + +- A [Particle Device](https://www.particle.io/devices/). +- Windows/Mac/Linux for building the software and flashing it to a device. +- [Particle Development Tools](https://docs.particle.io/getting-started/developer-tools/developer-tools/) installed and set up on your computer. +- Optionally, a nice cup of tea (and perhaps a biscuit). + +## Getting Started + +1. While not essential, we recommend running the [device setup process](https://setup.particle.io/) on your Particle device first. This ensures your device's firmware is up-to-date and you have a solid baseline to start from. + +2. If you haven't already, open this project in Visual Studio Code (File -> Open Folder). Then [compile and flash](https://docs.particle.io/getting-started/developer-tools/workbench/#cloud-build-and-flash) your device. Ensure your device's USB port is connected to your computer. + +3. Verify the device's operation by monitoring its logging output: + - In Visual Studio Code with the Particle Plugin, open the [command palette](https://docs.particle.io/getting-started/developer-tools/workbench/#particle-commands) and choose "Particle: Serial Monitor". + - Or, using the Particle CLI, execute: + ``` + particle serial monitor --follow + ``` + +4. Uncomment the code at the bottom of the cpp file in your src directory to publish to the Particle Cloud! Login to console.particle.io to view your devices events in real time. + +5. Customize this project! For firmware details, see [Particle firmware](https://docs.particle.io/reference/device-os/api/introduction/getting-started/). For information on the project's directory structure, visit [this link](https://docs.particle.io/firmware/best-practices/firmware-template/#project-overview). + +## Particle Firmware At A Glance + +### Logging + +The firmware includes a [logging library](https://docs.particle.io/reference/device-os/api/logging/logger-class/). You can display messages at different levels and filter them: + +``` +Log.trace("This is trace message"); +Log.info("This is info message"); +Log.warn("This is warn message"); +Log.error("This is error message"); +``` + +### Setup and Loop + +Particle projects originate from the Wiring/Processing framework, which is based on C++. Typically, one-time setup functions are placed in `setup()`, and the main application runs from the `loop()` function. + +For advanced scenarios, explore our [threading support](https://docs.particle.io/firmware/software-design/threading-explainer/). + +### Delays and Timing + +By default, the setup() and loop() functions are blocking whilst they run, meaning that if you put in a delay, your entire application will wait for that delay to finish before anything else can run. + +For techniques that allow you to run multiple tasks in parallel without creating threads, checkout the code example [here](https://docs.particle.io/firmware/best-practices/firmware-template/). + +(Note: Although using `delay()` isn't recommended for best practices, it's acceptable for testing.) + +### Testing and Debugging + +For firmware testing and debugging guidance, check [this documentation](https://docs.particle.io/troubleshooting/guides/build-tools-troubleshooting/debugging-firmware-builds/). + +### GitHub Actions (CI/CD) + +This project provides a YAML file for GitHub, automating firmware compilation whenever changes are pushed. More details on [Particle GitHub Actions](https://docs.particle.io/firmware/best-practices/github-actions/) are available. + +### OTA + +To learn how to utilize Particle's OTA service for device updates, consult [this documentation](https://docs.particle.io/getting-started/cloud/ota-updates/). + +Test OTA with the 'Particle: Cloud Flash' command in Visual Studio Code or the CLI command 'particle flash'! + +This firmware supports binary assets in OTA packages, allowing the inclusion of audio, images, configurations, and external microcontroller firmware. More details are [here](https://docs.particle.io/reference/device-os/api/asset-ota/asset-ota/). + +## Support and Feedback + +For support or feedback on this template or any Particle products, please join our [community](https://community.particle.io)! + +## Version + +Template version 1.0.2 \ No newline at end of file diff --git a/project.properties b/project.properties new file mode 100644 index 0000000..4c6ce01 --- /dev/null +++ b/project.properties @@ -0,0 +1,2 @@ +name=dummy +#assetOtaDir=assets diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..63df6f9 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,38 @@ +/* + * Project photon-iot-hello-world + * Author: Cristiano Brudna + * Date: 2024-04-06 + * For comprehensive documentation and examples, please visit: + * https://docs.particle.io/firmware/best-practices/firmware-template/ + */ + +#include + +// Let Device OS manage the connection to the Particle Cloud +SYSTEM_MODE(AUTOMATIC); + +// Run the application and system concurrently in separate threads +SYSTEM_THREAD(ENABLED); + +// Show system, cloud connectivity, and application logs over USB +// View logs with CLI using 'particle serial monitor --follow' +SerialLogHandler logHandler(LOG_LEVEL_INFO); + +void setup() +{ + Serial.begin(115200); + while(!Serial) + { + delay(10ms); + } + + Log.info("Hello World"); +} + +void loop() +{ + // Example: Publish event to cloud every 10 seconds. Uncomment the next 3 lines to try it! + // Log.info("Sending Hello World to the cloud!"); + // Particle.publish("Hello world!"); + // delay( 10 * 1000 ); // milliseconds and blocking - see docs for more info! +}