2021-03-17 07:10 AM
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 provider 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
Best Regards
Solved! Go to Solution.
2021-03-17 01:45 PM
hello
This issue covered here.
In general, dns_gethostbyname() and dns_gethostbyname_addrtype() functions resolve hostname (hivemq.cloud) to address
2021-03-17 01:45 PM
hello
This issue covered here.
In general, dns_gethostbyname() and dns_gethostbyname_addrtype() functions resolve hostname (hivemq.cloud) to address
2021-03-19 12:21 AM
@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.
2021-03-19 12:56 AM
Those functions are parts of RAW API. Read the documentation:
2021-03-19 03:32 AM
of course it is. I need to just enbale DNS from CubeIDE.
Do I need use Multi Tread When I want to subscribe multiple topic in MQTT
2021-03-25 11:27 PM
@Vangelis Fortounas Hello My friend. I have enabled DNS in STM32cubeIDE
even if LWIP_DNS is set to 1 in "lwipopts.h", I see that LWIP_DNS is acting like not defined as 1 in dns.c file
I have manually redefine LWIP_DNS as 1
I have followed the steps. However I get IP as "32.0.0.0" in callback function.
dns_setserver(0, &dnsserver); // 8.8.8.8 as server IP
dns_init();
dns_gethostbyname();
What could be the problem ?
2021-03-26 02:28 PM
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
2021-03-28 09:32 AM
Why are you calling some API function before the related initialization function? Why are you calling dns_init() manually at all? It is not listed as an API in documentation because it is not meant to be called by user application. And for DNS to work, the IP/mask/gateway and DNS server must be configured, working and accessible.
2021-03-29 05:05 AM
Hell @Vangelis Fortounas I am using static IP address.
Can you be more specific ? I did not understand what you mean.
2021-03-29 05:28 PM
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.