Skip to main content
Visitor II
March 17, 2021
Solved

STM32f4 LwIP MQTT

  • March 17, 2021
  • 6 replies
  • 5506 views

Hello,

I am able run successfully mqtt example on my stm32f4 MCU ​and on my local network.

I want to run the same code on a cloud platform. However there is a link provided by mqtt cloud pro​vider not an IP address like 192.168.0.10

​​

Can I directly use the below link instead of the IP address ? If not, then How can I ?

1f87a053302042c7a0ccb2dac5d1263b.s1.eu.hivemq.cloud

B​est Regards

    This topic has been closed for replies.
    Best answer by Vangelis Fortounas

    hello

    This issue covered here.

    In general, dns_gethostbyname() and dns_gethostbyname_addrtype() functions resolve hostname (hivemq.cloud) to address

    6 replies

    Visitor II
    March 17, 2021

    hello

    This issue covered here.

    In general, dns_gethostbyname() and dns_gethostbyname_addrtype() functions resolve hostname (hivemq.cloud) to address

    voyvoda .Author
    Visitor II
    March 19, 2021

    @Vangelis Fortounas​  Thank you for your reply. I can only use dns_gethostbyname() with socket or netconn. So I need to use freertos. Is there any other way to use with RAW API functions ?

    Or I migth use the web site http://domaintoipconverter.com/index.php to get the IP address directly.

    In addition, How can I subscibe to a topic with lwip mqtt example.

    I want to use second STM32 board to subscribe to the topic. In short, one board will publish and the other will subscribe(receive). "hivemq.cloud" will be the broker.

    Graduate II
    March 19, 2021

    Those functions are parts of RAW API. Read the documentation:

    https://www.nongnu.org/lwip/2_1_x/group__dns.html

    Visitor II
    March 26, 2021

    Hello

    try to use as DNS server the default router's address or the gateway address that is set during initialization (netif_set_addr(..))

    If dhcp is enabled , there is no need to set a DNS address

    voyvoda .Author
    Visitor II
    March 29, 2021

    Hell @Vangelis Fortounas​ I am using static IP address.

    Can you be more specific ? I did not understand what you mean.

    Visitor II
    March 30, 2021

    Hello

    Somewere in code, static address was set by calling netif_set_addr(...) function.

    This function takes three parameters, static IP address, subnet mask and gateway(GW). (in cubeMX these parameters are set sequentially).

    Usually the GW address is the IP address of the router that Ethernet cable is connected, also is the default DNS address. (eg 192.168.1.1).

    I suggested to put as DNS server address (dns_setserver(...)) the default address of the router that is probably used also as gateway address.

    I wrote "probably" because i don't know the exact network topology.

    Visitor II
    August 26, 2022

    Hello @voyvoda .,

    I tried to connect to MQTT server using LWIP protocol from STM32F4. I am able to connect but getting authentication failure in MQTT server side. And, not able to publish the date to the server. Kindly help resolve this issue.

    Explorer
    April 2, 2024

    Good day

    Have you been able to solve the problem? I know it is  a long time ago, but any possibility of code sharing?

    Or even a link to working software. I am using the STM32H563Z