Net Manager API 参考
宏定义
-
WIFI_STATION_NETIF_NAME
Name of station netif.
-
WIFI_SOFTAP_NETIF_NAME
Name of softAP netif.
-
WM_NM_INVALID_NETIF
Invalid net manager netif handle.
枚举
-
enum wm_nm_netif_flag_e
Flag of net manager’s netif.
Values:
-
enumerator NM_NETIF_FLAG_UP
-
enumerator NM_NETIF_FLAG_BROADCAST
If set, the netif has broadcast capability.
-
enumerator NM_NETIF_FLAG_LINK_UP
If set, the interface has an active link
-
enumerator NM_NETIF_FLAG_ETHARP
If set, the netif is an ethernet device using ARP
-
enumerator NM_NETIF_FLAG_ETHERNET
If set, the netif is an ethernet device using ARP.
-
enumerator NM_NETIF_FLAG_IGMP
If set, the netif is an ethernet device.
-
enumerator NM_NETIF_FLAG_MLD6
If set, the netif has IGMP capability.
-
enumerator NM_NETIF_FLAG_UP
-
enum wm_nm_dns_type_t
Type of DNS server.
Values:
-
enumerator WM_NM_DNS_MAIN
DNS main server address.
-
enumerator WM_NM_DNS_BACKUP
DNS backup server address.
-
enumerator WM_NM_DNS_MAIN
-
enum wm_nm_state_e
State of net manager.
Values:
-
enumerator WM_NM_INIT
net manager state: initializing.
-
enumerator WM_NM_WIFI_STA_CONNECTING
net manager state: connecting to AP. only for Wi-Fi station.
-
enumerator WM_NM_WIFI_STA_CONNECTED
net manager state: connected to AP. only for Wi-Fi station.
-
enumerator WM_NM_WIFI_STA_DISCONNECTED
net manager state: disconnect from AP. only for Wi-Fi station.
-
enumerator WM_NM_WIFI_STA_GOT_IP
net manager state: got IPv4. only for Wi-Fi station.
-
enumerator WM_NM_WIFI_STA_GOT_IP6
net manager state: got global IPv6. only for Wi-Fi station.
-
enumerator WM_NM_WIFI_STA_LOST_IP
net manager state: lost IPv4. only for Wi-Fi station.
-
enumerator WM_NM_WIFI_STA_LOST_IP6
net manager state: lost global IPv6. only for Wi-Fi station.
-
enumerator WM_NM_WIFI_AP_READY
net manager state: softAP is ready. only for Wi-Fi softap.
-
enumerator WM_NM_WIFI_AP_ASSIGNED_IP_ID
net manager state: softAP assigns IP to station. only for Wi-Fi softap.
-
enumerator WM_NM_EXIT
net manager state: exit, cannot be used.
-
enumerator WM_NM_INIT
结构体
-
struct wm_netif_ip_info_t
struct of ip info
-
struct wm_nm_dhcps_option_t
struct of dhcp server option
Public Members
-
wm_ip_addr_t server_ip
DHCP server ip.
-
wm_ip_addr_t start_ip
DHCP server assign IP starting address.
-
wm_ip_addr_t ip_mask
DHCP server assign IP netmask.
-
wm_ip_addr_t gateway
DHCP server assign gateway.
-
wm_ip_addr_t dns1
DHCP server assign DNS server IP address1.
-
wm_ip_addr_t dns2
DHCP server assign DNS server IP address2.
-
uint32_t lease_time
DHCP server assign IP lease time(seconds).
-
wm_ip_addr_t server_ip
-
struct wm_nm_wifi_station_cfg_t
struct of Wi-Fi station config
-
struct wm_nm_wifi_softap_cfg_t
struct of Wi-Fi softap config
API 参考
Netif API
-
wm_nm_netif_t wm_nm_get_netif(void)
Query available netif.
- 返回:
WM_NM_INVALID_NETIF: No available netif found
others: Available netif
-
int wm_nm_get_netif_number(void)
Query number of available netif.
- 返回:
0: No available netif
others: number of available netif
-
wm_nm_netif_t wm_nm_get_next_netif(wm_nm_netif_t netif)
Query next available netif.
- 参数:
netif – [in] Current netif
- 返回:
WM_NM_INVALID_NETIF: No next netif found
others: Available netif
-
const char *wm_nm_get_netif_name(wm_nm_netif_t netif)
Query netif name from net manager.
- 参数:
netif – [in] Netif
- 返回:
NULL: Invalid netif
others: Netif name
-
wm_nm_netif_t wm_nm_get_netif_by_name(const char *name)
Query netif by name.
- 参数:
name – [in] Netif name
- 返回:
WM_NM_INVALID_NETIF: No found netif
others: Available netif
-
int wm_nm_get_netif_flag(wm_nm_netif_t netif, uint32_t *flag)
Query the netif flag.
- 参数:
netif – [in] Netif handle
flag – [in] flag write back address
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_nm_get_netif_mtu(wm_nm_netif_t netif, uint32_t *mtu)
Query the netif mtu.
- 参数:
netif – [in] Netif handle
mtu – [in] mtu write back address
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_nm_set_netif_mac(wm_nm_netif_t netif, uint8_t *mac, size_t len)
Set the MAC address.
- 参数:
netif – [in] Netif handle
mac – [in] MAC address buffer
len – [in] MAC address length
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_nm_get_netif_mac(wm_nm_netif_t netif, uint8_t *mac, size_t *max_len)
Query the MAC address.
- 参数:
netif – [in] Netif handle
mac – [in] MAC address write back buffer
max_len – [in] write back buffer maximum length
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_nm_set_netif_ip_info(wm_nm_netif_t netif, wm_netif_ip_info_t *ip_info)
Set the IPv4 address.
备注
Set the IPv4 address, it will be stop DHCP client
- 参数:
netif – [in] Netif handle
ip_info – [in] include IPv4 address, net mask, gateway
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_nm_get_netif_ip_info(wm_nm_netif_t netif, wm_netif_ip_info_t *ip_info)
Query the IPv4 address.
备注
After setting the IP, DHCP server/client will be stopped
- 参数:
netif – [in] Netif handle
ip_info – [in] Net info write back address
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_nm_enable_netif_ip6(wm_nm_netif_t netif)
Enable IPv6 function.
- 参数:
netif – [in] Netif handle
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_nm_disable_netif_ip6(wm_nm_netif_t netif)
disable IPv6 function
- 参数:
netif – [in] Netif handle
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
bool wm_nm_get_netif_ip6_state(wm_nm_netif_t netif)
Query the IPv6 enable or disable.
- 参数:
netif – [in] Netif handle
- 返回:
FALSE: invalid argument or IPv6 is not enabled
TRUE: IPv6 is enabled
-
int wm_nm_get_netif_ip6_linklocal(wm_nm_netif_t netif, wm_ip6_addr_t *ip6)
Query the IPv6 address.
- 参数:
netif – [in] Netif handle
ip6 – [in] IPv6 linklocal address write back address
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_nm_get_netif_ip6_global(wm_nm_netif_t netif, wm_ip6_addr_t *ip6)
Query the IPv6 address.
- 参数:
netif – [in] Netif handle
ip6 – [in] IPv6 global address write back address
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_nm_set_netif_dhcps_option(wm_nm_netif_t netif, wm_nm_dhcps_option_t *dhcps_option)
Set DHCP server options.
备注
After DHCP server start, The original IP info will be overwritten
- 参数:
netif – [in] Netif handle
dhcps_option – [in] reference wm_nm_dhcps_option_t
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_nm_get_netif_dhcps_option(wm_nm_netif_t netif, wm_nm_dhcps_option_t *dhcps_option)
Query DHCP server options.
- 参数:
netif – [in] Netif handle
dhcps_option – [in] DHCP server options write back address
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_nm_start_netif_dhcps(wm_nm_netif_t netif)
start DHCP server
- 参数:
netif – [in] Netif handle
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_nm_stop_netif_dhcps(wm_nm_netif_t netif)
stop DHCP server
- 参数:
netif – [in] Netif handle
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_nm_start_netif_dhcpc(wm_nm_netif_t netif)
start DHCP client
备注
if set static IP, start DHCP will fail,
备注
if you want restart DHCP, must set ip to “0.0.0.0” first.
- 参数:
netif – [in] Netif handle
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_nm_stop_netif_dhcpc(wm_nm_netif_t netif)
stop DHCP client
- 参数:
netif – [in] Netif handle
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_nm_set_dns(wm_nm_dns_type_t type, wm_ip_addr_t *dns)
Set DHCP server start.
备注
After setting DNS, DHCP server allocated DNS server will be ignored
- 参数:
type – [in] DNS main server or backup server
dns – [in] DNS server address
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_nm_get_dns(wm_nm_dns_type_t type, wm_ip_addr_t *dns)
Query DHCP server start.
- 参数:
type – [in] DNS main server or backup server
dns – [in] DNS server address write back address
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_nm_start_netif_dnss(wm_nm_netif_t netif)
start DNS server
备注
It only works on the softap mode.
- 参数:
netif – [in] Netif handle
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_nm_stop_netif_dnss(wm_nm_netif_t netif)
stop DNS server
备注
It only works on the softap mode.
- 参数:
netif – [in] Netif handle
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
WiFi API
-
int wm_nm_start_wifi_station(wm_nm_wifi_station_cfg_t *cfg)
Start Wi-Fi station mode, It will be init Wi-Fi and connected to the specified AP, as well as start the DHCP client.
- Attention
This is asynchronous API. Please subscribe to the NM event, or call wm_nm_get_wifi_station_state to query the connection results
- 参数:
cfg – [in] reference wm_nm_wifi_station_cfg_t
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
wm_nm_state_e wm_nm_get_wifi_station_state(void)
Query NM Wi-Fi station state.
- 返回:
reference wm_nm_state_e
-
int wm_nm_stop_wifi_station(void)
Stop Wi-Fi station mode, It will be disconnect from AP.
- 返回:
WM_ERR_SUCCESS: succeed
others: failed
-
int wm_nm_start_wifi_softap(wm_nm_wifi_softap_cfg_t *cfg)
Start Wi-Fi softAP, It will be started soft AP and DHCP server.
备注
This is asynchronous API. Please subscribe to the NM event, or call wm_nm_get_wifi_softap_state to query the softAP state
- 参数:
cfg – [in] reference wm_nm_wifi_softap_cfg_t
- 返回:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
wm_nm_state_e wm_nm_get_wifi_softap_state(void)
Query NM Wi-Fi softAP state.
- 返回:
reference wm_nm_state_e
-
int wm_nm_stop_wifi_softap(void)
Stop Wi-Fi softAP.
- 返回:
WM_ERR_SUCCESS: succeed
others: failed