Wi-Fi management functions

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 802.11 network.

Detailed Description

These functions manage the Wi-Fi connection such as encryption keys, MAC addresses, and connecting to access points.


Function Documentation

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.

Parameters:
hwaddr will hold the wifi device MAC address upon successful return.
Returns:
  • 0 on succes
int wlp_get_network ( struct wlp_network_t net  ) 

Get the 802.11 network.

Get the description of the currently associated network, if any.

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.

Parameters:
net will hold the network description upon successful return.
Returns:
  • 0 on success
  • WLP_FAILURE on failure.
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.

Returns:
  • 0 on success
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.

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.

NOTE: encryption in access point mode is not supported in this release.

Parameters:
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 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).
Returns:
  • 0 on success
  • WLP_ERR_PARAM if invalid parameters, e.g. invalid key length.
  • WLP_ERR_FAILURE on any other error.
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.

Parameters:
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.
Generated on Fri Jul 15 16:14:04 2011 for API Reference Manual by  doxygen 1.6.3