net

The netw module is the low-level interface to the on-board u-blox networking module that provides WiFi and Bluetooth. It works by exchanging messages with the module using the u-blox EDM (Extended Data Mode) protocol and AT commands.

Note:

Most applications do not need to use netw directly. The higher-level net_new.py helper module (available in the Frameworks download) wraps these functions to provide simpler WiFi scanning, connection, HTTP, MQTT and Bluetooth APIs. See the Wireless Connections tutorials for how to use it.

get_init_status

Returns the initialisation status of the networking module.

netw.get_init_status()

The returned integer is one of the following constants:

  • netw.INIT_OK = Initialisation complete and ready to use.

  • netw.INIT_CONF0 = Initial configuration stage.

  • netw.INIT_RESET = The module is being reset.

  • netw.INIT_BEGIN = Initialisation has started.

  • netw.INIT_FAILURE = Initialisation failed.

get_hwmodule_info

Returns information about the networking module hardware.

netw.get_hwmodule_info()

Returns a named tuple with the fields mfr (manufacturer), model, version and serial, or None if the information is not available.

set_callback

Sets the function that is called when a new message is received from the networking module. Pass None to remove the callback.

netw.set_callback(callback)

Input Parameters:

  • callback[func] = The function to call when a new message is received.

new_message

Returns True if a new message is waiting to be read, otherwise False.

netw.new_message()

get_messages

Returns the messages received from the networking module and clears the “new message” flag.

netw.get_messages()

verbose

Sets the level of diagnostic output produced by the networking module, or returns the current level if no value is passed.

netw.verbose(level)

Input Parameters:

  • level[int] = The verbosity level to set. One of netw.VERBOSE_NONE, netw.VERBOSE_RESPONSE or netw.VERBOSE_ALL. If no value is passed, the current level is returned instead.

tx_msg_edm

Sends a message to the networking module using the EDM protocol. This is the function used to send AT commands.

netw.tx_msg_edm(payload, type)

Input Parameters:

  • payload[str] = The message payload, for example an AT command. Must be no longer than 4095 bytes.

  • type[int] = The EDM message type, for example netw.UBX_EDM_CMD_AT_REQ for an AT command request.