1.2.2 MQTT System Service Configuration

The MQTT System Service library should be configured through the MHC. When user selects the MQTT System Service library, all the required dependencies components are added automatically in the MHC configuration.

The following figure shows the MHC configuration window for configuring the MQTT System Service and a brief description of various configuration options.

  • Open the MHC 3

  • Drag the MQTT Service Module into the Active components from the Available components

Mqtt_service_MHC
  • Configure the various parameters of Basic Configuration

Mqtt_Basic_Service
Parameter NameDefault ValueDescription
Broker Name Name of the MQTT BrokerNote: User should ensure that the Broker is UP and running. In case the connection timesout often, the User can modify the value of SYS_MQTT_PERIOIDC_TIMEOUT as per his requirement.
Server Port Port number of the MQTT Broker at which the MQTT Client should connect
Enable TLSFALSEIf TRUE, the MQTT connection should use TLS while connecting to the broker. If FALSE, the MQTT connection should not use TLS.Note: In case the TLS is enabled, the User needs to update the component 'Presentation Layer' with the CA Certificate format, location, name, and size. Other parameters can be updated as per the User's requirements.
Enable SNIFALSEServer Name Indication ff TRUE, enables a client device to specify the domain name it is trying to reach in the first step of the TLS handshake.Note: In case the SNI is enabled, the Broker Name is taken as the Domain Name.
Enable ALPNFALSEApplication-Layer Protocol Negotiation (ALPN) is a TLS extension that allows the application layer to negotiate which protocol should be performed over a secure connection in a manner that avoids additional round trips and which is independent of the application-layer protocols
Client Id MQTT Client Id should be unique for the Broker. If left empty, the Id will be generated randomly
Network Interface Network Interface - Wifi or Ethernet on which the MQTT Client should run. On choosing Ethernet, the MHC will add EthMAC, MIIM, and LAM8740 Components. The User needs to attach the EthMAC to the NetConfig (in System Component Window) via the MAC parameter in Instance 1
Net_service_netconfig
  • Configure the various parameters of Presentation Layer if TLS enabled

presentation_layer
  • Configure the various parameters of 'Advanced Configuration' of the MQTT Service

Mqtt_Adv_Service
Parameter NameDefault ValueDescription
Enable Auto ReconnectTRUEIf TRUE, the MQTT Service will auto reconnect to the Broker if connection is broken. If FALSE, the customer application needs to take care of triggering the connection process again.
Enable Clean SessionTRUEIf TRUE, the MQTT Client shall tell the Broker that the session is clean; else, it will let the Broker know that the session is a continuation of the previous session. Also, if “clean session” is disabled, it is valid only within a single boot session in the Client (i.e. reconnecting before the next power-on reset) and not across boots
KeepAlive Interval60 secIf no data flows over an open connection for a certain KeepAliveInterval then the client will generate a PINGREQ and expect to receive a PINGRESP from the broker. This message exchange confirms that the connection is open and working
Username/ PasswordDisabledIn case the connection to Broker needs a Username and Password
Last Will and testamentDisabledLWT Configuration has the following parameters – 1. Topic, 2. QoS, 3. Retain, and 4. Message This ‘Message’ will be sent on the ‘Topic’ whenever the Broker finds that there is an ungraceful disconnection with the Client.
  • Configure the remaining parameters

Mqtt_Remaining_Service

To use the device certificates stored in ATECC608A-TNGTLS, enable the "Trust&Go client certificate" option under the net service configurations. Make sure that you enable TLS in the MQTT configuration to use the client certificate during the TLS handshake.

TNGTLS_ClientCert

All of the required files are automatically added into the MPLAB X IDE project by the MHC when the MQTT Service is selected for use.

Parameter NameDefault ValueDescription
Subscription TopicDisabledSubscription configuration has 2 Parameters – 1. Topic and 2. Qos. (0 (Atmost Once), 1 (Atleast Once), 2 (Exactly Once)) The User can configure these parameters to subscribe to a Topic to receive messages.
Publish to TopicDisabledPublishing a message to Topic has 3 Parameters – 1. Topic and 2. Qos ( 0 (Atmost Once), 1 (Atleast Once), 2 (Exactly Once)) 3. Retain: If the Broker should retain the message The User can configure these parameters to and use them along with the message to send it on a particular Topic.
Enable CLI CommandsEnabledEnabling this flag compiles in the CLI commands related to Mqtt Service. The user can use these CLI commands to connect/ disconnect, subscribe/ unsusbscribe, publish messages onto a topic.
Enable Debug LogsDisabledEnabling this flag compiles in debug logs and user can enable them at runtime. The user can use the following CLI commands to enable/ disable levels and flows for the MQTT service: 1. sysmqtt debug level 2. sysmqtt debug flow Note: In case the user enables debug logs, user needs to manually add the 'App Debug Service' component from Wireless-> System Service-> App Debug Service.