Skip to content

Commit 0a58486

Browse files
authored
Merge pull request #64 from zfi/demo
Initial commit on the WiFi library
2 parents e1393ae + a5069ca commit 0a58486

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+11193
-0
lines changed

Learn/Simple Libraries/Network/libwifi/Documentation wifi Library.html

Lines changed: 983 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Learn/Simple Libraries/Network/libwifi/Doxyfile.doxyfile

Lines changed: 1793 additions & 0 deletions
Large diffs are not rendered by default.
15.7 KB
Loading
40.8 KB
Loading
40.5 KB
Binary file not shown.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
@file command.c
3+
4+
@author Andy Lindsay
5+
6+
@version 0.80 for firmware 1.0
7+
8+
@copyright
9+
Copyright (C) Parallax, Inc. 2017. All Rights MIT Licensed.
10+
11+
@brief API for the Parallax WX Wi-Fi Module ESP8266-WROOM-02.
12+
*/
13+
14+
15+
#include "simpletools.h"
16+
#include "fdserial.h"
17+
#include "wifi.h"
18+
19+
20+
int wifi_replyStringIn(int maxByteCount);
21+
void wifi_replyStringDisplay(char *s);
22+
void wifi_simpletermSuspend(void);
23+
void wifi_simpletermResume(void);
24+
25+
26+
fdserial *wifi_fds;
27+
int wifi_pin_do;
28+
int wifi_pin_di;
29+
int wifi_baud;
30+
int wifi_comSelectPin;
31+
32+
int simpleterm_toRxDi;
33+
int simpleterm_fromTxDo;
34+
int wifi_msReplyTimeout;
35+
36+
char wifi_event;
37+
char wifi_status;
38+
int wifi_id;
39+
int wifi_handle;
40+
41+
int wifi_timeoutFlag;
42+
43+
char *wifi_buf;
44+
int wifi_buf_size;
45+
46+
47+
char *wifi_command(char * command)
48+
{
49+
wifi_simpletermSuspend();
50+
fdserial_txFlush(wifi_fds);
51+
//int size = strlen(command);
52+
writeChar(wifi_fds, CMD);
53+
writeStr(wifi_fds, command);
54+
wifi_replyStringIn(wifi_buf_size - 1);
55+
wifi_simpletermResume();
56+
return &wifi_buf[1];
57+
}
58+
59+
60+
/**
61+
* TERMS OF USE: MIT License
62+
*
63+
* Permission is hereby granted, free of charge, to any person obtaining a
64+
* copy of this software and associated documentation files (the "Software"),
65+
* to deal in the Software without restriction, including without limitation
66+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
67+
* and/or sell copies of the Software, and to permit persons to whom the
68+
* Software is furnished to do so, subject to the following conditions:
69+
*
70+
* The above copyright notice and this permission notice shall be included in
71+
* all copies or substantial portions of the Software.
72+
*
73+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
74+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
75+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
76+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
77+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
78+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
79+
* DEALINGS IN THE SOFTWARE.
80+
*/
81+
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
@file connect.c
3+
4+
@author Andy Lindsay
5+
6+
@version 0.80 for firmware 1.0
7+
8+
@copyright
9+
Copyright (C) Parallax, Inc. 2017. All Rights MIT Licensed.
10+
11+
@brief API for the Parallax WX Wi-Fi Module ESP8266-WROOM-02.
12+
*/
13+
14+
15+
#include "simpletools.h"
16+
#include "fdserial.h"
17+
#include "wifi.h"
18+
19+
20+
int wifi_replyStringIn(int maxByteCount);
21+
void wifi_replyStringDisplay(char *s);
22+
void wifi_simpletermSuspend(void);
23+
void wifi_simpletermResume(void);
24+
25+
26+
fdserial *wifi_fds;
27+
int wifi_pin_do;
28+
int wifi_pin_di;
29+
int wifi_baud;
30+
int wifi_comSelectPin;
31+
32+
int simpleterm_toRxDi;
33+
int simpleterm_fromTxDo;
34+
int wifi_msReplyTimeout;
35+
36+
char wifi_event;
37+
char wifi_status;
38+
int wifi_id;
39+
int wifi_handle;
40+
41+
int wifi_timeoutFlag;
42+
43+
char *wifi_buf;
44+
int wifi_buf_size;
45+
46+
47+
int wifi_connect(char *address, int port)
48+
{
49+
#ifdef WIFI_DEBUG
50+
print("tcpConnect\r");
51+
#endif //WIFI_DEBUG
52+
53+
wifi_simpletermSuspend();
54+
55+
dprint(wifi_fds, "%c%c%s,%d\r", CMD, CONNECT, address, port);
56+
wifi_replyStringIn(wifi_buf_size - 1);
57+
#ifdef WIFI_DEBUG
58+
wifi_replyStringDisplay("TCPC: ");
59+
#endif //WIFI_DEBUG
60+
sscan(&wifi_buf[2], "%c%d%d", &wifi_event, &wifi_handle, &wifi_id);
61+
int tcpHandle = wifi_handle;
62+
63+
wifi_simpletermResume();
64+
65+
return tcpHandle;
66+
}
67+
68+
69+
/**
70+
* TERMS OF USE: MIT License
71+
*
72+
* Permission is hereby granted, free of charge, to any person obtaining a
73+
* copy of this software and associated documentation files (the "Software"),
74+
* to deal in the Software without restriction, including without limitation
75+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
76+
* and/or sell copies of the Software, and to permit persons to whom the
77+
* Software is furnished to do so, subject to the following conditions:
78+
*
79+
* The above copyright notice and this permission notice shall be included in
80+
* all copies or substantial portions of the Software.
81+
*
82+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
83+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
84+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
85+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
86+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
87+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
88+
* DEALINGS IN THE SOFTWARE.
89+
*/
90+
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
@file close.c
3+
4+
@author Andy Lindsay
5+
6+
@version 0.80 for firmware 1.0
7+
8+
@copyright
9+
Copyright (C) Parallax, Inc. 2017. All Rights MIT Licensed.
10+
11+
@brief API for the Parallax WX Wi-Fi Module ESP8266-WROOM-02.
12+
*/
13+
14+
15+
#include "simpletools.h"
16+
#include "fdserial.h"
17+
#include "wifi.h"
18+
19+
20+
int wifi_replyStringIn(int maxByteCount);
21+
void wifi_replyStringDisplay(char *s);
22+
void wifi_simpletermSuspend(void);
23+
void wifi_simpletermResume(void);
24+
25+
26+
fdserial *wifi_fds;
27+
int wifi_pin_do;
28+
int wifi_pin_di;
29+
int wifi_baud;
30+
int wifi_comSelectPin;
31+
32+
int simpleterm_toRxDi;
33+
int simpleterm_fromTxDo;
34+
int wifi_msReplyTimeout;
35+
36+
char wifi_event;
37+
char wifi_status;
38+
int wifi_id;
39+
int wifi_handle;
40+
41+
int wifi_timeoutFlag;
42+
43+
char *wifi_buf;
44+
int wifi_buf_size;
45+
46+
47+
int wifi_disconnect(int idOrHandle)
48+
{
49+
wifi_simpletermSuspend();
50+
51+
dprint(wifi_fds, "%c%c%d\r", CMD, CLOSE, idOrHandle);
52+
wifi_replyStringIn(wifi_buf_size - 1);
53+
sscan(&wifi_buf[2], "%c%d", &wifi_event, &wifi_handle);
54+
55+
wifi_simpletermResume();
56+
57+
return wifi_handle;
58+
}
59+
60+
61+
/**
62+
* TERMS OF USE: MIT License
63+
*
64+
* Permission is hereby granted, free of charge, to any person obtaining a
65+
* copy of this software and associated documentation files (the "Software"),
66+
* to deal in the Software without restriction, including without limitation
67+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
68+
* and/or sell copies of the Software, and to permit persons to whom the
69+
* Software is furnished to do so, subject to the following conditions:
70+
*
71+
* The above copyright notice and this permission notice shall be included in
72+
* all copies or substantial portions of the Software.
73+
*
74+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
75+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
76+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
77+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
78+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
79+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
80+
* DEALINGS IN THE SOFTWARE.
81+
*/
82+
40.8 KB
Loading
712 Bytes
Loading

0 commit comments

Comments
 (0)