API Reference Manual  r5073
wlp_api.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2012, H&D Wireless AB All rights reserved.
00003  *
00004  * The license to use this software in whole and in part and to
00005  * redistribute it in any form follows with the WiFi HW module from H&D
00006  * Wireless and is granted under the following restrictions:
00007  * 
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  *
00011  * 2. Redistributions in binary form must reproduce the above copyright
00012  *    notice, this list of conditions and the following disclaimer in the
00013  *    documentation and/or other materials provided with the distribution.
00014  *
00015  * 3. The name of H&D Wireless AB may not be used to endorse or promote
00016  *    products derived from this software without specific prior written
00017  *    permission.
00018  *
00019  * 4. The software may only be used together with hardware from H&D
00020  *    Wireless all other use is prohibited.
00021  *
00022  * 5. The license to use and redistribute the software is granted
00023  *    together with the purchase of a hardware platform on a one to one
00024  *    basis.
00025  *
00026  * 6. The binary code may not be reversed engineered or by other means
00027  *    copied to circumvent this license.
00028  * 
00029  * THIS SOFTWARE IS PROVIDED BY H&D WIRELESS AB ``AS IS'' AND ANY
00030  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00031  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00032  * PURPOSE ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT
00033  * SHALL HD WIRELESS AB BE LIABLE FOR ANY DIRECT, INDIRECT,
00034  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00035  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00036  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00037  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
00038  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00039  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
00040  * OF THE POSSIBILITY OF SUCH DAMAGE.
00041  *
00042  * For more information regarding this software license Contact H&D
00043  * Wireless AB (support@hd-wireless.se).
00044  *
00045  */
00046 
00047 
00130 #ifndef WLP_API_H
00131 #define WLP_API_H
00132 
00133 #include <stdint.h>
00134 
00135 #include "wlp_proto.h"
00136 
00137 
00138 #define WLP_FAILURE      -1  
00139 #define WLP_ERR_PARAM    -2  
00140 #define WLP_ERR_MEM      -3  
00141 #define WLP_ERR_CONN     -4  
00142 #define WLP_ERR_STATE    -5  
00143 #define WLP_ERR_PARSE    -6  
00144 #define WLP_ERR_PATH     -7  
00145 #define WLP_ERR_TYPE     -8  
00146 #define WLP_ERR_PERM     -9  
00147 #define WLP_ERR_NOTSUPP  -10 
00148 #define WLP_ERR_RANGE    -11 
00149 #define WLP_ERR_SIZE     -12 
00150 #define WLP_ERR_AGAIN    -13 
00151 #define WLP_ERR_BUSY     -14 
00152 #define WLP_ERR_DISABLED -15 
00153 #define WLP_ERR_PROTO    -16 
00154 #define WLP_ERR_TIMEOUT  -17 
00155 #define WLP_ERR_IGNORED  -18 
00156 #define WLP_ERR_CANCEL   -19 
00157 #define WLP_ERR_SYNC     -20 
00158 #define WLP_ERR_ABORT    -21 
00159 #define WLP_ERR_INUSE    -22 
00160 #define WLP_ERR_USAGE    -23 
00161 #define WLP_ERR_CHECKSUM -24 
00164 #define WLP_INVALID_SOCKET_ID 0
00165 
00167 #define WLP_INTERFACE_UART 0
00168 #define WLP_INTERFACE_SPI  1
00169 
00175 struct wlp_network_t {
00176         struct wl_ssid_t ssid;          
00177         struct wl_mac_addr_t bssid;     
00178         int16_t rssi;                   
00180         int16_t snr;                    
00183         enum wlp_auth_mode auth;
00184         uint8_t channel;
00185         enum wl_conn_type_t type;
00186 };
00187 
00188 
00189 
00190 struct wlp_network_list {
00191         int cnt;
00192         struct wlp_network_t *net;
00193 };
00194 
00252 int wlp_init(int interface,
00253              int (*readf)(void *ctx, void *data, int len),
00254              int (*writef)(void *ctx, const void *data, int len),
00255              void (*selectf)(void *ctx, int select),
00256              void *ctx);
00257 
00276 void wlp_set_yield_cb(void (*yieldf)(void *ctx), void *ctx);
00277 
00278 
00292 void wlp_irq(void);
00293 
00294 
00362 int wlp_set_baudrate(uint32_t baudrate, uint8_t rtscts);
00363 
00364 
00374 int wlp_reset(void);
00375 
00376 #if WLP_STACK_OFFLOAD
00377 
00395 int wlp_fw_upgrade(uint8_t method, 
00396                    struct ip_addr *addr, 
00397                    uint16_t port,
00398                    const char *path);
00399 
00413 int wlp_set_fw_upgrade_cb(void (*status_cb)(void *ctx, uint8_t success),
00414                           void *ctx);
00415 
00416 
00417 #endif /* WLP_STACK_OFFLOAD */
00418 
00453 int wlp_get_fw_version(uint32_t *code, 
00454                        char *build, 
00455                        int build_len,
00456                        char *hw_rev, 
00457                        int hw_rev_len);
00458 
00499 int wlp_get_fw_caps(uint8_t *cap_flags);
00500 
00501 
00502 
00536 int wlp_scan(struct wl_ssid_t *ssid,
00537              void (*complete_cb)(void *ctx, int cnt), void *ctx);
00538 
00539 int wlp_get_network_list(struct wlp_network_list **netlist);
00540 
00571 void wlp_set_link_cb(void (*link_cb)(void *ctx, int link), void *ctx);
00572 
00573 
00636 int wlp_linkup(struct wl_ssid_t *ssid, const char *key, enum wlp_auth_mode auth);
00637 
00638 
00669 int wlp_linkdown(void);
00670 
00671 
00683 int wlp_get_hwaddr(struct wl_mac_addr_t *hwaddr);
00684 
00685 
00708 int wlp_get_network(struct wlp_network_t *net);
00709 
00710 
00711 
00715 #if WLP_STACK_OFFLOAD
00716 
00755 void wlp_set_ipaddr_cb(void (*addr_cb)(void *ctx, const struct ip_addr *addr),
00756                        void *ctx);
00757 
00758 
00778 int wlp_set_ipaddr(const struct ip_addr *ip, const struct ip_addr *netmask,
00779                    const struct ip_addr *gw, const struct ip_addr *dns);
00780 
00781 
00805 int wlp_get_ipaddr(struct ip_addr *ip, struct ip_addr *netmask,
00806                    struct ip_addr *gw, struct ip_addr *dns);
00807 
00808 
00833 int wlp_set_dhcp(int enable);
00834 
00835 
00852 int wlp_get_dhcp(int *enabled);
00853 
00854 
00891 int wlp_set_dhcpd(int enable);
00892 
00893     
00959 int wlp_socket(int type, int proto);
00960 
00961 
00992 int wlp_set_conn_cb(int sockid,
00993                     void (*conn_cb)(void *ctx, int sockid, int connected),
00994                     void *ctx);
00995 
01020 int wlp_set_recv_cb(int sockid,
01021                     void (*recv_cb)(void *ctx, int sockid, int len),
01022                     void *ctx);
01023 
01024 
01068 int wlp_bind(int sockid, const struct ip_addr *addr, uint16_t port);
01069 
01070 
01108 int wlp_listen(int sockid, int backlog,
01109                void (*listen_cb)(void *ctx, int sockid),
01110                void *ctx);
01111 
01170 int wlp_connect(int sockid, const struct ip_addr *ip, uint16_t port);
01171 
01204 int wlp_accept(int sockid);
01205 
01206 
01226 int wlp_close(int sockid);
01227 
01228 
01302 int wlp_recv(int sockid, char *buf, int16_t len);
01303 
01304 
01367 int wlp_send(int sockid, const char *buf, int16_t len);
01368 
01369 
01409 int wlp_sendto(int sockid, const char *buf, int16_t len,
01410                const struct ip_addr *ip, uint16_t port);
01411 
01412 
01432 int wlp_get_peeraddr(int sockid, struct ip_addr *peer);
01433 
01458 int wlp_get_hostbyname(const char *host,
01459                        void (*lookup_cb)(void *ctx, const struct ip_addr *ip),
01460                        void *ctx);
01461 
01462 #endif /* WLP_STACK_OFFLOAD */
01463 
01484 void wlp_poll(void);
01485 
01515 int wlp_set_mode(uint8_t mode);
01516 
01517 
01518 
01534 int wlp_get_mode(uint8_t *mode);
01535 
01536 
01537 
01551 int wlp_set_channel(uint8_t channel);
01552 
01553 
01577 int
01578 wlp_conf_ap(int hidden, int beacon_intvl, int inact_tmo, const char *country);
01579 
01801 int wlp_set_wakeup_cb(void (*wakeupf)(void *ctx, int enable),
01802                       void *ctx);
01803 
01818 int wlp_set_ps(int enable);
01819 
01876 int wlp_conf_ps(uint8_t use_ps_poll,
01877                 uint32_t ps_traffic_timeout,
01878                 uint32_t ps_delay,
01879                 uint8_t rx_all_dtim,
01880                 uint16_t listen_interval);
01881 
01882 
01900 int wlp_set_led(int enable);
01901 
01930 int wlp_set_heartbeat(uint32_t ms_period);
01931 
01961 int wlp_set_poll_period(uint32_t ms_period);
01962 
01965 #endif /* WLP_API_H */