Wi-Fi Module WX library  v0.82
Collection of convenience functions for the Parallax WX Wi-Fi Module
wifi.h
Go to the documentation of this file.
1 
74 #ifndef WIFI_H
75 #define WIFI_H
76 
77 #if defined(__cplusplus)
78 extern "C"
79 {
80 #endif
81 
82 #include "simpletools.h"
83 #include "fdserial.h"
84 //#define WIFI_DEBUG
85 
86 
87 
95 #ifndef WX_ALL_COM
96 
103 #define WX_ALL_COM -1
104 #endif
105 
106 
107 #ifndef USB_PGM_TERM
108 
114 #define USB_PGM_TERM -2
115 #endif
116 
117 
118 #ifndef USB_PGM
119 
125 #define USB_PGM -3
126 #endif
127 
128 
129 
137 #ifndef ARG
138 
142 #define ARG 0xE6
143 #endif
144 
145 #ifndef CONNECT
146 
150 #define CONNECT 0xE4
151 #endif
152 
153 
154 #ifndef CLOSE
155 
159 #define CLOSE 0xE8
160 #endif
161 
162 
163 #ifndef CHECK
164 
168 #define CHECK 0xEE
169 #endif
170 
171 
172 #ifndef JOIN
173 
176 #define JOIN 0xEF
177 #endif
178 
179 
180 #ifndef LISTEN
181 
185 #define LISTEN 0xE7
186 #endif
187 
188 
189 #ifndef PATH
190 
194 #define PATH 0xEB
195 #endif
196 
197 
198 #ifndef POLL
199 
203 #define POLL 0xEC
204 #endif
205 
206 #ifndef RECV
207 
211 #define RECV 0xE9
212 #endif
213 
214 
215 #ifndef REPLY
216 
220 #define REPLY 0xE5
221 #endif
222 
223 
224 #ifndef SEND
225 
229 #define SEND 0xEA
230 #endif
231 
232 
233 #ifndef SET
234 
238 #define SET 0xED
239 #endif
240 
241 
242 
252 #ifndef AP
253 
259 #define AP 0xF3
260 #endif
261 
262 
263 #ifndef CMD
264 
273 #define CMD 0xFE
274 #endif
275 
276 
277 #ifndef GET
278 
283 #define GET 'G'
284 #endif
285 
286 
287 #ifndef HTTP
288 
292 #define HTTP 0xF7
293 #endif
294 
295 
296 #ifndef POST
297 
304 #define POST 'P'
305 #endif
306 
307 
308 #ifndef STA
309 
314 #define STA 0xF4
315 #endif
316 
317 
318 
319 #ifndef STA_AP
320 
327 #define STA_AP 0xF2
328 #endif
329 
330 
331 #ifndef TCP
332 
337 #define TCP 0xF5
338 #endif
339 
340 
341 #ifndef WS
342 
350 #define WS 0xF6
351 #endif
352 
353 
354 
364 #ifndef GPIO_DI
365 
369 #define GPIO_DI 1 // 1 // -> DI
370 #endif
371 
372 
373 #ifndef GPIO_DO
374 
378 #define GPIO_DO 3 // 2 // <- DO
379 #endif
380 
381 
382 #ifndef GPIO_RTS
383 
387 #define GPIO_RTS 15 // 3 // <- //rTS
388 #endif
389 
390 
391 #ifndef GPIO_CTS
392 
397 #define GPIO_CTS 13 // 4 // <-> /CTS
398 #endif
399 
400 
401 #ifndef GPIO_ASC
402 
406 #define GPIO_ASC 5 // 5 // <- ASC
407 #endif
408 
409 
410 #ifndef GPIO_DBG
411 
415 #define GPIO_DBG 2 // 6 // <- DBG
416 #endif
417 
418 
419 #ifndef GPIO_PGM
420 
424 #define GPIO_PGM 0 // 7 // -> PGM
425 #endif
426 
427 
428 
438 #ifndef INVALID_REQUEST
439 
442 #define INVALID_REQUEST 1
443 #endif
444 
445 
446 #ifndef INVALID_ARGUMENT
447 
450 #define INVALID_ARGUMENT 2
451 #endif
452 
453 
454 #ifndef WRONG_ARGUMENT_COUNT
455 
458 #define WRONG_ARGUMENT_COUNT 3
459 #endif
460 
461 
462 #ifndef NO_FREE_LISTENER
463 
466 #define NO_FREE_LISTENER 4
467 #endif
468 
469 
470 #ifndef NO_FREE_CONNECTION
471 
474 #define NO_FREE_CONNECTION 5
475 #endif
476 
477 
478 #ifndef LOOKUP_FAILED
479 
482 #define LOOKUP_FAILED 6
483 #endif
484 
485 
486 #ifndef CONNECTION_FAILED
487 
490 #define CONNECTION_FAILED 7
491 #endif
492 
493 
494 #ifndef SEND_FAILED
495 
498 #define SEND_FAILED 8
499 #endif
500 
501 
502 #ifndef INVALID_STATE
503 
507 #define INVALID_STATE 9
508 #endif
509 
510 
511 #ifndef INVALID_SIZE
512 
516 #define INVALID_SIZE 10
517 #endif
518 
519 
520 #ifndef DISCONNECTED
521 
524 #define DISCONNECTED 11
525 #endif
526 
527 
528 #ifndef NOT_IMPLEMENTED_ERROR_12
529 
532 #define NOT_IMPLEMENTED_ERROR_12 12
533 #endif
534 
535 
536 #ifndef BUSY
537 
540 #define BUSY 13
541 #endif
542 
543 
544 #ifndef INTERNAL_ERROR
545 
549 #define INTERNAL_ERROR 14
550 #endif
551 
552 
553 
563 #ifndef NO_ERROR
564 
567 #define NO_ERROR 0
568 #endif
569 
570 
571 #ifndef OUT_OF_MEMORY
572 
575 #define OUT_OF_MEMORY -1
576 #endif
577 
578 
579 #ifndef UNDEFINED_NEG2
580 
583 #define UNDEFINED_NEG2 -2
584 #endif
585 
586 
587 #ifndef TIMEOUT
588 
591 #define TIMEOUT -3
592 #endif
593 
594 
595 #ifndef ROUTING_PROBLEM
596 
599 #define ROUTING_PROBLEM -4
600 #endif
601 
602 
603 #ifndef OPERATION_IN_PROCESS
604 
607 #define OPERATION_IN_PROCESS -5
608 #endif
609 
610 
611 #ifndef UNDEFINED_NEG6
612 
615 #define UNDEFINED_NEG6 -6
616 #endif
617 
618 
619 #ifndef NUMBER_TOO_LARGE
620 
623 #define NUMBER_TOO_LARGE -7
624 #endif
625 
626 
627 #ifndef CONNECTION_ABORTED
628 
631 #define CONNECTION_ABORTED -8
632 #endif
633 
634 
635 #ifndef CONNECTION_RESET
636 
639 #define CONNECTION_RESET -9
640 #endif
641 
642 
643 #ifndef CONNECTION_CLOSED
644 
647 #define CONNECTION_CLOSED -10
648 #endif
649 
650 
651 #ifndef NOT_CONNECTED
652 
655 #define NOT_CONNECTED -11
656 #endif
657 
658 
659 #ifndef ILLEGAL_ARGUUMENT
660 
663 #define ILLEGAL_ARGUUMENT -12
664 #endif
665 
666 
667 #ifndef UNDEFINED_NEG13
668 
671 #define UNDEFINED_NEG13 -13
672 #endif
673 
674 
675 #ifndef UDP_SEND_ERROR
676 
679 #define UDP_SEND_ERROR -14
680 #endif
681 
682 
683 #ifndef ALREADY_CONNECTED
684 
688 #define ALREADY_CONNECTED -15
689 #endif
690 
691 
692 #ifndef SSL_HANDSHAKE_FAILED
693 
696 #define SSL_HANDSHAKE_FAILED -28
697 #endif
698 
699 
700 #ifndef SSL_APPLICATION_INVALID
701 
704 #define SSL_APPLICATION_INVALID -61
705 #endif
706 
707 
708 
722 char *wifi_bufferSize(int bytes);
723 
724 
741 char *wifi_command(char * command);
742 
743 
754 int wifi_connect(char *address, int port);
755 
756 
767 int wifi_disconnect(int idOrHandle);
768 
769 
780 int wifi_ip(int mode, int *ipAddr);
781 
782 
792 int wifi_join(char *network, char *password);
793 
794 
804 int wifi_leave(int newMode);
805 
806 
819 int wifi_listen(char protocol, char *path);
820 
821 
830 int wifi_mode(int mode);
831 
832 
851 void wifi_poll(int *event, int *id, int *handle);
852 
853 
887 int wifi_print(int protocol, int handle, const char *fmt, ...);
888 
889 
901 int wifi_recv(int handle, char *data, int size);
902 
903 
912 int wifi_replyStringCopy(char *targetStr);
913 
914 
948 int wifi_scan(int protocol, int handle, const char *fmt, ...);
949 
950 
963 char wifi_send(int handle, char *data, int size);
964 
965 
975 void wifi_setBuffer(char *buffer, int size);
976 
977 
1021 fdserial *wifi_start(int fromDO, int toDI, int baud, int comSelect);
1022 
1023 
1028 void wifi_stop(void);
1029 
1030 
1031 #if defined(__cplusplus)
1032 }
1033 #endif
1034 /* __cplusplus */
1035 #endif
1036 /* WIFI_H */
1037 
int wifi_print(int protocol, int handle, const char *fmt,...)
The Wi-Fi module version of the simpletext library&#39;s print function. It simplifies formatting data i...
int wifi_mode(int mode)
Set or check the Wi-Fi module&#39;s network mode.
void wifi_setBuffer(char *buffer, int size)
Sets the Wi-Fi buffer to an user declared external character array.
int wifi_disconnect(int idOrHandle)
Terminate an established connection or listener via its handle or id (respectively), freeing it to rejoin the available connection or listener pools.
fdserial * wifi_start(int fromDO, int toDI, int baud, int comSelect)
Set up Wi-Fi module serial connections for data command and transparent data communication.
int wifi_leave(int newMode)
Leave an AP network and transition into a mode that&#39;s not pure STA. The wi-fi module will forget the ...
int wifi_connect(char *address, int port)
Attempt a TCP connection to address on port.
char * wifi_bufferSize(int bytes)
Sets the size (in bytes) of the Wi-Fi communication buffer.
int wifi_scan(int protocol, int handle, const char *fmt,...)
The Wi-Fi module version of the simpletext library&#39;s scan function. It simplifies extracting data co...
void wifi_stop(void)
Stops the process started by wifi_start and recovers any memory that was allocated for command/reply ...
char * wifi_command(char *command)
Send a string command to the Wi-Fi module using its serial protocol, and get the Wi-Fi module&#39;s respo...
int wifi_ip(int mode, int *ipAddr)
Check the IP address for the Parallax Wi-Fi module.
int wifi_recv(int handle, char *data, int size)
Retrieve incoming HTTP body or WebSocket/TCP data.
int wifi_replyStringCopy(char *targetStr)
Copy a reply from the libwifi response buffer to a character array.
char wifi_send(int handle, char *data, int size)
Transmit WebSocket/TCP data, or extended HTTP body (after REPLY command).
int wifi_listen(char protocol, char *path)
Activate a listener process to monitor HTTP or WebSocket protocol activity on port 80 with a specifie...
void wifi_poll(int *event, int *id, int *handle)
Check for activity like incoming HTTP GET/POST requests, HTTP/WebSocket/TCP connections/disconnection...
int wifi_join(char *network, char *password)
Attempt to join a network via the ssid access point using passphrase.