-->
Page 1 of 2

how to set broker url in menuconfig for rtos mqtt example

PostPosted: Sun May 30, 2021 11:55 am
by sunbelt57
I've got mosquitto_sub running on a couple linux boxes on my network, and I'm compiling the example that comes with the ESP8266_RTOS_SDK examples in the mqtt section (ws & tcp). The 'Example Configuration' section of the menuconfig defaults to some cloud mqtt url but I want it to use the mosquitto broker running on one of my linux boxes. So I specify the broker url as 192.168.88.150 which works with mosquitto, but when I compile and flash the ESP8266 is says:
Code: Select allError parse uri: = 192.168.88.150
Client asked to stop, but was not started
Client was not initialized

I also had to hard code in setting the port number because I couldn't find where to set it in the menuconfig.
I'm digging threw the code right now in components/mqtt/esp-mqtt/mqtt_client.c but I don't want to go mucking around with it by hard-coding it in. Do I need to specify a DNS name for the linux box?

Re: how to set broker url in menuconfig for rtos mqtt exampl

PostPosted: Tue Jun 01, 2021 3:30 am
by quackmore
I checked out that example some time ago

I'm using mosquitto too, so I went straight to the code and changed it like the following

Code: Select all     const esp_mqtt_client_config_t mqtt_cfg = {
        // .uri = "mqtts://mqtt.eclipse.org:8883",
        // .uri = CONFIG_BROKER_URI,
        .host = "192.168.88.50",
        .port = 1883,
        .transport = MQTT_TRANSPORT_OVER_SSL,


but I think you can get the same result setting your BROKER_URI to

Code: Select allmqtts://192.168.88.150:1883

Re: how to set broker url in menuconfig for rtos mqtt exampl

PostPosted: Tue Jun 01, 2021 5:57 am
by quackmore
on second thought this is probably what you were looking for...

you can also change the file Kconfig.projbuild
and have your host and port configurable by menuconfig

Kconfig.projbuild
Code: Select all...
config BROKER_HOST
        string "Broker HOST"
        default "192.168.1.100"
        help
            The mqtt broker IP address.

config BROKER_PORT
        int "Broker PORT"
        default 1883
        help
            The mqtt broker port.
...


and then into the code

Code: Select allconst esp_mqtt_client_config_t mqtt_cfg = {
        // .uri = CONFIG_BROKER_URI,
        .host = CONFIG_BROKER_HOST,
        .port = CONFIG_BROKER_PORT,

Re: how to set broker url in menuconfig for rtos mqtt exampl

PostPosted: Tue Jun 01, 2021 5:18 pm
by sunbelt57
I think you meant BROKER_URL but yeah, that worked!
Many thanks, I owe you dinner at the very least.