API Reference Manual
r8267
|
Functions | |
int | wlp_scan (struct wlp_ssid *ssid, void(*scan_cb)(void *ctx, struct wlp_network *net), void *ctx) |
Start a scan on all channels. | |
void | wlp_set_link_cb (void(*link_cb)(void *ctx, int link), void *ctx) |
Set a wifi link status callback function. | |
int | wlp_linkup (struct wlp_ssid *ssid, const char *key, enum wlp_auth_mode auth) |
Connect the wifi link. | |
int | wlp_linkdown (void) |
Disconnect the wifi link. | |
int | wlp_set_wps (int enable) |
Enable or disable WPS (Wi-Fi Protected Setup). | |
int | wlp_get_hwaddr (struct wlp_mac_addr *hwaddr) |
Get the interface MAC address. | |
int | wlp_get_network (struct wlp_network *net) |
Get the 802.11 network. | |
int | wlp_get_link_context (void(*linkctx_cb)(void *ctx, void *linkctx, int len), void *ctx) |
int | wlp_set_link_context (void *linkctx) |
These functions manage the Wi-Fi connection such as encryption keys, MAC addresses, and connecting to access points.
int wlp_get_hwaddr | ( | struct wlp_mac_addr * | hwaddr | ) |
Get the interface MAC address.
Return the 802.3 MAC address of the network interface.
hwaddr | will hold the wifi device MAC address upon successful return. |
int wlp_get_link_context | ( | void(*)(void *ctx, void *linkctx, int len) | linkctx_cb, |
void * | ctx | ||
) |
Retrieve information about the link, such as the PMK. This can be used to later speed up the linkup process by passing the same context to wlx_set_link_context().
int wlp_get_network | ( | struct wlp_network * | net | ) |
Get the 802.11 network.
Get the description of the currently associated network, if any.
If associated, the device will update the RSSI and SNR information each time this function is called by listening for beacon frames from the current AP.
In access point mode, this function will return the description of the device when the link is up, e.g. first client connected. See wlp_set_mode() for more information on how to set access point mode. In this mode, the RSSI and SNR values will be set to 0.
net | will hold the network description upon successful return. |
int wlp_linkdown | ( | void | ) |
Disconnect the wifi link.
Disable the wifi link. The wifi device will no longer try to maintain the network connection. Any link callback that was registered through wlp_set_link_cb() will be invoked when disconnection is completed, if currently connected to an access point.
Note again that successful return means that the wifi device will now _initate_ a link disconnection, not that the link is already disconnected.
If wlp_linkup() is called when already disconnected, any ongoing connection attempts will be stopped.
wlp_linkdown() will only manage the link layer, not the network or socket layer. See wlp_set_dhcp() and wlp_set_ipaddr() for information about configuring the network layer and wlp_socket() for information about the socket layer.
In access point mode, this function will stop the access point and it will no longer transmit beacons. All clients will be disconnected. See wlp_set_mode() for more information on how to set access point mode.
int wlp_linkup | ( | struct wlp_ssid * | ssid, |
const char * | key, | ||
enum wlp_auth_mode | auth | ||
) |
Connect the wifi link.
Enable the wifi link. Upon successful return, the wifi device will try to establish and maintain a connection to the network specified by the parameters. When the link status (connected, disconnected) changes, the caller will be notified of the new status through the callback registered in wlp_set_link_cb(). Information about the current network can be obtained through wlp_get_network().
Note again that successful return means that the wifi device will now _initate_ a link using the desired parameters, not that the link is already established.
If wlp_linkup() is called when already connected to an access point, the wifi device will try to switch to the network configuration according to the provided parameters.
wlp_linkup() will only manage the link layer, not the network or socket layer. See wlp_set_dhcp() and wlp_set_ipaddr() for information about configuring the network layer and wlp_socket() for information about the socket layer.
In access point mode, this function will start an access point with the given ssid and key parameters. See wlp_set_mode() for more information on how to set access point mode.
If the auth parameter is WLP_AUTH_AUTO WPA2 authentication with CCMP encryption will be used for security (in access point).
ssid | is the name of the access point to connect to or the name of the access point to start (in access point mode). |
key | is the encryption key to use. If this parameter is NULL, no enryption will be used. Should be provided as an ascii string. In case of a WPA key (parameter auth set to WLP_AUTH_AUTO, WLP_AUTH_WPA_PSK or WLP_AUTH_WPA2_PSK), the WPA passphrase should be provided, e.g. "mysecretkey". A WPA pass-phase must be between 8 and 63 characters long. In case of a WEP key (parameter auth set to WLP_AUTH_WEP), the key should be provided as a string containing the hexadecimal chars (10 or 26 chars, depending on whether a 40-bit or 104-bit key is used), e.g. "a1b2c3d4e5". |
auth | specifies the authentication mode to use. For WEP this parameter must be set to WLP_AUTH_WEP. For WPA/WPA2 the parameter can be set to WLP_AUTH_AUTO to select the mode from the network, or to WLP_AUTH_WPA_PSK or WLP_AUTH_WPA2_PSK to explicitly select WPA or WPA2/RSN. WLP_AUTH_AUTO also allows open authentication (no encryption) and for security reasons should not be used when the actual authentication mode of the network is known. |
int wlp_scan | ( | struct wlp_ssid * | ssid, |
void(*)(void *ctx, struct wlp_network *net) | scan_cb, | ||
void * | ctx | ||
) |
Start a scan on all channels.
The scan results will be passed scan_cb one at a time.
Note : Scanning may interfere with the connection management on some WiFi modules. If the module is already scanning because it is trying to connect to a network then wlp_scan() may return WLP_ERR_BUSY. To get manual scanning to work in that situation you may have to issue a wlp_linkdown() call first to stop the connection manager from scanning.
ssid | SSID to scan for. Can be NULL, in which case all SSIDs are included in the result. |
scan_cb | Callback that will be invoked once for every network found. The net parameter will be NULL when the scan is completed. |
ctx | is an opaque context pointer that will be passed back to scan_cb. |
void wlp_set_link_cb | ( | void(*)(void *ctx, int link) | link_cb, |
void * | ctx | ||
) |
Set a wifi link status callback function.
Register a callback that will be invoked when the wifi connection status changes.
Every time wlp_poll() is invoked, the callback condition will be evaluated and any registered callback will be invoked from same context as the call to wlp_poll().
Note that the link callback will be invoked when the wifi device is connected to the access point, an IP address does not have to be configured. See wlp_set_ipaddr_cb() for information on how to get notified when an IP address is configured.
Note that the connection status will also be indicated by any wlp_api that performs socket communication (e.g. wlp_send() and wlp_recv()) through their return values, event though wlp_set_link_cb() is not called.
In access point mode, the link callback will be invoked when the first client is connected to the access point. See wlp_set_mode() for more information on how to set access point mode.
link_cb | will be invoked upon a link status change. The callback parameter link will be set to 1 to indicate that the link has been established and 0 to indicate that the link has been shut down. |
ctx | is an opaque context pointer that will be passed back to link_cb. |
int wlp_set_link_context | ( | void * | linkctx | ) |
Set context for the link. The context is only valid for the next wlp_linkup() call.
int wlp_set_wps | ( | int | enable | ) |
Enable or disable WPS (Wi-Fi Protected Setup).
When enabled, pin or push button methods can be used to connect to an access-point. To use the pin method, the pin should be passed to wlp_linkup() after enabling WPS. To use the push-button method, wlp_linkup() should be called without a key after enabling WPS.
enable | determines if WPS should be enabled or disabled. |