From 9d1e0d7d8ceb6edfbb36e20debcf943b096a938a Mon Sep 17 00:00:00 2001 From: Nick Lambourne Date: Sun, 3 Nov 2024 21:34:13 -0800 Subject: [PATCH] Initial checkin --- .github/workflows/main.yaml | 37 +++++++++++++ .gitignore | 55 ++++++++++++++++++++ .vscode/launch.json | 53 +++++++++++++++++++ .vscode/settings.json | 7 +++ README.md | 100 ++++++++++++++++++++++++++++++++++++ blueprint.yaml | 22 ++++++++ project.properties | 2 + src/hello-world.cpp | 29 +++++++++++ 8 files changed, 305 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.md create mode 100644 blueprint.yaml create mode 100644 project.properties create mode 100644 src/hello-world.cpp diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..c8b9e38 --- /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: 'p2' + + # 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..4c1c72a --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,53 @@ +{ + "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}", + "searchDir": [ + "${command:particle.getDebuggerSearchDir}" + ], + "configFiles": [ + "${command:particle.getDebuggerConfigFiles}" + ], + "postAttachCommands": [ + "${command:particle.getDebuggerPostAttachCommands}" + ], + "particle": { + "version": "1.1.0", + "debugger": "particle-debugger" + } + }, + { + "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}", + "searchDir": [ + "${command:particle.getDebuggerSearchDir}" + ], + "configFiles": [ + "${command:particle.getDebuggerConfigFiles}" + ], + "postAttachCommands": [ + "${command:particle.getDebuggerPostAttachCommands}" + ], + "particle": { + "version": "1.1.0", + "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..e7f2a81 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "extensions.ignoreRecommendations": true, + "C_Cpp.default.configurationProvider": "particle.particle-vscode-core", + "files.associations": { + "*.ino": "cpp" + } +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..c29fe3e --- /dev/null +++ b/README.md @@ -0,0 +1,100 @@ +# 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/blueprint.yaml b/blueprint.yaml new file mode 100644 index 0000000..bbc3ae9 --- /dev/null +++ b/blueprint.yaml @@ -0,0 +1,22 @@ +- id: particle/hello-world + catagory: tutorial + icon: particle.png + gitrepo: https://github.com/particle-iot/blueprint-hello-world + name: "Getting Started: Hello World" + shortDescription: The classic application, running on your Particle device! + version: 1.0.0 + models: [] + firstPublished: "Sept 20th 2024, 9:00 am" + lastUpdated: "Oct 31st 2024, 7:00 pm" + language: "Particle Wiring" + cloudServices: [] + integrations: [] + hardwareDependencies: + - name: Particle MCU Development Boards + link: https://store.particle.io/collections/all-products?filter.p.product_type=Development%20Boards + deployLink: https://setup.particle.io/?app=particle-hello-world + stats: + deploys: 45 + forks: 3 + description: | + The Hello World Blueprint App for Particle is a beginner-friendly IoT solution that connects a Particle device to the cloud, enabling users to send and receive simple messages. This app demonstrates fundamental IoT interactions, such as sending a “Hello, World!” message from the device and visualizing it in real-time on the Particle dashboard, showcasing how easy it is to set up and deploy IoT applications. diff --git a/project.properties b/project.properties new file mode 100644 index 0000000..f29eb9d --- /dev/null +++ b/project.properties @@ -0,0 +1,2 @@ +name=hello-world +#assetOtaDir=assets diff --git a/src/hello-world.cpp b/src/hello-world.cpp new file mode 100644 index 0000000..d688140 --- /dev/null +++ b/src/hello-world.cpp @@ -0,0 +1,29 @@ +/* + * Particle Blueprint - Hello World + * https://github.com/particle-iot/blueprint-hello-world + */ + +// Include Particle Device OS APIs +#include "Particle.h" + +// Let Device OS manage the connection to the Particle Cloud +SYSTEM_MODE(AUTOMATIC); + +// Show system, cloud connectivity, and application logs over USB +// View logs with CLI using 'particle serial monitor --follow' +SerialLogHandler logHandler(LOG_LEVEL_INFO); + +// setup() runs once, when the device is first turned on +void setup() { + Log.info("Setup has finished!"); +} + +// loop() runs over and over again, as quickly as it can execute. +// This is a very basic programming model (the superloop) - +// for more advanced threading models, please see the Device OS documentation at docs.particle.io +void loop() { + // Example: Publish event to cloud every 10 seconds. + Log.info("Sending Hello World to the cloud!"); + Particle.publish("Hello world!"); + delay( 10 * 1000 ); // milliseconds and blocking - see docs for more info! +}