API Reference Manual  r8305
wlp_api.h File Reference

oWL Pico API More...

#include <owl_cc.h>
#include <owl_beginpack.h>
#include <owl_endpack.h>
#include <wlp_trampoline.h>

Go to the source code of this file.

Data Structures

struct  wlp_ssid
 SSID representation. More...
struct  wlp_mac_addr
struct  ip_addr
struct  wlp_network

Defines

#define WLP_STACK_OFFLOAD   1
#define WLP_STACK_LWIP   0
#define WLP_TRAMPOLINE   0
#define WLP_VERSION(a, b, c)
#define WLP_MAJOR_VERSION(code)   ((uint16_t)((code) >> 16) & 0xff)
#define WLP_MINOR_VERSION(code)   ((uint16_t)((code) >> 8) & 0xff)
#define WLP_PATCH_VERSION(code)   ((uint16_t)((code)) & 0xff)
#define WLP_VERSION_CODE   WLP_VERSION(2,0,0)
#define WLP_FAILURE   -1
#define WLP_ERR_PARAM   -2
#define WLP_ERR_MEM   -3
#define WLP_ERR_CONN   -4
#define WLP_ERR_STATE   -5
#define WLP_ERR_PARSE   -6
#define WLP_ERR_PATH   -7
#define WLP_ERR_TYPE   -8
#define WLP_ERR_PERM   -9
#define WLP_ERR_NOTSUPP   -10
#define WLP_ERR_RANGE   -11
#define WLP_ERR_SIZE   -12
#define WLP_ERR_AGAIN   -13
#define WLP_ERR_BUSY   -14
#define WLP_ERR_DISABLED   -15
#define WLP_ERR_PROTO   -16
#define WLP_ERR_TIMEOUT   -17
#define WLP_ERR_IGNORED   -18
#define WLP_ERR_CANCEL   -19
#define WLP_ERR_SYNC   -20
#define WLP_ERR_ABORT   -21
#define WLP_ERR_INUSE   -22
#define WLP_ERR_USAGE   -23
#define WLP_ERR_CHECKSUM   -24
#define WLP_INVALID_SOCKET_ID   0
#define WLP_INTERFACE_UART   0
#define WLP_INTERFACE_SPI   1
#define WLP_CAP_HA_PIN   (1 << 0)
#define WLP_CAP_WAKEUP_PIN   (1 << 1)
#define WLP_SOCK_STREAM   0
#define WLP_SOCK_DGRAM   1
#define WLP_SOCK_RAW   2
#define WLP_MAX_PASS_LEN   64
#define WLP_SNR_UNKNOWN   -128
#define WLP_RSSI_UNKNOWN   -128
#define WLP_SSID_MAX_LENGTH   32
#define WLP_MAC_ADDR_LENGTH   6
#define WLP_MODE_STA   0
#define WLP_MODE_AP   1
#define WLP_MODE_ADHOC   2
#define IP_ADDR_ANY   ((struct ip_addr *) &ip_addr_any)
#define IP4_ADDR(ipaddr, a, b, c, d)
#define ip_addr_set(dest, src)   (dest)->addr = ((src) == NULL? 0: (src)->addr)
#define ip_addr_netcmp(addr1, addr2, mask)   (((addr1)->addr & (mask)->addr) == ((addr2)->addr & (mask)->addr))
#define ip_addr_cmp(addr1, addr2)   ((addr1)->addr == (addr2)->addr)
#define ip_addr_isany(addr1)   ((addr1) == NULL || (addr1)->addr == 0)
#define ip4_addr1(ipaddr)   ((uint16_t)(ntohl((ipaddr)->addr) >> 24) & 0xff)
#define ip4_addr2(ipaddr)   ((uint16_t)(ntohl((ipaddr)->addr) >> 16) & 0xff)
#define ip4_addr3(ipaddr)   ((uint16_t)(ntohl((ipaddr)->addr) >> 8) & 0xff)
#define ip4_addr4(ipaddr)   ((uint16_t)(ntohl((ipaddr)->addr)) & 0xff)

Enumerations

enum  wlp_auth_mode {
  WLP_AUTH_AUTO = 0, WLP_AUTH_WEP, WLP_AUTH_WPA_PSK, WLP_AUTH_WPA2_PSK,
  WLP_AUTH_WPA, WLP_AUTH_WPA2
}
enum  wlp_fw_upgrade_method { WLP_UPGRADE_METHOD_HTTP_POST }
enum  wlp_conn_type { WLP_CONN_TYPE_INFRA, WLP_CONN_TYPE_ADHOC }

Functions

int wlp_init (int interface, int(*readf)(void *ctx, void *data, int len), int(*writef)(void *ctx, const void *data, int len), void(*selectf)(void *ctx, int select), void *ctx)
 Initialize the wifi device.
void wlp_set_yield_cb (void(*yieldf)(void *ctx), void *ctx)
 Register a callback that will be invoked when wlp_api is idle.
void wlp_irq (void)
 Handler for interrupts from device.
int wlp_set_baudrate (uint32_t baudrate, uint8_t rtscts)
 Change the baudrate of the device.
int wlp_fw_upgrade (uint8_t method, struct ip_addr *addr, uint16_t port, const char *path)
 Prepare the device for a firmware upgrade operation.
int wlp_set_fw_upgrade_cb (void(*status_cb)(void *ctx, uint8_t success), void *ctx)
 Register a firmware upgrade notification callback.
int wlp_get_fw_version (uint32_t *code, char *build, int build_len, char *hw_rev, int hw_rev_len)
 Get the firmware version.
int wlp_get_fw_caps (uint8_t *cap_flags)
 Get WiFi device capabilities.
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)
void wlp_set_ipaddr_cb (void(*addr_cb)(void *ctx, const struct ip_addr *addr), void *ctx)
 Register a callback that will be invoked when an IP address is set.
int wlp_set_ipaddr (const struct ip_addr *ip, const struct ip_addr *netmask, const struct ip_addr *gw, const struct ip_addr *dns)
 Set a static IP address.
int wlp_get_ipaddr (struct ip_addr *ip, struct ip_addr *netmask, struct ip_addr *gw, struct ip_addr *dns)
 Get the current IP address parameters.
int wlp_set_dhcp (int enable)
 Request or release IP address through DHCP.
int wlp_get_dhcp (int *enabled)
 Get the current DHCP configuration.
int wlp_set_dhcpd (int enable)
 Start or stop the device DHCP server.
int wlp_socket (int type, int proto)
 Creates an endpoint for communication and returns a socket id.
int wlp_set_conn_cb (int sockid, void(*conn_cb)(void *ctx, int sockid, int connected), void *ctx)
 Register a connection status callback.
int wlp_set_recv_cb (int sockid, void(*recv_cb)(void *ctx, int sockid, int len), void *ctx)
 Register a data pending callback.
int wlp_set_sent_cb (int sockid, void(*sent_cb)(void *ctx, int sockid, int len), void *ctx)
int wlp_bind (int sockid, const struct ip_addr *addr, uint16_t port)
 Assign an address for a socket.
int wlp_listen (int sockid, int backlog, void(*listen_cb)(void *ctx, int sockid), void *ctx)
 Configure the socket to listen for incoming connections.
int wlp_connect (int sockid, const struct ip_addr *ip, uint16_t port)
 Initiate a connection on a socket.
int wlp_accept (int sockid)
 Accept a connection on a socket.
int wlp_close (int sockid)
 Close a socket.
int wlp_recv (int sockid, char *buf, int16_t len)
 Read data from a socket.
int wlp_send (int sockid, const char *buf, int16_t len)
 Send data to a socket.
int wlp_sendto (int sockid, const char *buf, int16_t len, const struct ip_addr *ip, uint16_t port)
 Send data to a specified address from a socket.
int wlp_get_peeraddr (int sockid, struct ip_addr *peer)
 Get name of connected peer socket.
int wlp_get_hostbyname (const char *host, void(*lookup_cb)(void *ctx, const struct ip_addr *ip), void *ctx)
 Get network address given a dns name.
int wlp_poll (void)
 Event progress function.
int wlp_set_mode (uint8_t mode)
 Set the Wi-Fi mode to AP or STA.
int wlp_get_mode (uint8_t *mode)
 Check if the device is currently in AP or STA mode.
int wlp_set_channel (uint8_t channel, void(*channel_cb)(void *ctx, int status), void *ctx)
 Set the channel. Only supported when mode is WLP_MODE_AP.
int wlp_conf_ap (int hidden, int beacon_intvl, int inact_tmo, const char *country)
 Configure parameters for access point mode.
int wlp_set_wakeup_cb (void(*wakeupf)(void *ctx, int enable), void *ctx)
 Register a callback that will be called to wakeup the wifi device.
int wlp_set_ps (int enable)
 Enable or disable WiFi power save.
int wlp_conf_ps (uint8_t use_ps_poll, uint32_t ps_traffic_timeout, uint32_t ps_delay, uint8_t rx_all_dtim, uint16_t listen_interval)
 Configure WiFi power save parameters.
int wlp_set_heartbeat (uint32_t ms_period)
 Configure the link heartbeat.
int wlp_set_led (int enable)
 Enable/disable LEDs on the device.
int wlp_set_poll_period (uint32_t ms_period)
 Configure the device IP-stack poll frequency.

Variables

struct wlp_ssid OWL_PACKED
struct ip_addr ip_addr_any

Detailed Description

oWL Pico API

Author:
H&D Wireless AB

Introduction

This is the documentation for the oWL Pico API.


Define Documentation

#define IP4_ADDR (   ipaddr,
  a,
  b,
  c,
 
)
Value:
(ipaddr)->addr = htonl(((uint32_t)((a) & 0xff) << 24) | \
                               ((uint32_t)((b) & 0xff) << 16) | \
                               ((uint32_t)((c) & 0xff) << 8) |  \
                               (uint32_t)((d) & 0xff))
#define WLP_CAP_HA_PIN   (1 << 0)

Host Attention pin supported

#define WLP_CAP_WAKEUP_PIN   (1 << 1)

Wakeup pin supported

#define WLP_ERR_ABORT   -21

Aborted

#define WLP_ERR_AGAIN   -13

Retry later

#define WLP_ERR_BUSY   -14

Busy

#define WLP_ERR_CANCEL   -19

Canceled by remote

#define WLP_ERR_CHECKSUM   -24

Checksum failure

#define WLP_ERR_CONN   -4

No connection

#define WLP_ERR_DISABLED   -15

Function is disabled

#define WLP_ERR_IGNORED   -18

Ignored, no effect

#define WLP_ERR_INUSE   -22

Already in use

#define WLP_ERR_MEM   -3

Out of memory

#define WLP_ERR_NOTSUPP   -10

Operation not supported

#define WLP_ERR_PARAM   -2

Parameter error

#define WLP_ERR_PARSE   -6

Input parsing error

#define WLP_ERR_PATH   -7

Path not found

#define WLP_ERR_PERM   -9

No permission

#define WLP_ERR_PROTO   -16

Protocol error

#define WLP_ERR_RANGE   -11

Out of range

#define WLP_ERR_SIZE   -12

Bad size

#define WLP_ERR_STATE   -5

Invalid state

#define WLP_ERR_SYNC   -20

Sync error

#define WLP_ERR_TIMEOUT   -17

Timeout

#define WLP_ERR_TYPE   -8

Incompatible type

#define WLP_ERR_USAGE   -23

General usage error

#define WLP_FAILURE   -1

General failure

#define WLP_VERSION (   a,
  b,
 
)
Value:
(((uint32_t)((a) & 0xff) << 16) |            \
                            ((uint32_t)((b) & 0xff) << 8) |             \
                            (uint32_t)((c) & 0xff))

Enumeration Type Documentation

Enumerator:
WLP_CONN_TYPE_INFRA 

For infrastructure mode (default)

WLP_CONN_TYPE_ADHOC 

For ad-hoc mode