Functions | |
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 wl_ssid_t *ssid, const char *key, enum wlp_auth_mode auth) |
Connect the wifi link. | |
int | wlp_linkdown (void) |
Disconnect the wifi link. | |
int | wlp_get_hwaddr (struct wl_mac_addr_t *hwaddr) |
Get the interface MAC address. | |
int | wlp_get_network (struct wlp_network_t *net) |
Get the 802.11 network. |
These functions manage the Wi-Fi connection such as encryption keys, MAC addresses, and connecting to access points.
int wlp_get_hwaddr | ( | struct wl_mac_addr_t * | 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_network | ( | struct wlp_network_t * | 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.
NOTE: wlp_linkdown() is not supported in this release. To stop the access point, wlp_reset() can be used as a workaround.
int wlp_linkup | ( | struct wl_ssid_t * | 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. |
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. |