Git Product home page Git Product logo

edgehog-esp32-device's Introduction

Edgehog ESP32 Device

Edgehog ESP32 Device is the Edgehog component for Espressif esp-idf, that enables remote management of Espressif ESP32 devices using Astarte.

Getting Started

1 - Install ESP-IDF Toolchain

Follow the esp-idf installation guide.

2 - Install the IDF-Component Manager

Follow the idf-component manager installation guide.

3 - Setup a New Project

Create a new CMake project:

mkdir ~/hello_world
cd ~/hello_world
cp -r $IDF_PATH/examples/get-started/hello_world .

4 - Setup Dependencies

Create a new idf_component.yml in the project root directory, as follows:

## IDF Component Manager Manifest File
dependencies:
  idf:
    version: ">=4.4.4"
  edgehog-esp32-device:
    version: "*" # this is the latest commit on the main branch
    git: https://github.com/edgehog-device-manager/edgehog-esp32-device.git
  astarte-device-sdk-esp32:
    version: "b47e453777f774835b3f86eeb0ce5d3b3a890c9c" # 'release-1.0' branch
    git: https://github.com/astarte-platform/astarte-device-sdk-esp32.git

5 - Build project

idf.py build

Component Free RTOS APIs usage

The Edgehog ESP32 Device interacts internally with the Free RTOS APIs. As such some factors should be taken into account when integrating this component in a larger system.

The following tasks are spawned directly by the Edgehog ESP32 Device:

  • BLINK TASK: Provides functionality for visual feedback using an on board LED. It is only spawned if CONFIG_INDICATOR_GPIO_ENABLE is set in the Edgehog ESP32 device configuration, will use 2048 words from the stack, and can be triggered by a publish from the Astarte cluster to the dedicated LED interface. This task has a fixed duration and will be deleted at timeout.
  • OTA UPDATE TASK: Provides functionality for OTA updates. It will use 4096 words from the stack, and can be triggered by a publish from the Astarte cluster to the dedicated OTA update interface. This task does not have a fixed duration, it will run untill a successful OTA update has been downloaded and flashed or the procedure failed. Note that the OTA update task could restart the device.

All of the tasks are spawned with the lowest priority and rely on the time slicing functionality of freertos to run concurrently with the main task.

Other than tasks, a certain number of software timers are also created to be used for telemetry. The actual number of timers that this component is going to use will depend on the telemetry configuration of your project. Each telemetry type will create a separate timer. Software timers run all in a single task instantiated by freertos. The stack size and priority for such task should be configured in the project using this component. This module has been tested using 2048 words for the stack size and a priority of 1 for the timer task.

In addition to what stated above, this component requires an Astarte ESP32 Device to be externally instantiated and provided in its configuration struct. The Astarte ESP32 Device interacts internally with the Free RTOS APIs and its resource usage should be evaluated separately.

Resources

Contributing

Edgehog ESP32 Device is open to any contribution.

Pull requests, bug reports and feature requests are welcome.

License

Edgehog ESP32 Device source code is released under the Apache 2.0 License.

Check the LICENSE file for more information.

edgehog-esp32-device's People

Contributors

bettio avatar francescovaiani avatar harlem88 avatar rbino avatar sorru94 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

edgehog-esp32-device's Issues

Support for ESP-IDF 5.0

The ESP-IDF 5.0 was released in December 2022.
It is a major release with breaking changes. Appropriate fixes should be applied to this project to support this version.

[Example] Move the Edgehog setup before Astarte device start

Move from the example the edgehog_device_new function before the astarte_device_start function, this also prevents publication of data before publishing the Astarte introspection.

edgehog_device_telemetry_config_t telemetry_config
        = { .type = EDGEHOG_TELEMETRY_SYSTEM_STATUS, .period_seconds = 3600 };

    edgehog_device_config_t edgehog_conf = { .astarte_device = astarte_device,
        .partition_label = "nvs",
        .telemetry_config = &telemetry_config,
        .telemetry_config_len = 1 };
    edgehog_device = edgehog_device_new(&edgehog_conf);

    if (!edgehog_device) {
        ESP_LOGE(TAG, "Failed to create Edgehog device");
        return;
    }
    
    ...
    
     if (astarte_device_start(astarte_device) != ASTARTE_OK) {
        ESP_LOGE(TAG, "Failed to start astarte device");
        return;
    }

LedBehavior: GPIO still active after behaviors

If you execute one of the behaviors implemented by LedBehavior, the GPIO remains enabled after execution.

To reproduce it, go on Edgehog frontend page and click the identify button in check my device section.

Decouple the initialization from the first data send

The edgehog_device_new contains both the Astarte interface configuration and the initial sending data. They should also be separated for reasons of integration with other components that use Astarte.

Tipical app Integration with Astarte

  • add edgehog-interface
  • add third-party-interface
    ...
  • init edgehog
  • init third-party compent

There are several options for achieving this :

  • Add init method to edeghog device where move the initial send data.
  • Move the initial send data to start method
  • ...

Add ESP32 Doxygen Doc

ESP32 Edgehog component API doc should be generated using doxygen, and published automatically using CI.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.