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#

The network management HAL provides comprehensive network connection management interfaces, including Wi-Fi (STA and AP modes), LAN, and general network utilities. This document describes the available functions and their usage.


Constant Definitions#

Network Interface Types#

enum rt_netif_t {
    RT_NET_DEV_WLAN_STA = 0,  // Wi-Fi站点模式
    RT_NET_DEV_WLAN_AP  = 1,  // Wi-Fi接入点模式
    RT_NET_DEV_USB      = 2   // USB网络接口
};

Maximum Length Limits#

#define RT_WLAN_SSID_MAX_LENGTH 32         // SSID最大长度
#define RT_WLAN_PASSWORD_MAX_LENGTH 32     // 密码最大长度
#define RT_WLAN_BSSID_MAX_LENGTH 6         // MAC地址长度
#define RT_WLAN_STA_SCAN_MAX_AP 64         // 扫描结果中AP最大数量
#define NET_DEV_MAX_CNT 8                  // 最大网络设备数量

Wi-Fi STA Functionality#

Auto Reconnect Management#

netmgmt_wlan_sta_get_auto_reconnect()#

Function: Get auto reconnect status Parameters:

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

netmgmt_wlan_sta_set_auto_reconnect()#

Function: Enable/disable auto reconnect Parameters:

  • enable: 0 to disable, 1 to 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: Connect to AP using scan information Parameters:

  • info: Pointer to scan result information

  • password: Network password Return value: Returns 0 on success, -1 on failure

netmgmt_wlan_sta_disconnect_ap()#

Function: Disconnect from 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 of the 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


Scanning Functions#

netmgmt_wlan_sta_scan()#

Function: Scan for available APs Parameters:

  • ap_num: Pointer to store 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 for a specific SSID Parameters:

  • ssid: The SSID to search for

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


MAC Address Management#

netmgmt_wlan_sta_get_mac()#

Function: Get STA MAC address Parameters:

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

netmgmt_wlan_sta_set_mac()#

Function: Set STA MAC address Parameters:

  • mac: The 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 with SSID and password Parameters:

  • ssid: SSID of the AP

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

netmgmt_wlan_ap_start_with_info()#

Function: Start AP with configuration information Parameters:

  • info: AP configuration

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

netmgmt_wlan_ap_stop()#

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

netmgmt_wlan_ap_isactived()#

Function: Check whether the AP is active Parameters:

  • status: Pointer to store the 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 connected STA clients Parameters:

  • sta_num: Pointer to store the number of STAs

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

netmgmt_wlan_ap_disconnect_sta()#

Function: Disconnect a STA client Parameters:

  • mac: MAC address of the STA to disconnect 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 to store the country code Return Value: Returns 0 on success, -1 on failure

netmgmt_wlan_ap_set_country()#

Function: Set AP country code Parameters:

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


LAN Functionality#

Connection Status#

netmgmt_lan_get_isconnected()#

Function: Check whether LAN is connected Parameters:

  • status: Pointer to store the 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 the MAC address Return Value: Returns 0 on success, -1 on failure

netmgmt_lan_set_mac()#

Function: Set LAN MAC address Parameters:

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


Network Tools#

Device Management#

netmgmt_utils_get_defeault_dev()#

Function: Get 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: Name to set as the default device Return Value: Returns 0 on success, -1 on failure

netmgmt_utils_get_dev_list()#

Function: Get network device list Parameters:

  • dev_num: Pointer to store device count

  • names: Array to store device names Return Value: Returns 0 on success, -1 on failure

netmgmt_utils_probe_device()#

Function: Probe network interface availability Parameters:

  • itf: Interface type

  • status: Pointer to store probe result 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 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 Structures#

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 status

struct ifconfig_t#

Contains IP configuration information, including:

  • IP address

  • Gateway

  • Subnet mask

  • DNS server


Notes#

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

  2. Callers must check buffer sizes to prevent overflow

  3. Network operations may take time to complete - if needed, check status after a delay

Comments list
Comments
Log in