Connecting to Private MQTT broker

Dear Nordic Team, 

I am currently using nrf9160 for MQTT transmission. I have successfully connected to a public MQTT broker which is HiveMQ and transmitted data to HiveMQ. The next step I am trying to achieve is to transfer data to a private MQTT broker which will require a username and password. May I know how I configure these parameters in the prj.conf file? The image below is my configuration for HiveMQ. 

Parents
  • Hello, 

    You will need to know if the MQTT broker uses TLS for private connection. If so, you can build your project using nrf\samples\nrf9160\mqtt_simple\overlay-tls.conf.

    If you are using the simple_mqtt sample, you can add the user_name and password in client_init(). From zephyr\include\zephyr\net\mqtt.h

    	/** User name (if any) to be used for the connection. NULL indicates
    	 *  no user name.
    	 */
    	struct mqtt_utf8 *user_name;
    
    	/** Password (if any) to be used for the connection. Note that if
    	 *  password is provided, user name shall also be provided. NULL
    	 *  indicates no password.
    	 */
    	struct mqtt_utf8 *password;

    More information can be found in the MQTT library documentation

    Kind regards,
    Øyvind.

Reply
  • Hello, 

    You will need to know if the MQTT broker uses TLS for private connection. If so, you can build your project using nrf\samples\nrf9160\mqtt_simple\overlay-tls.conf.

    If you are using the simple_mqtt sample, you can add the user_name and password in client_init(). From zephyr\include\zephyr\net\mqtt.h

    	/** User name (if any) to be used for the connection. NULL indicates
    	 *  no user name.
    	 */
    	struct mqtt_utf8 *user_name;
    
    	/** Password (if any) to be used for the connection. Note that if
    	 *  password is provided, user name shall also be provided. NULL
    	 *  indicates no password.
    	 */
    	struct mqtt_utf8 *password;

    More information can be found in the MQTT library documentation

    Kind regards,
    Øyvind.

Children
Related