Getting nRF5340DK + W5500 Ethernet Shield with MQTT + TLS to work

Hi,

I am working on a setup where nRF5340 uses W5500 Ethernet IC and communicate MQTT over TLS. The actual setup for now is nrf5340dk + w5500 ethernet shield.

I am working with the nrf/samples/networking/mqtt sample (NCS version 2.6.0), with slight modification (added DHCP and modified one of the Kconfig settings).

I have managed to get it to work without TLS (without the overlay-tis-nrf53.conf added to the build in the attached project).

However when I add the TLS overlay file I get -123 (unknown protocol) error during mqtt_connect.

I ran a debug session and it seems to error (-123) during a call to:

client->transport.tls.sock = zsock_socket(broker->sa_family,
						  type, IPPROTO_TLS_1_2);

in mqtt_transport_socket_tls.c (line 32).

I'm guessing something is not correctly setup in Kconfig? 

I have attached the zipped project. I'd appreciate if someone can help me.

Best Regards,

Makoto

4628.mqtt_260.zip

Parents Reply Children
  • Hi Øyvind,

    Thank you for your help. Below is the log I see after turning on CONFIG_MQTT_HELPER_LOG_LEVEL_DBG=y in my project.

    [00:00:00.391,387] <inf> eth_w5500: W5500 Initialized
    *** Booting nRF Connect SDK v3.5.99-ncs1 ***
    [00:00:00.398,040] <inf> network: Bringing network interface up and connecting to the network
    [00:00:00.398,101] <inf> network: DHCP Client Start on w5500: index=1
    [00:00:00.398,986] <dbg> mqtt_helper: mqtt_state_set: State transition: MQTT_STATE_UNINIT --> MQTT_STATE_DISCONNECTED
    [00:00:00.399,414] <dbg> mqtt_helper: mqtt_helper_poll_loop: Waiting for connection_poll_sem
    [00:00:00.503,906] <inf> network: Network connectivity established
    [00:00:03.933,990] <inf> net_dhcpv4: Received: 192.168.10.5
    [00:00:03.934,234] <inf> network:    Address[1]: 192.168.10.5
    [00:00:03.934,295] <inf> network:     Subnet[1]: 255.255.255.0
    [00:00:03.934,326] <inf> network:     Router[1]: 192.168.10.1
    [00:00:03.934,356] <inf> network: Lease time[1]: 86400 seconds
    [00:00:05.504,425] <dbg> mqtt_helper: broker_init: Resolving IP address for test.mosquitto.org
    [00:00:06.627,777] <dbg> mqtt_helper: broker_init: IPv4 Address found 91.121.93.94 (AF_INET)
    [00:00:06.627,838] <dbg> mqtt_helper: certificates_provision: CA certificate already exists, sec tag: 955
    [00:00:06.627,868] <dbg> mqtt_helper: mqtt_state_set: State transition: MQTT_STATE_DISCONNECTED --> MQTT_STATE_TRANSPORT_CONNECTING
    [00:00:06.627,899] <err> mqtt_helper: mqtt_connect, error: -123
    [00:00:06.627,960] <dbg> mqtt_helper: mqtt_state_set: State transition: MQTT_STATE_TRANSPORT_CONNECTING --> MQTT_STATE_DISCONNECTED
    [00:00:06.627,960] <err> transport: Failed connecting to MQTT, error code: -123

  • Hi, can I get any further help on this?

    I've tried to post in the Zephyr Discord, but got no response.

    I saw this thread, which seems like an example that would help, but I still can't get mine to work...

    Best Regards,

    Makoto

  • Hi Makoto, 

    No, I'm afraid that I have not had more time to look into this. The thread you pointed to is the closest and possibly the best answer at the moment. 

    Kind regards,
    Øyvind

Related