Giter Club home page Giter Club logo

esp-aws-iot-mqtt-config's Introduction

aws_iot_mqtt_config component

platformio build

Component for ESP-IDF. Provides functions to store and load MQTT config attributes to/from NVS storage.

Following attributes are managed:

  • host
  • port
  • uri
  • cert_pem, cert_len
  • client_cert_pem, client_cert_len
  • client_key_pem, client_key_len
  • clientkey_password, clientkey_password_len

Usage

When used as IDF component, add it as a Git submodule

git submodule add https://github.com/mdvorak-iot/esp-aws-iot-mqtt-config.git components/aws_iot_mqtt_config

When used as platformio library, add it to platformio.ini:

[env]
lib_deps = https://github.com/mdvorak-iot/esp-aws-iot-mqtt-config.git

Code

See example.

Note that when attributes are loaded into config, they are newly allocated and should be freed when not needed.

esp_mqtt_client_init() method creates copy of some attributes, but does not copy certificates and key. Those must not be freed as long as mqtt client exists.

esp_mqtt_client_config_t mqtt_cfg = {};
mqtt_cfg.cert_pem = AWS_IOT_ROOT_CA;
mqtt_cfg.cert_len = AWS_IOT_ROOT_CA_LEN;
ESP_ERROR_CHECK(aws_iot_mqtt_config_load(&mqtt_cfg));

esp_mqtt_client_handle_t mqtt_client = esp_mqtt_client_init(&mqtt_cfg);
// ...

aws_iot_mqtt_config_free_unused(&mqtt_cfg);
ESP_ERROR_CHECK(esp_mqtt_client_start(mqtt_client));

esp-aws-iot-mqtt-config's People

Contributors

dependabot[bot] avatar mdvorak avatar

Watchers

 avatar  avatar

Forkers

diwakrzha

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.