Note

This is the documentation for the latest development branch and may refer to features that are not available in released versions. If you are looking for the documentation for a specific release, use the drop-down menu on the left and select the desired version.

K230 NetMgmt API Reference#

Overview#

Network management HAL provides a comprehensive network connection management interface, including Wi-Fi (STA and AP mode), LAN and general network tools. This document describes the available features and how to use them.


constant definition#

Network interface type#

enum rt_netif_t {
    RT_NET_DEV_WLAN_STA = 0,  // Wi-Fi station mode
    RT_NET_DEV_WLAN_AP  = 1,  // Wi-Fi access point mode
    RT_NET_DEV_USB      = 2   // USB network interface
};

Maximum length limit#

#define RT_WLAN_SSID_MAX_LENGTH 32         // Maximum SSID length
#define RT_WLAN_PASSWORD_MAX_LENGTH 32     // Maximum password length
#define RT_WLAN_BSSID_MAX_LENGTH 6         // MAC address length
#define RT_WLAN_STA_SCAN_MAX_AP 64         // Maximum AP count in scan results
#define NET_DEV_MAX_CNT 8                  // Maximum number of network devices

Wi-Fi STA function#

Automatic reconnection management#

netmgmt_wlan_sta_get_auto_reconnect()#

Function: Get automatic reconnection status Parameters:

  • enable: Pointer to store state (0=disabled, 1=enabled) Return Value: Returns 0 on success, -1 on failure

netmgmt_wlan_sta_set_auto_reconnect()#

Function: Enable/disable automatic reconnection Parameters:

  • enable: 0 disable, 1 enable Return Value: Returns 0 on success, -1 on failure


Connection management#

netmgmt_wlan_sta_connect_with_ssid()#

Function: Connect to AP using SSID and password Parameters:

  • ssid: Network SSID

  • password: network password Return Value: Returns 0 on success, -1 on failure

netmgmt_wlan_sta_connect_with_scan_info()#

Function: Use scanned information to connect to AP Parameters:

  • info: Scan result information pointer

  • password: network password Return Value: Returns 0 on success, -1 on failure

netmgmt_wlan_sta_disconnect_ap()#

Function: Disconnect current AP connection Return Value: Returns 0 on success, -1 on failure

netmgmt_wlan_sta_isconnected()#

Function: Check connection status Parameters:

  • status: Pointer to store status (1=connected, 0=not connected) Return Value: Returns 0 on success, -1 on failure


AP information acquisition#

netmgmt_wlan_sta_get_ap_info()#

Function: Get information about connected AP Parameters:

  • info: Pointer to store AP information Return Value: Returns 0 on success, -1 on failure

netmgmt_wlan_sta_get_rssi()#

Function: Get signal strength (RSSI) Parameters:

  • rssi: Pointer to store RSSI value Return Value: Returns 0 on success, -1 on failure


Scan function#

netmgmt_wlan_sta_scan()#

Function: Scan for available APs Parameters:

  • ap_num: Pointer that stores the number of discovered APs

  • ap_infos: Array to store AP information Return Value: Returns 0 on success, -1 on failure

netmgmt_wlan_sta_scan_with_ssid()#

Function: Scan specific SSID Parameters:

  • ssid: SSID to search for

  • ap_info: Pointer to store the found AP information Return Value: Returns 0 if found, otherwise returns -1


MAC address management#

netmgmt_wlan_sta_get_mac()#

Function: Get STA MAC address Parameters:

  • mac: Buffer to store MAC address Return Value: Returns 0 on success, -1 on failure

netmgmt_wlan_sta_set_mac()#

Function: Set STA MAC address Parameters:

  • mac: MAC address to be set Return Value: Returns 0 on success, -1 on failure


Wi-Fi AP functions#

AP management#

netmgmt_wlan_ap_start_with_ssid()#

Function: Start AP using SSID and password Parameters:

  • ssid: SSID of AP

  • password: AP password Return Value: Returns 0 on success, -1 on failure

netmgmt_wlan_ap_start_with_info()#

Function: Start AP using configuration information Parameters:

  • info: AP configuration

  • password: AP password Return Value: Returns 0 on success, -1 on failure

netmgmt_wlan_ap_stop()#

Function: Stop AP Return Value: Returns 0 on success, -1 on failure

netmgmt_wlan_ap_isactived()#

Function: Check if AP is active Parameters:

  • status: Pointer to store status (1=active, 0=inactive) Return Value: Returns 0 on success, -1 on failure


AP information acquisition#

netmgmt_wlan_ap_get_info()#

Function: Get AP configuration information Parameters:

  • info: Pointer to store AP information Return Value: Returns 0 on success, -1 on failure

netmgmt_wlan_ap_get_sta_info()#

Function: Get the connected STA client Parameters:

  • sta_num: Pointer storing the number of STA

  • sta_infos: Array to store STA information Return Value: Returns 0 on success, -1 on failure

netmgmt_wlan_ap_disconnect_sta()#

Function: Disconnect STA client Parameters:

  • mac: MAC address of the STA to be disconnected Return Value: Returns 0 on success, -1 on failure


Country code settings#

netmgmt_wlan_ap_get_country()#

Function: Get AP country code Parameters:

  • country: Pointer storing country code Return Value: Returns 0 on success, -1 on failure

netmgmt_wlan_ap_set_country()#

Function: Set AP country code Parameters:

  • country: Country code to be set Return Value: Returns 0 on success, -1 on failure


LAN function#

connection status#

netmgmt_lan_get_isconnected()#

Function: Check if LAN is connected Parameters:

  • status: Pointer to store status (1=connected, 0=not connected) Return Value: Returns 0 on success, -1 on failure


MAC address management#

netmgmt_lan_get_mac()#

Function: Get LAN MAC address Parameters:

  • mac: Buffer to store MAC address Return Value: Returns 0 on success, -1 on failure

netmgmt_lan_set_mac()#

Function: Set LAN MAC address Parameters:

  • mac: MAC address to be set Return Value: Returns 0 on success, -1 on failure


Network tools#

Device management#

netmgmt_utils_get_defeault_dev()#

Function: Get the default network device Parameters:

  • name: Buffer to store device name Return Value: Returns 0 on success, -1 on failure

netmgmt_utils_set_defeault_dev()#

Function: Set default network device Parameters:

  • name: The name of the device to be set as the default Return Value: Returns 0 on success, -1 on failure

netmgmt_utils_get_dev_list()#

Function: Get the list of network devices Parameters:

  • dev_num: Pointer to the number of storage devices

  • names: array storing device names Return Value: Returns 0 on success, -1 on failure

netmgmt_utils_probe_device()#

Function: Detect network interface availability Parameters:

  • itf: Interface type

  • status: Pointer to store detection results Return Value: Returns 0 on success, -1 on failure


IP configuration#

netmgmt_utils_get_ifconfig()#

Function: Get interface IP configuration Parameters:

  • itf: Interface type

  • config: Pointer to store IP configuration Return Value: Returns 0 on success, -1 on failure

netmgmt_utils_set_ifconfig_static()#

Function: Set static IP configuration Parameters:

  • itf: Interface type

  • config: IP configuration to be set Return Value: Returns 0 on success, -1 on failure

netmgmt_utils_set_ifconfig_dhcp()#

Function: Enable DHCP for the interface Parameters:

  • itf: Interface type Return Value: Returns 0 on success, -1 on failure


data structure#

struct rt_wlan_info_t#

Contains Wi-Fi network information, including:

  • security type

  • Frequency band (2.4GHz/5GHz)

  • data rate

  • channel

  • RSSI (signal strength)

  • SSID

  • BSSID(MAC address)

  • Hidden state

struct ifconfig_t#

Contains IP configuration information, including:

  • IP address

  • gateway

  • subnet mask

  • DNS server


Things to note#

  1. Unless otherwise stated, all functions return 0 on success and -1 on failure.

  2. The caller must check the buffer size to prevent overflow

  3. Network operations may take time to complete - check status after delay if necessary

Comments list
Comments
Log in