00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
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
00162 #define WLP_INVALID_SOCKET_ID 0
00163
00165 #define WLP_INTERFACE_UART 0
00166 #define WLP_INTERFACE_SPI 1
00167
00173 struct wlp_network_t {
00174 struct wl_ssid_t ssid;
00175 struct wl_mac_addr_t bssid;
00176 int16_t rssi;
00178 int16_t snr;
00181 enum wlp_auth_mode auth;
00182 uint8_t channel;
00183 enum wl_conn_type_t type;
00184 };
00185
00186
00187
00188 struct wlp_network_list {
00189 int cnt;
00190 struct wlp_network_t *net;
00191 };
00192
00250 int wlp_init(int interface,
00251 int (*readf)(void *ctx, void *data, int len),
00252 int (*writef)(void *ctx, const void *data, int len),
00253 void (*selectf)(void *ctx, int select),
00254 void *ctx);
00255
00274 void wlp_set_yield_cb(void (*yieldf)(void *ctx), void *ctx);
00275
00276
00290 void wlp_irq(void);
00291
00292
00360 int wlp_set_baudrate(uint32_t baudrate, uint8_t rtscts);
00361
00362
00372 int wlp_reset(void);
00373
00374 #if WLP_STACK_OFFLOAD
00375
00393 int wlp_fw_upgrade(uint8_t method,
00394 struct ip_addr *addr,
00395 uint16_t port,
00396 const char *path);
00397 #endif
00398
00433 int wlp_get_fw_version(uint32_t *code,
00434 char *build,
00435 int build_len,
00436 char *hw_rev,
00437 int hw_rev_len);
00438
00479 int wlp_get_fw_caps(uint8_t *cap_flags);
00480
00481
00482
00495 int wlp_scan(struct wl_ssid_t *ssid,
00496 void (*complete_cb)(void *ctx, int cnt), void *ctx);
00497
00498 int wlp_get_network_list(struct wlp_network_list **netlist);
00499
00530 void wlp_set_link_cb(void (*link_cb)(void *ctx, int link), void *ctx);
00531
00532
00595 int wlp_linkup(struct wl_ssid_t *ssid, const char *key, enum wlp_auth_mode auth);
00596
00597
00628 int wlp_linkdown(void);
00629
00630
00641 int wlp_get_hwaddr(struct wl_mac_addr_t *hwaddr);
00642
00643
00666 int wlp_get_network(struct wlp_network_t *net);
00667
00671 #if WLP_STACK_OFFLOAD
00672
00711 void wlp_set_ipaddr_cb(void (*addr_cb)(void *ctx, const struct ip_addr *addr),
00712 void *ctx);
00713
00714
00734 int wlp_set_ipaddr(const struct ip_addr *ip, const struct ip_addr *netmask,
00735 const struct ip_addr *gw, const struct ip_addr *dns);
00736
00737
00761 int wlp_get_ipaddr(struct ip_addr *ip, struct ip_addr *netmask,
00762 struct ip_addr *gw, struct ip_addr *dns);
00763
00764
00789 int wlp_set_dhcp(int enable);
00790
00791
00808 int wlp_get_dhcp(int *enabled);
00809
00810
00847 int wlp_set_dhcpd(int enable);
00848
00849
00915 int wlp_socket(int type, int proto);
00916
00917
00948 int wlp_set_conn_cb(int sockid,
00949 void (*conn_cb)(void *ctx, int sockid, int connected),
00950 void *ctx);
00951
00976 int wlp_set_recv_cb(int sockid,
00977 void (*recv_cb)(void *ctx, int sockid, int len),
00978 void *ctx);
00979
00980
01024 int wlp_bind(int sockid, const struct ip_addr *addr, uint16_t port);
01025
01026
01064 int wlp_listen(int sockid, int backlog,
01065 void (*listen_cb)(void *ctx, int sockid),
01066 void *ctx);
01067
01126 int wlp_connect(int sockid, const struct ip_addr *ip, uint16_t port);
01127
01160 int wlp_accept(int sockid);
01161
01162
01182 int wlp_close(int sockid);
01183
01184
01258 int wlp_recv(int sockid, char *buf, int16_t len);
01259
01260
01323 int wlp_send(int sockid, const char *buf, int16_t len);
01324
01325
01365 int wlp_sendto(int sockid, const char *buf, int16_t len,
01366 const struct ip_addr *ip, uint16_t port);
01367
01368
01388 int wlp_get_peeraddr(int sockid, struct ip_addr *peer);
01389
01414 int wlp_get_hostbyname(const char *host,
01415 void (*lookup_cb)(void *ctx, const struct ip_addr *ip),
01416 void *ctx);
01417
01418 #endif
01419
01440 void wlp_poll(void);
01441
01471 int wlp_set_mode(uint8_t mode);
01472
01473
01474
01490 int wlp_get_mode(uint8_t *mode);
01491
01492
01493
01507 int wlp_set_channel(uint8_t channel);
01508
01509
01731 int wlp_set_wakeup_cb(void (*wakeupf)(void *ctx, int enable),
01732 void *ctx);
01733
01748 int wlp_set_ps(int enable);
01749
01806 int wlp_conf_ps(uint8_t use_ps_poll,
01807 uint32_t ps_traffic_timeout,
01808 uint32_t ps_delay,
01809 uint8_t rx_all_dtim,
01810 uint16_t listen_interval);
01811
01812
01830 int wlp_set_led(int enable);
01831
01860 int wlp_set_heartbeat(uint32_t ms_period);
01861
01891 int wlp_set_poll_period(uint32_t ms_period);
01892
01895 #endif