Getting Started
- MQTT
- Shadow Setup
- BLE Mesh
- Persistent logs and device health
- OTA Updates
- Consumer applications
MQTT Setup
Step 1:
Login from your golain account and go to "Fleets and Devices".
From a fleet of your choice, create a device as per your requirements.
You will receive a zip file with all the certificates you need and JSON file named connection_settings.json contain multiple configuration parameters. We will use the certificates in the next step, and the config parameters in the step 3.
Remember to use the same shadow definitions as your configurations.
Step 2:
Copy your certificates and move them in
/main/certs
. Your folder structure should look like this:main
|
-certs
|
-device_cert.pem
-device_private_key.pem
-mqtt_broker_cert.pem
-root_ca_cert.pemAdd the following to your root CMakeLists.txt:
target_add_binary_data(${PROJECT_NAME}.elf "main/certs/device_cert.pem" TEXT)
target_add_binary_data(${PROJECT_NAME}.elf "main/certs/device_private_key.pem" TEXT)
target_add_binary_data(${PROJECT_NAME}.elf "main/certs/mqtt_broker_cert.pem" TEXT)
target_add_binary_data(${PROJECT_NAME}.elf "main/certs/root_ca_cert.pem" TEXT)Ensure that your certificates are named accordingly.
These certificates allow the device to establish a TLS connection. We use a TLS connection for security.
Step 3:
- Open ESP-IDF menuconfig by :
Press
Ctrl
+Shift
+P
and then search for "menuconfig")Open command line and run
idf.py menuconfig
You can find more information in ESP-IDF's official documentation
Scroll down to Golain
Using the parameters we found in connection_settings.json, update the following in this KConfig:
Topic Root → root_topic
Device Name → device_name
Step 4:
Click on the "Enable Wifi" option to allow golain to handle wifi.
Enter your ssid and password in "Enter ssid" and "Enter wifi password" fields respectively.
This step is optional and is only required if you don't use golain to setup wifi. However, it is recommended that you do allow golain to setup and handle wifi.
Shadow settings
- Shadow Buffer Size : The size of the shadow buffer. This is used to store the device's shadow document. Increase this if you have a large shadow document.
- Set your desired shadow buffer size with "Shadow Buffer Size".
BLE Mesh setup
Step 1:
- Open ESP-IDF menuconfig by :
- Press
Ctrl
+Shift
+P
and then search for "menuconfig" - Open command line and run
idf.py menuconfig
- Official documentation
- Press
Step 2:
Scroll down to "Golain" and click on "Enable BLE Services for Golain".
Golain uses NimBLE for its BLE operations. Do not enable the other ESP BLE Mesh Support option to avoid thread conflicts for NimBLE.
Persistent Logs
Click on "Enable Persistent Cloud Logging".
Insert your desired value for "Maximum number of persistent logs" .(Default is 50)
Set the log level to be stored with "Internal log level". The default value is 3, which means that both ERROR and WARNING logs will be stored.
Device Health
Enable "Report Device Health".
Set "Device health buffer size".
The only step required here
- Click on "Enable OTA Updates via MQTT"
- See examples for help with using the OTA component.
The device firmware update will fully occur once the device restarts after receiving and accepting an OTA package.
Consumer applications:
Enables consumer applications & user association. This option enables the deivce to associate an external user with the golain platform. See User Applications for more info.
- Click on "Enable Consumer applictions"