Note: This repository is a work in progress
This repository contains the out of tree BG9x modem driver with SSL socket offloading for Zephyr RTOS.
This means that the modem takes care of layers 1-4 of the OSI model, plus the SSL layer, instead of using native Zephyr sockets with MBEDTLS for SSL. The driver is using net socket offload to allow transparent use of the modem as a network interface. Currently only one socket at a time is supported, this is usually enough for IoT applications such as Azure IoT Hub and other MQTT brokers.
- SSL socket offloading as a Zephyr network interface
- CA certificate, client certificate and client key file upload to the modem
- Socket offloading for client SSL sockets
- Setsockopt runtime certificate provisioning support
- Currently only one socket at a time is supported
- PM device power management support
- DNS resolve offloading support (getaddrinfo)
- Kconfig support for cert and key file path auto provisioning
- connectivity manager support (conn_mgr) - currently connect and disconnect only
- Two samples are included:
- MQTT publisher sample (test.mosquitto.org)
- Azure IOT Hub sample application using NRF IOT Hub library
Also included is a sample application that demonstrates the driver. Currently the only sample application is Zephyr's MQTT publisher sample with SSL socket offloading.
- Connectivity manager setopt and getopt to allow user to set the modem's APN and connection perferences
- Aquire modem info on startup (IMEI, IMSI, etc.)
- More than one socket at a time (low priority as it is not required for MQTT/IoT Hub)
- Test and use with BG96
- HTTPS sample application
- BG95M3 on NRF52840
- Nordic SDK v2.5.0 (Zephyr v3.4.99-ncs1)
TODO: Describe how to use the driver.
Enable the driver in the project's prj.conf file:
CONFIG_BG9X_MODEM_SSL=y
Next, configure the required security level:
- For encryption without client authentication, security level 1 is required and CA certificate is mandatory.
CONFIG_BG9X_SSL_MODEM_SECURITY_LEVEL=1
CONFIG_BG9X_SSL_MODEM_CA_CERT="mosquitto.org.crt"
- For encryption with client authentication, security level 2 is required and CA certificate, client certificate and client key are mandatory.
CONFIG_BG9X_SSL_MODEM_SECURITY_LEVEL=2
CONFIG_BG9X_SSL_MODEM_CA_CERT="mosquitto.org.crt"
CONFIG_BG9X_SSL_MODEM_CLIENT_CERT="client.crt"
CONFIG_BG9X_SSL_MODEM_CLIENT_KEY="client.key"
- For no encryption, security level 0 is required and no certificates are required.
CONFIG_BG9X_SSL_MODEM_SECURITY_LEVEL=0
Other required configuration options:
CONFIG_UART_ASYNC_API=y
CONFIG_BG9X_SSL_MODEM_APN="internet"
# for debug prints
CONFIG_MODEM_LOG_LEVEL_DBG=y
The driver reuires a bg9x modem node in a uart bus, for example:
/ {
aliases {
modem = &modem;
};
}
&uart1 {
compatible = "nordic,nrf-uarte";
status = "okay";
current-speed = <115200>;
pinctrl-0 = <&uart1_default>;
pinctrl-1 = <&uart1_sleep>;
pinctrl-names = "default", "sleep";
hw-flow-control;
modem: modem {
compatible = "quectel,bg95";
mdm-power-gpios = <&gpio0 26 GPIO_ACTIVE_HIGH>;
status = "okay";
};
};