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, int wep) |
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 associated 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 associated 802.11 network.
Get the description of the currently associated network, if any.
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.
int wlp_linkup | ( | struct wl_ssid_t * | ssid, | |
const char * | key, | |||
int | wep | |||
) |
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.
ssid | is the name of the access point to connect to. | |
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 wep set to 0), the WPA passphrase key should be provided, e.g. "mysecretkey". In case of a WEP key (parameter wep set to 1), 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". | |
wep | should be set to 1 if WEP encryption should be used (default is wpa). |
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.
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. |