This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How can I dynamically assign the MQTT broker address?

How can I dynamically assign the MQTT broker address

Hi all, I have a general question how to assign the MQTT broker address dynamically. Current Nordic IoT-SDK mqtt examples assign the mqtt broker address at compile time. What would be the best ( or standardized) way to implement a dynamic configuration for the nrf51.

Possible solutions:

  • add an additional service and configure it over BLE via Smart-phone.
  • or connect the nrf51 to border router and configure it over IPv6

Does anybody know which is the best solution? Thanks !

Parents
  • Hello,

    May I understand what is your use case to change the broker address without connecting the session again? Remember that TCP is point to point and associates IP address and port with the data endpoint, not just the port number. If you acknowledge this, then best way to dynamically connect to a broker is to disconnect using the API mqtt_disconnect and then connect to the new broker address (essentially treat it as new broker) using mqtt_connect API.

    Hope this helps!

    Regards, Krishna

Reply
  • Hello,

    May I understand what is your use case to change the broker address without connecting the session again? Remember that TCP is point to point and associates IP address and port with the data endpoint, not just the port number. If you acknowledge this, then best way to dynamically connect to a broker is to disconnect using the API mqtt_disconnect and then connect to the new broker address (essentially treat it as new broker) using mqtt_connect API.

    Hope this helps!

    Regards, Krishna

Children
No Data
Related