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;
00177 int16_t rssi;
00179 int16_t snr;
00181 };
00182
00183
00184
00242 int wlp_init(int interface,
00243 int (*readf)(void *ctx, void *data, int len),
00244 int (*writef)(void *ctx, const void *data, int len),
00245 void (*selectf)(void *ctx, int select),
00246 void *ctx);
00247
00266 void wlp_set_yield_cb(void (*yieldf)(void *ctx), void *ctx);
00267
00268
00282 void wlp_irq(void);
00283
00284
00352 int wlp_set_baudrate(uint32_t baudrate, uint8_t rtscts);
00353
00354
00364 int wlp_reset(void);
00365
00384 int wlp_fw_upgrade(uint8_t method,
00385 struct ip_addr addr,
00386 uint16_t port,
00387 const char *path);
00388
00423 int wlp_get_fw_version(uint32_t *code,
00424 char *build,
00425 int build_len,
00426 char *hw_rev,
00427 int hw_rev_len);
00428
00469 int wlp_get_fw_caps(uint8_t *cap_flags);
00470
00471
00472
00515 void wlp_set_link_cb(void (*link_cb)(void *ctx, int link), void *ctx);
00516
00517
00580 int wlp_linkup(struct wl_ssid_t *ssid, const char *key, enum wlp_auth_mode auth);
00581
00582
00613 int wlp_linkdown(void);
00614
00615
00626 int wlp_get_hwaddr(struct wl_mac_addr_t *hwaddr);
00627
00628
00651 int wlp_get_network(struct wlp_network_t *net);
00652
00695 void wlp_set_ipaddr_cb(void (*addr_cb)(void *ctx, const struct ip_addr *addr),
00696 void *ctx);
00697
00698
00718 int wlp_set_ipaddr(const struct ip_addr *ip, const struct ip_addr *netmask,
00719 const struct ip_addr *gw, const struct ip_addr *dns);
00720
00721
00745 int wlp_get_ipaddr(struct ip_addr *ip, struct ip_addr *netmask,
00746 struct ip_addr *gw, struct ip_addr *dns);
00747
00748
00773 int wlp_set_dhcp(int enable);
00774
00775
00792 int wlp_get_dhcp(int *enabled);
00793
00794
00825 int wlp_set_dhcpd(int enable);
00826
00827
00894 int wlp_socket(int type, int proto);
00895
00896
00927 int wlp_set_conn_cb(int sockid,
00928 void (*conn_cb)(void *ctx, int sockid, int connected),
00929 void *ctx);
00930
00955 int wlp_set_recv_cb(int sockid,
00956 void (*recv_cb)(void *ctx, int sockid, int len),
00957 void *ctx);
00958
00959
01003 int wlp_bind(int sockid, const struct ip_addr *addr, uint16_t port);
01004
01005
01043 int wlp_listen(int sockid, int backlog,
01044 void (*listen_cb)(void *ctx, int sockid),
01045 void *ctx);
01046
01105 int wlp_connect(int sockid, const struct ip_addr *ip, uint16_t port);
01106
01139 int wlp_accept(int sockid);
01140
01141
01161 int wlp_close(int sockid);
01162
01163
01237 int wlp_recv(int sockid, char *buf, int16_t len);
01238
01239
01302 int wlp_send(int sockid, const char *buf, int16_t len);
01303
01304
01344 int wlp_sendto(int sockid, const char *buf, int16_t len,
01345 const struct ip_addr *ip, uint16_t port);
01346
01347
01367 int wlp_get_peeraddr(int sockid, struct ip_addr *peer);
01368
01393 int wlp_get_hostbyname(const char *host,
01394 void (*lookup_cb)(void *ctx, const struct ip_addr *ip),
01395 void *ctx);
01396
01417 void wlp_poll(void);
01418
01448 int wlp_set_mode(uint8_t mode);
01449
01450
01451
01467 int wlp_get_mode(uint8_t *mode);
01468
01469
01470
01484 int wlp_set_channel(uint8_t channel);
01485
01486
01708 int wlp_set_wakeup_cb(void (*wakeupf)(void *ctx, int enable),
01709 void *ctx);
01710
01725 int wlp_set_ps(int enable);
01726
01783 int wlp_conf_ps(uint8_t use_ps_poll,
01784 uint32_t ps_traffic_timeout,
01785 uint32_t ps_delay,
01786 uint8_t rx_all_dtim,
01787 uint16_t listen_interval);
01788
01789
01807 int wlp_set_led(int enable);
01808
01837 int wlp_set_heartbeat(uint32_t ms_period);
01838
01868 int wlp_set_poll_period(uint32_t ms_period);
01869
01872 #endif