Helper library to query network information and return it as either a zcbor map (useful for Golioth Remote Procedure Calls) or as a Zephyr log message.
-
Add this repository to your
west.yml
fileprojects
section (be sure to update the revision number to newest/desired):projects: - name: zephyr-network-info path: modules/lib/network-info revision: v1.0.0 url: https://github.com/golioth/zephyr-network-info
-
Enable the library in prj.conf:
CONFIG_NETWORK_INFO=y
-
Add
#include "network_info.h"
to your calling file -
Call your desired function 2. Write network info to log files:
network_info_log()
-
Return network info as a Golioth RPC:
static enum golioth_rpc_status on_get_network_info(zcbor_state_t *request_params_array, zcbor_state_t *response_detail_map, void *callback_arg) { network_info_add_to_map(response_detail_map); return GOLIOTH_RPC_OK; }
-
Boards that use Nordic's Modem Info library, like the nRF9160, can use this network info library. After following the steps above, add the following symbols to the conf file for your board in the boards directory:
# Add Network Info Support
CONFIG_MODEM_INFO=y
CONFIG_GOLIOTH_RPC_MAX_RESPONSE_LEN=512
This library holds device-specific files for returning network info. Only one of
these files should be built into a project. This is selected using the
CMakeLists.txt
and Kconfg
files.
-
Create the new C file
-
Add
#include <network_info.h>
-
Implement required functions:
-
int network_info_add_to_map(QCBOREncodeContext *response_detail_map)
-
int network_info_log(void)
-
-
-
Add C file to
CMakeLists.txt
gated by theKconfig
symbol for that file:zephyr_library_sources_ifdef(CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP network_info_nrf7002dk.c) zephyr_library_sources_ifdef(CONFIG_MODEM_INFO network_info_modem_info.c)