Connecting S0 to Magistrala via CoAP Secure#
Running Magistrala#
Ensure that Magistrala is running.
Ensure also you are in the embedded/targets/zephyr/coaps directory when executing the below steps
Modify the configuration file in src/config.h
Start with the WiFi credentials as S0 in this case is in Station Mode.
#define WIFI_SSID "SSID" // Replace `SSID` with WiFi ssid
#define WIFI_PSK "PASSWORD" // Replace `PASSWORD` with Router password
Configuring Magistrala variables#
#define MAGISTRALA_HOSTNAME "messaging.magistrala.absmach.eu" // Replace with your Magistrala instance hostname or IP
#define MAGISTRALA_COAPS_PORT 5684
#define DOMAIN_ID "DOMAIN_ID" // Replace with your Domain ID
#define CLIENT_ID "CLIENT_ID" // Replace with your Client ID
#define CLIENT_SECRET "CLIENT_SECRET" // Replace with your Client secret
#define CHANNEL_ID "CHANNEL_ID" // Replace with your Channel ID
DTLS Certificate#
To download the Magistrala CA certificate, run the following command:
openssl s_client -connect messaging.magistrala.absmach.eu:443 \
-servername messaging.magistrala.absmach.eu \
</dev/null | openssl x509 > messaging.magistrala.absmach.eu.pem
Copy the certificate contents to your src/ca_cert.h
Bulding and Flashing Code#
Once you update the configuration file, build and run the code:
west build -p always -b esp32c6_devkitc
west flash
west espressif monitor