Azure IoT Hub Library with OpenThread

Hello Everyone,

We are working on a new product using the nrf52840 and OpenThread.Our current product uses the Azure IoT Hub and we were wondering if we could use the library used by the nrf91.

According to Didrik in a post on Devzone It should be possible to use this library to connect to the Azure IoT Hub.

I have set up a Thread network and added a route for the NAT64 interface. I am able to use the NAT64 interface as a DNS server to get a IPv6 address synthesized from the well-known-prefix and the IPv4 address.

I've done this using the OpenThread CLI example from the nRF Connect SDK.

I've created a project and I've included the Azure IoT Hub library. It runs but is unable to get a ip address for the provided domain.

I've looked at the Azure IoT Hub code and it uses getaddrinfo to get a ip address from a hostname.

What would be the best way to proceed? I can see the OpenThread CLI example uses a different method to retrieve the ip address from the DNS. Is there a way to configure a DNS server used by getaddrinfo?

Parents
  • Hi,

    It looks like getaddrinfo() internally calls dns_get_addr_info(), so you may be able to call dns_resolve_init() or dns_resolve_reconfigure() to set the DNS server address.

    You may also use the Kconfigs DNS_SERVER_IP_ADDRESSES and CONFIG_DNS_SERVERx to specify the DNS servers used by the DNS resolve library.

    Best regards,
    Jørgen

  • Hello Jørgen,

    I've tried to set the correct Server, but I am getting an error in the callback.

    I configure the DNS and try to resolve when the device connects to the Thread network. Also before the error in dns_result_cb, I get a error "<err> net_otPlat_radio: Error while calling otIp6Send"

    void set_dns_config(void)
    {
    	int ret;
    	const char *dns_server = "FDAA:BB:1::2";
    	struct dns_resolve_context *dnsctx;
    
    	dnsctx = dns_resolve_get_default();
    	ret = dns_resolve_reconfigure(dnsctx, &dns_server, NULL);
    }
    
    void dns_result_cb(enum dns_resolve_status status,
    				   struct dns_addrinfo *info,
    				   void *user_data)
    {
    	// fails with -101
    	// <inf> net_l2_openthread: State changed! Flags: 0x00000064 Current role: 3
    	// <err> net_otPlat_radio: Error while calling otIp6Send
    	// <inf> coap_server: dns_result_cb Failed: -101
    	if (status == 0)
    	{
    		LOG_INF("dns_result_cb Success");
    	}
    	else
    	{
    		LOG_INF("dns_result_cb Failed: %d", status);
    	}
    	return;
    }
    
    void resolve_dns(void)
    {
    	int ret;
    	struct dns_resolve_context *dnsctx;
    
    	dnsctx = dns_resolve_get_default();
    	ret = dns_resolve_name(dnsctx,
    						   "reddit.com",
    						   DNS_QUERY_TYPE_AAAA,
    						   NULL,
    						   dns_result_cb,
    						   NULL,
    						   1000);
    	if (ret != 0)
    	{
    		LOG_ERR("resolve_dns %d", ret);
    	}
    }

    Maybe I am missing a configuration, the command in OT CLI example does work.

    uart:~$ ot dns resolve reddit.com fdaa:bb:1::2 53 1000 2 1
    DNS response for reddit.com. - 64:ff9b:0:0:0:0:9765:c18c TTL:67 64:ff9b:0:0:0:0:9765:818c TTL:67 64:ff9b:0:0:0:0:9765:18c TTL:67 64:ff9b:0:0:0:0:9765:418c TTL:67
    Done

     

Reply
  • Hello Jørgen,

    I've tried to set the correct Server, but I am getting an error in the callback.

    I configure the DNS and try to resolve when the device connects to the Thread network. Also before the error in dns_result_cb, I get a error "<err> net_otPlat_radio: Error while calling otIp6Send"

    void set_dns_config(void)
    {
    	int ret;
    	const char *dns_server = "FDAA:BB:1::2";
    	struct dns_resolve_context *dnsctx;
    
    	dnsctx = dns_resolve_get_default();
    	ret = dns_resolve_reconfigure(dnsctx, &dns_server, NULL);
    }
    
    void dns_result_cb(enum dns_resolve_status status,
    				   struct dns_addrinfo *info,
    				   void *user_data)
    {
    	// fails with -101
    	// <inf> net_l2_openthread: State changed! Flags: 0x00000064 Current role: 3
    	// <err> net_otPlat_radio: Error while calling otIp6Send
    	// <inf> coap_server: dns_result_cb Failed: -101
    	if (status == 0)
    	{
    		LOG_INF("dns_result_cb Success");
    	}
    	else
    	{
    		LOG_INF("dns_result_cb Failed: %d", status);
    	}
    	return;
    }
    
    void resolve_dns(void)
    {
    	int ret;
    	struct dns_resolve_context *dnsctx;
    
    	dnsctx = dns_resolve_get_default();
    	ret = dns_resolve_name(dnsctx,
    						   "reddit.com",
    						   DNS_QUERY_TYPE_AAAA,
    						   NULL,
    						   dns_result_cb,
    						   NULL,
    						   1000);
    	if (ret != 0)
    	{
    		LOG_ERR("resolve_dns %d", ret);
    	}
    }

    Maybe I am missing a configuration, the command in OT CLI example does work.

    uart:~$ ot dns resolve reddit.com fdaa:bb:1::2 53 1000 2 1
    DNS response for reddit.com. - 64:ff9b:0:0:0:0:9765:c18c TTL:67 64:ff9b:0:0:0:0:9765:818c TTL:67 64:ff9b:0:0:0:0:9765:18c TTL:67 64:ff9b:0:0:0:0:9765:418c TTL:67
    Done

     

Children
No Data
Related