Skip to content

MQTT Configs

suraj inamdar edited this page Apr 19, 2020 · 3 revisions

MQTT Configs

MQTT configs are kept in MqttConfig.h file under config folder. this file holds the Mqtt table structure in database and some web behaviour control parameters

mqtt_general_configs is general table which consist

  • Mqtt host : i.e. Mqtt broker address
  • Mqtt port : in most cases it is 1883
  • Mqtt client id : unique client id. we can keep device mac_id as well for the same
  • Mqtt username : username for general authentication by broker
  • Mqtt password : password for Mqtt
  • keepalive : no of seconds to enter for which server/broker will keep connection alive
  • clean session : whether to maintain session at server side

mqtt_lwt_configs is lwt table which consist

  • Mqtt will topic : Mqtt broker will use this information to publish device disconnect/dead condition
  • Mqtt will message : Message to publish by broker when device get disconnect

mqtt_pubsub_configs is publish / subscribe table which consist

  • Mqtt topic : to which device should publish/subscribe
  • Mqtt QoS & Retain

Allow MQTT configs from portal

This defines allow of mqtt settings update from web portal

/**
 * enable/disable mqtt config modification here
 */
#define ALLOW_MQTT_CONFIG_MODIFICATION

Default definitions

you can edit this parameters as per requirement

#define MQTT_DEFAULT_KEEPALIVE  120     /*second*/
#define MQTT_HOST_CONNECT_TIMEOUT  5    /*second*/
#define MQTT_DEFAULT_PORT       1883
#define MQTT_MAX_QOS_LEVEL      2
#define MQTT_MAX_PUBLISH_TOPIC  2
#define MQTT_MAX_SUBSCRIBE_TOPIC  MQTT_MAX_PUBLISH_TOPIC

#define MQTT_INITIALIZE_DURATION   MILLISECOND_DURATION_5000
Clone this wiki locally