Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create examples for ESP-IDF #199

Merged
merged 5 commits into from
Jun 7, 2024

Conversation

hayschan
Copy link
Contributor

@hayschan hayschan commented Apr 12, 2024

This pull request aims to solve the missing ESP-IDF examples mentioned in #175 .

Completed examples:

  • Send data. Done previously by other contributor.
  • Process OTA MQTT. Done previously by other contributor.
  • Server-side RPC command f42a7cb
  • Process shared attribute update dc87645

@rayene01 rayene01 mentioned this pull request May 13, 2024
@MathewHDYT
Copy link
Contributor

MathewHDYT commented May 17, 2024

@imbeacon Would be nice if this could be merged, because it does not require any additional changes, even a version bump is not required and it fixes #175.

This commit adds a new README file to the examples folder of the ThingsBoard Client SDK GitHub repository. The README provides comprehensive guidance on the directory structure, feature support, and platform compatibility of the examples included in the repository.

The README begins with an overview of the directory structure and usage, explaining how the examples are organized and guiding users on how to choose the relevant example based on their target platform and desired ThingsBoard feature.

It then delves into the feature support over MQTT and HTTP(S), outlining which features are implemented over MQTT and which need to be implemented manually over HTTP(S). Links to the relevant sections of the ThingsBoard documentation are provided for further information on implementing these features.

A folder prefix guide is included to help users understand the naming convention used for each example folder, indicating the platform the example is designed for.

The README also features a detailed examples overview table, listing each example's folder name, description, and supported platform. This table serves as a quick reference for users to identify the example that best suits their needs.

Each folder within the examples directory contains its own README file with additional information specific to that example, providing users with detailed guidance on how to use it effectively.

Overall, this README enhances the usability of the repository by providing users with clear and comprehensive documentation on the available examples and how to leverage them for their ThingsBoard development projects.
This commit introduces a new example for provisioning devices using the ThingsBoard client SDK on the ESP-IDF platform. The example demonstrates how to securely connect to the ThingsBoard server, provision a device, and reconnect using the newly provisioned credentials.

### Key Features:
- **WiFi Initialization**: Establishes a connection to the specified WiFi network.
- **ThingsBoard Client SDK Integration**: Utilizes the ThingsBoard client SDK for device provisioning and MQTT communication.
- **Secure Connection**: Supports both encrypted and unencrypted connections to the ThingsBoard server. Uses SSL/TLS for encrypted communication with the server.
- **Provisioning Process**: Implements the provisioning process by sending a provisioning request and handling the response to obtain device credentials.
- **Reconnect with New Credentials**: Disconnects from the provision account and reconnects to the ThingsBoard server using the newly generated credentials.

### Code Overview:
- `InitWiFi()`: Initializes the WiFi connection.
- `processProvisionResponse()`: Handles the response from the ThingsBoard server after provisioning.
- `provision_device()`: Manages the device provisioning process, including connecting to the server with the provision account, sending the provisioning request, and reconnecting with the new credentials.
- `app_main()`: Entry point for the application, initializes NVS, WiFi, and starts the provisioning task.

### Example Usage:
- Configure the `WIFI_SSID`, `WIFI_PASSWORD`, `PROVISION_DEVICE_KEY`, and `PROVISION_DEVICE_SECRET` with your specific credentials.
- Optionally set `DEVICE_NAME` or allow it to default to the device's MAC address.
- Build and flash the example to your ESP32 device.

This example provides a comprehensive guide for developers looking to integrate ThingsBoard device provisioning into their ESP-IDF projects, ensuring secure and efficient device management.
@imbeacon imbeacon merged commit e159f13 into thingsboard:master Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants