Azure MQTT with GSM modem over PPP #nrf52840 #mqtt #ppp #modem


petrus.vanderwalt@...
 

Hi, Zephyr community.  I am trying to add Azure MQTT functionality to my project.  I am using an nRF52840 with a Quectel BG96/Sara R412M-02B.  I would also like to use the modem functionality to communicate to cellular towers over PPP.

Currently, I have the gsm_modem sample up and running for my Quectel BG96 and U-Blox SARA R412.  I also have the tagio_http_post sample up and running.  I would also want to adapt the tagio_http_post sample to work for Azure.  Would this be easy to do?  Have anyone tried to do this?

I am now playing around with the mqtt_azure sample.  I have added PPP support by adding a modem overlay.  I had to disable the DHCPV4 and use a static IP address.  The sample successfully resolves the DNS for azure.  The issue comes thereafter.  The sample fails to connect.  The following is the output I get:
[00:00:13.283,172] <inf> modem_gsm: Manufacturer: u-blox
[00:00:13.362,243] <inf> modem_gsm: Model: SARA-R412M-02B
[00:00:13.442,871] <inf> modem_gsm: Revision: M0.10.00 [Mar 28 2019 17:13:41]
[00:00:13.523,864] <inf> modem_gsm: IMSI: 655014150468485
[00:00:13.604,797] <inf> modem_gsm: ICCID: 89415000000004684852
[00:00:13.685,394] <inf> modem_gsm: IMEI: 354679092855504
[00:00:13.847,473] <inf> modem_gsm: Attached to packet service!
[00:00:13.880,706] <inf> net_ppp: Initializing PPP to use UART_1
[00:00:13.904,815] <inf> net_config: Interface 1 (0x20000544) coming up
[00:00:13.931,030] <inf> net_config: IPv4 address: 192.0.2.1
[00:00:13.954,803] <dbg> mqtt_azure.main: Waiting for network to setup...
[00:00:15.979,888] <err> mqtt_azure: DNS not resolved for WCM.azure-devices.net:
[00:00:16.744,842] <inf> mqtt_azure: DNS resolved for WCM.azure-devices.net:8883
[00:00:16.770,294] <dbg> mqtt_azure.try_to_connect: attempting to connect...
[00:00:19.802,642] <err> mqtt_azure: mqtt_connect failed -116
[00:00:22.833,923] <err> mqtt_azure: mqtt_connect failed -116
[00:00:25.865,234] <err> mqtt_azure: mqtt_connect failed -116

I can not seem to find the definition of error -116.  Does anyone have an idea what this error is referring to?

This is my Azure config:
#define CONFIG_SAMPLE_CLOUD_AZURE_USERNAME "XXX.azure-devices.net/Device-01/?api-version=2018-06-30"
#define CONFIG_SAMPLE_CLOUD_AZURE_PASSWORD "1XbHvFPxHZq1cD380GqCcCxUOAv3SXtecBRGGIXXXXg="
#define CONFIG_SAMPLE_CLOUD_AZURE_CLIENT_ID "Device-01"
#define CONFIG_SAMPLE_CLOUD_AZURE_HOSTNAME "XXX.azure-devices.net"
#define CONFIG_SAMPLE_CLOUD_AZURE_SERVER_ADDR "XXX.61.54.255"
#define CONFIG_SAMPLE_CLOUD_AZURE_SERVER_PORT 8883

My project config as follows:
CONFIG_NETWORKING=y
 
# Disable IPv6 support
CONFIG_NET_IPV6=n
 
# Enable IPv4 support
CONFIG_NET_IPV4=y
CONFIG_NET_IF_MAX_IPV4_COUNT=2
CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=3
 
# Enable TCP support
CONFIG_NET_TCP=y
 
# Enable Sockets support
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_SOCKOPT_TLS=y
 
# Disable DHCPv4 and use static address
CONFIG_NET_DHCPV4=n
 
# Use local DNS server on host
CONFIG_DNS_SERVER1="192.0.2.2"
 
# Configure static addresses
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
CONFIG_NET_CONFIG_MY_IPV4_GW="192.0.2.2"
 
# Enable SOCKS5 proxy support
CONFIG_SOCKS=n
 
# Enable MQTT Lib support
CONFIG_MQTT_LIB=y
CONFIG_MQTT_LIB_TLS=y
 
# Enable Mbed TLS configuration
CONFIG_MBEDTLS=y
CONFIG_MBEDTLS_BUILTIN=y
CONFIG_MBEDTLS_ENABLE_HEAP=y
CONFIG_MBEDTLS_HEAP_SIZE=100000
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=10240
CONFIG_MBEDTLS_PEM_CERTIFICATE_FORMAT=y
 
# Network configuration
CONFIG_NET_CONFIG_SETTINGS=y
 
# Network connection manager
CONFIG_NET_CONNECTION_MANAGER=y
 
CONFIG_NET_MGMT_EVENT_STACK_SIZE=1024
CONFIG_NET_MGMT_EVENT_QUEUE_SIZE=5
CONFIG_NET_MGMT_EVENT_LOG_LEVEL_DBG=n
 
CONFIG_DNS_RESOLVER=y
CONFIG_DNS_SERVER_IP_ADDRESSES=y
CONFIG_DNS_SERVER1="8.8.8.8"
CONFIG_DNS_RESOLVER_ADDITIONAL_BUF_CTR=2
CONFIG_NEWLIB_LIBC=y
 
CONFIG_INIT_STACKS=y
CONFIG_NET_SHELL=y
 
CONFIG_MAIN_STACK_SIZE=4096
 
# Enable Logging support
CONFIG_LOG_IMMEDIATE=y
CONFIG_NET_LOG=y
CONFIG_NET_TCP_LOG_LEVEL_DBG=n
CONFIG_NET_SOCKETS_LOG_LEVEL_DBG=n
CONFIG_MQTT_LOG_LEVEL_DBG=n
CONFIG_NET_DHCPV4_LOG_LEVEL_INF=y
CONFIG_NET_IF_LOG_LEVEL_DBG=n
CONFIG_MBEDTLS_DEBUG=n
#CONFIG_MBEDTLS_DEBUG_LEVEL=4
CONFIG_SOCKS_LOG_LEVEL_DBG=n
CONFIG_NET_CONFIG_LOG_LEVEL_DBG=y
CONFIG_NET_CONNECTION_MANAGER_LOG_LEVEL_DBG=n
CONFIG_DNS_RESOLVER_LOG_LEVEL_DBG=n
CONFIG_NET_CONTEXT_LOG_LEVEL_DBG=n

My modem overlay:
# UART support
CONFIG_SERIAL=y
 
# GSM modem support
CONFIG_MODEM=y
CONFIG_MODEM_SHELL=y
CONFIG_MODEM_CMD_HANDLER_MAX_PARAM_COUNT=20
CONFIG_MODEM_GSM_PPP=y
CONFIG_MODEM_GSM_RX_STACK_SIZE=1024
CONFIG_MODEM_GSM_UART_NAME="UART_1"
CONFIG_MODEM_GSM_APN="internet"
 
# Network management events
CONFIG_NET_CONNECTION_MANAGER=y
 
# PPP networking support
CONFIG_NET_NATIVE=y
CONFIG_NET_PPP=y
CONFIG_NET_L2_PPP=y
CONFIG_NET_L2_PPP_TIMEOUT=10000
 
CONFIG_DNS_RESOLVER_MAX_SERVERS=1
CONFIG_DNS_SERVER_IP_ADDRESSES=y
CONFIG_DNS_SERVER1="8.8.8.8"

My main.c stayed unchanged.  I am hoping someone in the community has done something similar and can maybe help me out.  Any help would be appreciated.

Thanks,
Jurgens

Join users@lists.zephyrproject.org to automatically receive all group messages.