00001 #ifndef PICO_H
00002 #define PICO_H
00003
00004 #include <stdint.h>
00005
00006 #define WLP_UART_CONFIG 0
00007 #define WLP_POLL 1
00008 #define WLP_FW_VERSION 2
00009
00010 #define WLP_LINK_UP 3
00011 #define WLP_LINK_DOWN 4
00012 #define WLP_LINK_STATUS 5
00013 #define WLP_LINK_INFO 6
00014
00015 #define WLP_NET_STATUS 7
00016 #define WLP_NET_CONFIG 8
00017 #define WLP_NET_INFO 9
00018 #define WLP_NET_DNSLOOKUP 10
00019
00020 #define WLP_SOCK_OPEN 11
00021 #define WLP_SOCK_BIND 12
00022 #define WLP_SOCK_LISTEN 13
00023 #define WLP_SOCK_CONNECT 14
00024
00025 #define WLP_SOCK_CLOSE 15
00026 #define WLP_SOCK_RECV 16
00027 #define WLP_SOCK_SEND 17
00028 #define WLP_SOCK_SENDTO 18
00029 #define WLP_SOCK_STATUS 19
00030 #define WLP_SOCK_ACCEPT 20
00031 #define WLP_SOCK_INFO 21
00032
00033 #ifndef WL_API_H
00034
00035 #define WL_MAX_PASS_LEN 64
00036 #define WL_SSID_MAX_LENGTH 32
00037 #define WL_MAC_ADDR_LENGTH 6
00038
00039 struct wl_ssid_t {
00040 char ssid[WL_SSID_MAX_LENGTH];
00041 uint8_t len;
00042 };
00043
00044 struct wl_mac_addr_t {
00045 uint8_t octet[WL_MAC_ADDR_LENGTH];
00046 };
00047
00048 #endif
00049
00050 #ifndef __LWIP_IP_ADDR_H__
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 struct ip_addr {
00085 uint32_t addr;
00086 };
00087
00088 extern const struct ip_addr ip_addr_any;
00089
00090 #define IP_ADDR_ANY ((struct ip_addr *) &ip_addr_any)
00091 #define IP4_ADDR(ipaddr, a,b,c,d) \
00092 (ipaddr)->addr = htonl(((uint32_t)((a) & 0xff) << 24) | \
00093 ((uint32_t)((b) & 0xff) << 16) | \
00094 ((uint32_t)((c) & 0xff) << 8) | \
00095 (uint32_t)((d) & 0xff))
00096 #define ip_addr_set(dest, src) \
00097 (dest)->addr = ((src) == NULL? 0: (src)->addr)
00098 #define ip_addr_netcmp(addr1, addr2, mask) \
00099 (((addr1)->addr & (mask)->addr) == ((addr2)->addr & (mask)->addr))
00100 #define ip_addr_cmp(addr1, addr2) \
00101 ((addr1)->addr == (addr2)->addr)
00102 #define ip_addr_isany(addr1) \
00103 ((addr1) == NULL || (addr1)->addr == 0)
00104
00105 #define ip4_addr1(ipaddr) ((uint16_t)(ntohl((ipaddr)->addr) >> 24) & 0xff)
00106 #define ip4_addr2(ipaddr) ((uint16_t)(ntohl((ipaddr)->addr) >> 16) & 0xff)
00107 #define ip4_addr3(ipaddr) ((uint16_t)(ntohl((ipaddr)->addr) >> 8) & 0xff)
00108 #define ip4_addr4(ipaddr) ((uint16_t)(ntohl((ipaddr)->addr)) & 0xff)
00109
00110 #endif
00111
00112 #define WLP_VERSION(a,b,c) ((((uint32_t) a) << 16) + \
00113 (((uint32_t) b) << 8) + \
00114 ((uint32_t) c))
00115 #define WLP_MAJOR_VERSION(code) ((code >> 16) & 0xffff)
00116 #define WLP_MINOR_VERSION(code) ((code >> 8) & 0xff)
00117 #define WLP_PATCH_VERSION(code) ((code) & 0xff)
00118
00119 struct wlp_uart_config_req {
00120 uint8_t id;
00121 char pad[2];
00122 uint8_t rtscts;
00123 uint32_t baudrate;
00124 };
00125
00126 struct wlp_poll_req {
00127 uint8_t id;
00128 };
00129
00130 struct wlp_fw_version_req {
00131 uint8_t id;
00132 };
00133
00134 struct wlp_link_up_req {
00135 uint8_t id;
00136 char pad[3];
00137 struct wl_ssid_t ssid;
00138 char key[WL_MAX_PASS_LEN];
00139 uint8_t wep;
00140 };
00141
00142 struct wlp_link_down_req {
00143 uint8_t id;
00144 };
00145
00146 struct wlp_link_status_req {
00147 uint8_t id;
00148 };
00149
00150 struct wlp_link_info_req {
00151 uint8_t id;
00152 };
00153
00154 struct wlp_net_status_req {
00155 uint8_t id;
00156 };
00157
00158 struct wlp_net_config_req {
00159 uint8_t id;
00160 char pad[2];
00161 int8_t dhcp;
00162 struct ip_addr ip;
00163 struct ip_addr netmask;
00164 struct ip_addr gw;
00165 struct ip_addr dns_server;
00166 };
00167
00168 struct wlp_net_info_req {
00169 uint8_t id;
00170 };
00171
00172 struct wlp_net_dnslookup_req {
00173 uint8_t id;
00174 #define WLP_HOSTNAME_MAX_LENGTH 127
00175 char host[WLP_HOSTNAME_MAX_LENGTH + 1];
00176 };
00177
00178
00179 struct wlp_sock_open_req {
00180 uint8_t id;
00181 #define WLP_SOCK_STREAM 0
00182 #define WLP_SOCK_DGRAM 1
00183 #define WLP_SOCK_RAW 2
00184 uint8_t type;
00185 uint8_t protocol;
00186 };
00187
00188 struct wlp_sock_bind_req {
00189 uint8_t id;
00190 char pad[1];
00191 int16_t sockid;
00192 struct ip_addr ip;
00193 uint16_t port;
00194 };
00195
00196 struct wlp_sock_listen_req {
00197 uint8_t id;
00198 int8_t backlog;
00199 int16_t sockid;
00200 };
00201
00202 struct wlp_sock_connect_req {
00203 uint8_t id;
00204 char pad[1];
00205 int16_t sockid;
00206 struct ip_addr ip;
00207 uint16_t port;
00208 };
00209
00210 struct wlp_sock_close_req {
00211 uint8_t id;
00212 char pad[1];
00213 int16_t sockid;
00214 };
00215
00216 struct wlp_sock_recv_req {
00217 uint8_t id;
00218 char pad[1];
00219 int16_t sockid;
00220 int16_t len;
00221 };
00222
00223 struct wlp_sock_send_req {
00224 uint8_t id;
00225 char pad[1];
00226 int16_t sockid;
00227 int16_t len;
00228 };
00229
00230 struct wlp_sock_sendto_req {
00231 uint8_t id;
00232 char pad[1];
00233 int16_t sockid;
00234 int16_t len;
00235 uint16_t port;
00236 struct ip_addr addr;
00237 };
00238
00239 struct wlp_sock_status_req {
00240 uint8_t id;
00241 char pad[1];
00242 int16_t sockid;
00243 };
00244
00245 struct wlp_sock_accept_req {
00246 uint8_t id;
00247 char pad[1];
00248 int16_t sockid;
00249 };
00250
00251 struct wlp_sock_info_req {
00252 uint8_t id;
00253 char pad[1];
00254 int16_t sockid;
00255 };
00256
00257 struct wlp_req {
00258
00259 union {
00260 uint8_t id;
00261
00262 struct wlp_uart_config_req uart_config;
00263 struct wlp_poll_req poll;
00264 struct wlp_fw_version_req fw_version;
00265
00266 struct wlp_link_up_req link_up;
00267 struct wlp_link_down_req link_down;
00268 struct wlp_link_status_req link_status;
00269 struct wlp_link_info_req link_info;
00270
00271 struct wlp_net_status_req net_status;
00272 struct wlp_net_config_req net_config;
00273 struct wlp_net_info_req net_info;
00274 struct wlp_net_dnslookup_req net_dnslookup;
00275
00276 struct wlp_sock_open_req sock_open;
00277 struct wlp_sock_bind_req sock_bind;
00278 struct wlp_sock_listen_req sock_listen;
00279 struct wlp_sock_connect_req sock_connect;
00280 struct wlp_sock_close_req sock_close;
00281 struct wlp_sock_recv_req sock_recv;
00282 struct wlp_sock_send_req sock_send;
00283 struct wlp_sock_sendto_req sock_sendto;
00284 struct wlp_sock_status_req sock_status;
00285 struct wlp_sock_accept_req sock_accept;
00286 struct wlp_sock_info_req sock_info;
00287 };
00288 };
00289
00290 struct wlp_uart_config_cfm {
00291 int16_t res;
00292 };
00293
00294 struct wlp_poll_cfm {
00295 int16_t res;
00296 };
00297
00298 struct wlp_fw_version_cfm {
00299 int16_t res;
00300 char pad[2];
00301 uint32_t code;
00302 char build[16];
00303 };
00304
00305 struct wlp_link_up_cfm {
00306 int16_t res;
00307 };
00308
00309 struct wlp_link_down_cfm {
00310 int16_t res;
00311 };
00312
00313 struct wlp_link_status_cfm {
00314 int16_t res;
00315 };
00316
00317 struct wlp_link_info_cfm {
00318 int16_t res;
00319 char pad1[2];
00320 struct wl_mac_addr_t hwaddr;
00321 struct wl_mac_addr_t ap;
00322 struct wl_ssid_t ssid;
00323 char pad2[1];
00324 };
00325
00326 struct wlp_net_status_cfm {
00327 int16_t res;
00328 };
00329
00330 struct wlp_net_config_cfm {
00331 int16_t res;
00332 };
00333
00334 struct wlp_net_info_cfm {
00335 int16_t res;
00336 #define WLP_DNS_OK 0
00337 #define WLP_DNS_ERROR -1
00338 #define WLP_DNS_AGAIN -2
00339 #define WLP_DNS_INVALID -3
00340 int8_t dns_result;
00341 int8_t dhcp;
00342 struct ip_addr ip;
00343 struct ip_addr netmask;
00344 struct ip_addr gw;
00345 struct ip_addr dns_server;
00346 struct ip_addr dns_lookup;
00347 };
00348
00349 struct wlp_net_dnslookup_cfm {
00350 int16_t res;
00351 };
00352
00353 struct wlp_sock_open_cfm {
00354 int16_t res;
00355 };
00356
00357 struct wlp_sock_bind_cfm {
00358 int16_t res;
00359 };
00360
00361 struct wlp_sock_listen_cfm {
00362 int16_t res;
00363 };
00364
00365 struct wlp_sock_connect_cfm {
00366 int16_t res;
00367 };
00368
00369 struct wlp_sock_close_cfm {
00370 int16_t res;
00371 };
00372
00373 struct wlp_sock_recv_cfm {
00374 int16_t res;
00375 };
00376
00377 struct wlp_sock_send_cfm {
00378 int16_t res;
00379 };
00380
00381 struct wlp_sock_sendto_cfm {
00382 int16_t res;
00383 };
00384
00385 struct wlp_sock_status_cfm {
00386 int16_t res;
00387 char pad[1];
00388
00389 #define WLP_SOCK_STATE_DISCONNECTED 0
00390 #define WLP_SOCK_STATE_CONNECTED 1
00391 #define WLP_SOCK_STATE_LISTEN 2
00392 #define WLP_SOCK_STATE_ACCEPT 3
00393 #define WLP_SOCK_STATE_ERROR 4
00394 int8_t state;
00395 };
00396
00397 struct wlp_sock_accept_cfm {
00398 int16_t res;
00399 };
00400
00401 struct wlp_sock_info_cfm {
00402 int16_t res;
00403 char pad[2];
00404 struct ip_addr peer;
00405 };
00406
00407 struct wlp_cfm {
00408 union {
00409 int16_t res;
00410
00411 struct wlp_uart_config_cfm uart_config;
00412 struct wlp_poll_cfm poll;
00413 struct wlp_fw_version_cfm fw_version;
00414
00415 struct wlp_link_up_cfm link_up;
00416 struct wlp_link_down_cfm link_down;
00417 struct wlp_link_status_cfm link_status;
00418 struct wlp_link_info_cfm link_info;
00419
00420 struct wlp_net_status_cfm net_status;
00421 struct wlp_net_config_cfm net_config;
00422 struct wlp_net_info_cfm net_info;
00423 struct wlp_net_dnslookup_cfm net_dnslookup;
00424
00425 struct wlp_sock_open_cfm sock_open;
00426 struct wlp_sock_bind_cfm sock_bind;
00427 struct wlp_sock_listen_cfm sock_listen;
00428 struct wlp_sock_connect_cfm sock_connect;
00429 struct wlp_sock_close_cfm sock_close;
00430 struct wlp_sock_recv_cfm sock_recv;
00431 struct wlp_sock_send_cfm sock_send;
00432 struct wlp_sock_sendto_cfm sock_sendto;
00433 struct wlp_sock_status_cfm sock_status;
00434 struct wlp_sock_accept_cfm sock_accept;
00435 struct wlp_sock_info_cfm sock_info;
00436 };
00437
00438 };
00439
00440 #endif