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

nRF9160 MQTT IPv6

Hi,

nRF9160 mqtt works with ipv4 by using "ncs\nrf\samples\nrf9160\mqtt_simple" application.

Now NB-IOT network which we are using is faced out the IPv4 and moved to IPv6. Now  nRF9160 is not connecting to mqtt server.

By looking into "ncs\nrf\samples\nrf9160\mqtt_simple" (https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/master/samples/nrf9160/mqtt_simple/src/main.c) it supports only IPv4.

Could you please point to IPV6 mqtt samples or any other client samples like COAP etc,.. that support IPv6.

Parents
  • Hi.

    If you look at the example ncs\nrf\samples\nrf9160\aws_fota\src\main.c, you can see that both IPv4 and IPv6 is supported.

    (Line 243 - 255)

            } else if (addr->ai_addrlen == sizeof(struct sockaddr_in6)) {
                /* IPv6 Address. */
                struct sockaddr_in6 *broker =
                    ((struct sockaddr_in6 *)&broker_storage);

                memcpy(broker->sin6_addr.s6_addr,
                    ((struct sockaddr_in6 *)addr->ai_addr)
                    ->sin6_addr.s6_addr,
                    sizeof(struct in6_addr));
                broker->sin6_family = AF_INET6;
                broker->sin6_port = htons(CONFIG_MQTT_BROKER_PORT);

                printk("IPv6 Address");
                break;

    I think you should be able to just add this code to the broker_init() function.

    Best regards,

    Andreas

Reply
  • Hi.

    If you look at the example ncs\nrf\samples\nrf9160\aws_fota\src\main.c, you can see that both IPv4 and IPv6 is supported.

    (Line 243 - 255)

            } else if (addr->ai_addrlen == sizeof(struct sockaddr_in6)) {
                /* IPv6 Address. */
                struct sockaddr_in6 *broker =
                    ((struct sockaddr_in6 *)&broker_storage);

                memcpy(broker->sin6_addr.s6_addr,
                    ((struct sockaddr_in6 *)addr->ai_addr)
                    ->sin6_addr.s6_addr,
                    sizeof(struct in6_addr));
                broker->sin6_family = AF_INET6;
                broker->sin6_port = htons(CONFIG_MQTT_BROKER_PORT);

                printk("IPv6 Address");
                break;

    I think you should be able to just add this code to the broker_init() function.

    Best regards,

    Andreas

Children
Related