API Reference Manual
r5073
|
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 #ifndef WLP_PROTO_H 00048 #define WLP_PROTO_H 00049 00050 #include <stdint.h> 00051 00052 #if !defined(WLP_STACK_OFFLOAD) 00053 # define WLP_STACK_OFFLOAD 1 00054 #endif 00055 00056 /* Message types */ 00057 #define WLP_TYPE_MGMT_REQ 0 00058 #define WLP_TYPE_MGMT_CFM 1 00059 #define WLP_TYPE_DATA_REQ 2 00060 #define WLP_TYPE_DATA_CFM 3 00061 #define WLP_TYPE_DATA_IND 4 00062 00063 /* Message id's */ 00064 #define WLP_UART_CONFIG 0 00065 #define WLP_POLL 1 00066 #define WLP_FW_VERSION 2 00067 #define WLP_FW_UPGRADE 28 00068 #define WLP_SET_MODE 22 00069 #define WLP_SET_CHANNEL 23 00070 #define WLP_RESET 24 00071 #define WLP_GET_MODE 26 00072 #define WLP_SET_PS_CONF 29 00073 #define WLP_SET_PS_ENABLE 30 00074 #define WLP_SET_CONFIG 31 00075 #define WLP_SET_LED 32 00076 #define WLP_SET_HEARTBEAT 33 00077 #define WLP_SET_POLL_PERIOD 34 00078 #define WLP_GET_CONFIG 35 00079 #define WLP_DEV_STATUS 36 00080 00081 #define WLP_LINK_UP 3 00082 #define WLP_LINK_DOWN 4 00083 #define WLP_LINK_STATUS 5 00084 #define WLP_LINK_INFO 6 00085 00086 #define WLP_NET_STATUS 7 00087 #define WLP_NET_CONFIG 8 00088 #define WLP_NET_INFO 9 00089 #define WLP_NET_DNSLOOKUP 10 00090 #define WLP_NET_DHCPD 25 00091 00092 #define WLP_SOCK_OPEN 11 00093 #define WLP_SOCK_BIND 12 00094 #define WLP_SOCK_LISTEN 13 00095 #define WLP_SOCK_CONNECT 14 00096 00097 #define WLP_SOCK_CLOSE 15 00098 #define WLP_SOCK_RECV 16 00099 #define WLP_SOCK_SEND 17 00100 #define WLP_SOCK_SENDTO 18 00101 #define WLP_SOCK_STATUS 19 00102 #define WLP_SOCK_ACCEPT 20 00103 #define WLP_SOCK_INFO 21 00104 #define WLP_SOCK_DATA 27 00105 00107 enum wlp_auth_mode { 00108 WLP_AUTH_AUTO = 0, 00109 WLP_AUTH_WEP, 00110 WLP_AUTH_WPA_PSK, 00111 WLP_AUTH_WPA2_PSK, 00112 WLP_AUTH_WPA, 00113 WLP_AUTH_WPA2, 00114 }; 00115 00116 #define WLP_SOCK_STREAM 0 00117 #define WLP_SOCK_DGRAM 1 00118 #define WLP_SOCK_RAW 2 00119 00120 enum wlp_fw_upgrade_method { 00121 WLP_UPGRADE_METHOD_HTTP_POST 00122 }; 00123 00124 #ifndef WL_API_H 00125 #define WL_MAX_PASS_LEN 64 00126 #define WL_SNR_UNKNOWN -128 00127 #define WL_RSSI_UNKNOWN -128 00128 #define WL_SSID_MAX_LENGTH 32 00129 #define WL_MAC_ADDR_LENGTH 6 00130 struct wl_ssid_t { 00131 char ssid[WL_SSID_MAX_LENGTH]; 00132 uint8_t len; 00133 }; 00134 00135 struct wl_mac_addr_t { 00136 uint8_t octet[WL_MAC_ADDR_LENGTH]; 00137 }; 00138 00139 #define WL_MODE_STA 0 00140 #define WL_MODE_AP 1 00141 #define WL_MODE_ADHOC 2 00142 #define WL_MODE_WPS 3 00143 00144 enum wl_conn_type_t { 00145 WL_CONN_TYPE_INFRA, 00146 WL_CONN_TYPE_ADHOC 00147 }; 00148 00149 #endif /* WL_API_H */ 00150 00151 /* Message alignment */ 00152 #define WLP_SIZE_ALIGNMENT 4 00153 #define WLP_SIZE_ALIGNMENT_MASK (WLP_SIZE_ALIGNMENT - 1) 00154 #define wlp_pad(len) \ 00155 (((len) & WLP_SIZE_ALIGNMENT_MASK) ? \ 00156 WLP_SIZE_ALIGNMENT - ((len) & WLP_SIZE_ALIGNMENT_MASK) : 0) 00157 00158 00159 #if !defined(__LWIP_IP_ADDR_H__) && !defined(__LWIPOPTS_H__) 00160 00161 /* 00162 * The struct ip_addr type is based on work from the lwIP network stack. 00163 * 00164 */ 00165 00166 /* 00167 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 00168 * All rights reserved. 00169 * 00170 * Redistribution and use in source and binary forms, with or without 00171 * modification, are permitted provided that the following conditions are met: 00172 * 00173 * 1. Redistributions of source code must retain the above copyright notice, 00174 * this list of conditions and the following disclaimer. 00175 * 2. Redistributions in binary form must reproduce the above copyright notice, 00176 * this list of conditions and the following disclaimer in the documentation 00177 * and/or other materials provided with the distribution. 00178 * 3. The name of the author may not be used to endorse or promote products 00179 * derived from this software without specific prior written permission. 00180 * 00181 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00182 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00183 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 00184 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00185 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00186 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 00187 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00188 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 00189 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 00190 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00191 */ 00192 00193 struct ip_addr { 00194 uint32_t addr; 00195 }; 00196 00197 extern const struct ip_addr ip_addr_any; 00198 00199 #define IP_ADDR_ANY ((struct ip_addr *) &ip_addr_any) 00200 #define IP4_ADDR(ipaddr, a,b,c,d) \ 00201 (ipaddr)->addr = htonl(((uint32_t)((a) & 0xff) << 24) | \ 00202 ((uint32_t)((b) & 0xff) << 16) | \ 00203 ((uint32_t)((c) & 0xff) << 8) | \ 00204 (uint32_t)((d) & 0xff)) 00205 #define ip_addr_set(dest, src) \ 00206 (dest)->addr = ((src) == NULL? 0: (src)->addr) 00207 #define ip_addr_netcmp(addr1, addr2, mask) \ 00208 (((addr1)->addr & (mask)->addr) == ((addr2)->addr & (mask)->addr)) 00209 #define ip_addr_cmp(addr1, addr2) \ 00210 ((addr1)->addr == (addr2)->addr) 00211 #define ip_addr_isany(addr1) \ 00212 ((addr1) == NULL || (addr1)->addr == 0) 00213 00214 #define ip4_addr1(ipaddr) ((uint16_t)(ntohl((ipaddr)->addr) >> 24) & 0xff) 00215 #define ip4_addr2(ipaddr) ((uint16_t)(ntohl((ipaddr)->addr) >> 16) & 0xff) 00216 #define ip4_addr3(ipaddr) ((uint16_t)(ntohl((ipaddr)->addr) >> 8) & 0xff) 00217 #define ip4_addr4(ipaddr) ((uint16_t)(ntohl((ipaddr)->addr)) & 0xff) 00218 00219 #endif /* __LWIP_IP_ADDR_H__ */ 00220 00221 #define WLP_VERSION(a,b,c) (((uint32_t)((a) & 0xff) << 16) | \ 00222 ((uint32_t)((b) & 0xff) << 8) | \ 00223 (uint32_t)((c) & 0xff)) 00224 #define WLP_MAJOR_VERSION(code) ((uint16_t)((code) >> 16) & 0xff) 00225 #define WLP_MINOR_VERSION(code) ((uint16_t)((code) >> 8) & 0xff) 00226 #define WLP_PATCH_VERSION(code) ((uint16_t)((code)) & 0xff) 00227 00228 00229 /* !\ingroup wlp_api */ 00230 #define WLP_CAP_HA_PIN (1 << 0) 00231 #define WLP_CAP_WAKEUP_PIN (1 << 1) 00233 struct wlp_uart_config_req { 00234 uint32_t baudrate; 00235 uint8_t rtscts; 00236 uint8_t pad[3]; 00237 }; /* sizeof: 8 */ 00238 00239 struct wlp_set_config_req { 00240 uint8_t flags; 00241 #define WLP_FLAG_WAKEUP_PIN_PRESENT 1 00242 uint8_t pad[3]; 00243 }; /* sizeof: 4 */ 00244 00245 #if WLP_STACK_OFFLOAD 00246 struct wlp_fw_upgrade_req { 00247 struct ip_addr addr; 00248 uint16_t port; 00249 uint8_t method; 00250 char pad[1]; 00251 #define WLP_PATH_MAX_LENGTH 127 00252 char path[WLP_PATH_MAX_LENGTH + 1]; 00253 }; /* sizeof: 136 */ 00254 #endif /* WLP_STACK_OFFLOAD */ 00255 00256 struct wlp_set_mode_req { 00257 uint8_t mode; 00258 uint8_t pad[3]; 00259 }; /* sizeof: 4 */ 00260 00261 struct wlp_set_channel_req { 00262 uint8_t channel; 00263 uint8_t pad[3]; 00264 }; /* sizeof: 4 */ 00265 00266 struct wlp_set_ps_conf_req { 00267 uint32_t ps_delay; 00268 uint32_t traffic_timeout; 00269 uint16_t listen_interval; 00270 uint8_t ps_poll; 00271 uint8_t rx_all_dtim; 00272 char pad[3]; 00273 }; /* sizeof: 24 */ 00274 00275 struct wlp_set_ps_enable_req { 00276 uint8_t enable; 00277 uint8_t pad[3]; 00278 }; /* sizeof: 4 */ 00279 00280 struct wlp_set_led_req { 00281 uint8_t enable; 00282 uint8_t pad[3]; 00283 }; /* sizeof: 4 */ 00284 00285 struct wlp_set_heartbeat_req { 00286 uint32_t period; 00287 }; /* sizeof: 4 */ 00288 00289 struct wlp_set_poll_period_req { 00290 uint32_t period; 00291 }; /* sizeof: 4 */ 00292 00293 struct wlp_link_up_req { 00294 struct wl_ssid_t ssid; 00295 char pad[3]; 00296 char key[WL_MAX_PASS_LEN]; 00297 uint8_t auth; 00298 char pad2[3]; 00299 }; /* sizeof: 104 */ 00300 00301 #if WLP_STACK_OFFLOAD 00302 struct wlp_net_config_req { 00303 struct ip_addr ip; 00304 struct ip_addr netmask; 00305 struct ip_addr gw; 00306 struct ip_addr dns_server; 00307 int8_t dhcp; 00308 char pad[3]; 00309 }; /* sizeof: 24 */ 00310 00311 struct wlp_net_dnslookup_req { 00312 #define WLP_HOSTNAME_MAX_LENGTH 127 00313 char host[WLP_HOSTNAME_MAX_LENGTH + 1]; 00314 }; /* sizeof: 128 */ 00315 00316 struct wlp_net_dhcpd_req { 00317 uint8_t enable; 00318 char pad[3]; 00319 }; /* sizeof: 4 */ 00320 00321 00322 struct wlp_sock_open_req { 00323 uint8_t stype; 00324 uint8_t protocol; 00325 char pad[2]; 00326 }; /* sizeof: 4 */ 00327 00328 struct wlp_sock_bind_req { 00329 struct ip_addr ip; 00330 int16_t sockid; 00331 uint16_t port; 00332 }; /* sizeof: 8 */ 00333 00334 struct wlp_sock_listen_req { 00335 int16_t sockid; 00336 int8_t backlog; 00337 char pad[1]; 00338 }; /* sizeof: 4 */ 00339 00340 struct wlp_sock_connect_req { 00341 struct ip_addr ip; 00342 int16_t sockid; 00343 uint16_t port; 00344 }; /* sizeof: 8 */ 00345 00346 struct wlp_sock_close_req { 00347 int16_t sockid; 00348 char pad[2]; 00349 }; /* sizeof: 4 */ 00350 00351 struct wlp_sock_recv_req { 00352 int16_t sockid; 00353 int16_t datalen; 00354 }; /* sizeof: 4 */ 00355 00356 struct wlp_sock_send_req { 00357 int16_t sockid; 00358 int16_t datalen; 00359 }; /* sizeof: 4 */ 00360 00361 struct wlp_sock_sendto_req { 00362 struct ip_addr addr; 00363 int16_t sockid; 00364 int16_t datalen; 00365 uint16_t port; 00366 char pad[2]; 00367 }; /* sizeof: 12 */ 00368 00369 struct wlp_sock_status_req { 00370 int16_t sockid; 00371 char pad[2]; 00372 }; /* sizeof: 4 */ 00373 00374 struct wlp_sock_accept_req { 00375 int16_t sockid; 00376 char pad[2]; 00377 }; /* sizeof: 4 */ 00378 00379 struct wlp_sock_info_req { 00380 int16_t sockid; 00381 char pad[2]; 00382 }; /* sizeof: 4 */ 00383 #endif /* WLP_STACK_OFFLOAD */ 00384 00385 struct wlp_uart_config_cfm { 00386 int8_t mode; /* operation mode */ 00387 char pad[3]; 00388 }; /* sizeof: 4 */ 00389 00390 struct wlp_get_config_cfm { 00391 uint8_t flags; 00392 uint8_t pad[3]; 00393 }; /* sizeof: 4 */ 00394 00395 struct wlp_dev_status_cfm { 00396 #define WLP_DEV_STATUS_FW_SUCCESS (1 << 0) 00397 #define WLP_DEV_STATUS_FW_FAIL (1 << 1) 00398 uint8_t flags; 00399 uint8_t pad[3]; 00400 }; /* sizeof: 4 */ 00401 00402 struct wlp_fw_version_cfm { 00403 uint8_t major; /* WLP_VERSION(a, b, c) */ 00404 uint8_t minor; /* WLP_VERSION(a, b, c) */ 00405 uint8_t patch; /* WLP_VERSION(a, b, c) */ 00406 char pad[1]; 00407 char build[16]; 00408 char hw_rev[16]; 00409 }; /* sizeof: 36 */ 00410 00411 struct wlp_get_mode_cfm { 00412 uint8_t mode; 00413 char pad[3]; 00414 }; /* sizeof: 4 */ 00415 00416 struct wlp_link_info_cfm { 00417 struct wl_mac_addr_t hwaddr; 00418 struct wl_mac_addr_t ap; 00419 struct wl_ssid_t ssid; 00420 char pad[3]; 00421 int16_t rssi; 00422 int16_t snr; 00423 }; /* sizeof: 52 */ 00424 00425 #if WLP_STACK_OFFLOAD 00426 struct wlp_net_info_cfm { 00427 struct ip_addr ip; 00428 struct ip_addr netmask; 00429 struct ip_addr gw; 00430 struct ip_addr dns_server; 00431 struct ip_addr dns_lookup; 00432 00433 #define WLP_DNS_OK 0 00434 #define WLP_DNS_ERROR -1 00435 #define WLP_DNS_AGAIN -2 00436 #define WLP_DNS_INVALID -3 00437 int8_t dns_result; 00438 int8_t dhcp; 00439 char pad[2]; 00440 }; /* sizeof: 24 */ 00441 00442 struct wlp_sock_status_cfm { 00443 #define WLP_SOCK_STATE_DISCONNECTED 0 /* default */ 00444 #define WLP_SOCK_STATE_CONNECTED 1 00445 #define WLP_SOCK_STATE_LISTEN 2 00446 #define WLP_SOCK_STATE_ACCEPT 3 00447 #define WLP_SOCK_STATE_ERROR 4 00448 int8_t state; 00449 char pad[3]; 00450 }; /* sizeof: 4 */ 00451 00452 struct wlp_sock_info_cfm { 00453 struct ip_addr peer; 00454 }; /* sizeof: 4 */ 00455 #endif /* WLP_STACK_OFFLOAD */ 00456 00457 struct wlp_hdr { 00458 uint16_t len; 00459 uint8_t type; 00460 uint8_t id; 00461 int16_t res; 00462 uint8_t pad; 00463 char reserved[1]; 00464 }; 00465 00466 struct wlp_req { 00467 union { 00468 struct wlp_uart_config_req uart_config; 00469 struct wlp_set_config_req config; 00470 #if WLP_STACK_OFFLOAD 00471 struct wlp_fw_upgrade_req fw_upgrade; 00472 #endif 00473 struct wlp_set_mode_req set_mode; 00474 struct wlp_set_channel_req set_channel; 00475 struct wlp_set_ps_conf_req ps_config; 00476 struct wlp_set_ps_enable_req ps_enable; 00477 struct wlp_set_led_req led_enable; 00478 struct wlp_set_heartbeat_req heartbeat; 00479 struct wlp_set_poll_period_req poll_period; 00480 00481 struct wlp_link_up_req link_up; 00482 #if WLP_STACK_OFFLOAD 00483 struct wlp_net_config_req net_config; 00484 struct wlp_net_dnslookup_req net_dnslookup; 00485 struct wlp_net_dhcpd_req net_dhcpd; 00486 00487 struct wlp_sock_open_req sock_open; 00488 struct wlp_sock_bind_req sock_bind; 00489 struct wlp_sock_listen_req sock_listen; 00490 struct wlp_sock_connect_req sock_connect; 00491 struct wlp_sock_close_req sock_close; 00492 struct wlp_sock_recv_req sock_recv; 00493 struct wlp_sock_send_req sock_send; 00494 struct wlp_sock_sendto_req sock_sendto; 00495 struct wlp_sock_status_req sock_status; 00496 struct wlp_sock_accept_req sock_accept; 00497 struct wlp_sock_info_req sock_info; 00498 #endif 00499 } u; /* C89 */ 00500 }; 00501 00502 struct wlp_cfm { 00503 union { 00504 struct wlp_uart_config_cfm uart_config; 00505 struct wlp_get_config_cfm fw_config; 00506 struct wlp_dev_status_cfm dev_status; 00507 struct wlp_fw_version_cfm fw_version; 00508 struct wlp_get_mode_cfm get_mode; 00509 00510 struct wlp_link_info_cfm link_info; 00511 00512 #if WLP_STACK_OFFLOAD 00513 struct wlp_net_info_cfm net_info; 00514 00515 struct wlp_sock_status_cfm sock_status; 00516 struct wlp_sock_info_cfm sock_info; 00517 #endif 00518 } u; /* C89 */ 00519 }; 00520 00521 struct wlp_msg { 00522 struct wlp_hdr hdr; 00523 union { 00524 struct wlp_req req; 00525 struct wlp_cfm cfm; 00526 char payload[1]; 00527 } u; /* C89 */ 00528 }; 00529 00530 /* API version */ 00531 #define WLP_VERSION_CODE WLP_VERSION(1,3,2) 00532 00533 #endif /* WLP_PROTO_H */