<alp/iot.h> — Wi-Fi & MQTT
Connectivity helpers for putting an E1M module on the network.
Header
#include <alp/iot.h>
Wi-Fi station
alp_wifi_t *wifi = alp_wifi_open(&(alp_wifi_config_t){
.mode = ALP_WIFI_MODE_STATION,
});
alp_wifi_connect(wifi, &(alp_wifi_credentials_t){
.ssid = "MyNetwork",
.password = "secret",
.security = ALP_WIFI_SECURITY_WPA2,
});
while (!alp_wifi_is_connected(wifi)) {
k_msleep(100);
}
alp_wifi_close(wifi);
On AEN this flows through the CC3501E coprocessor. On V2N it flows through the on-module Murata module. The application API is identical across silicon families.
MQTT
alp_mqtt_t *mqtt = alp_mqtt_open(&(alp_mqtt_config_t){
.broker_uri = "mqtt://broker.example.com:1883",
.client_id = "alp-device-001",
});
alp_mqtt_connect(mqtt);
alp_mqtt_publish(mqtt, "sensors/temperature", "23.5", 4, ALP_MQTT_QOS_0);
void on_message(const char *topic, const uint8_t *payload, size_t len, void *user) {
/* handle incoming message */
}
alp_mqtt_subscribe(mqtt, "actuators/+/cmd", ALP_MQTT_QOS_1, on_message, NULL);
// Drive the loop from your main thread, or spawn a worker
while (1) {
alp_mqtt_loop(mqtt, 100); // process pending events, 100 ms budget
}
alp_mqtt_close(mqtt);
TLS (mqtts://)
alp_mqtt_t *mqtt = alp_mqtt_open(&(alp_mqtt_config_t){
.broker_uri = "mqtts://broker.example.com:8883",
.client_id = "alp-device-001",
.tls = &(alp_mqtt_tls_config_t){
.ca_path = "/etc/ssl/certs",
.cert_path = "/etc/alp/device.crt",
.key_path = "/etc/alp/device.key",
},
});
The Yocto backend routes TLS through OpenSSL (mosquitto_tls_set); the Zephyr backend uses MbedTLS configured via <alp/security.h>.
board.yaml
iot:
wifi: true
mqtt: true
tls: true
See also
<alp/security.h>— TLS / PSA Crypto<alp/ble.h>— BLE 5.4- Examples: iot-connected-camera
Questions about this page? Discuss in Community Forum