3
3
*
4
4
* You must configure your particular hardware. Follow the steps below.
5
5
*
6
- * Currently StandardFirmataWiFi is configured as a server. An option to
7
- * configure as a client may be added in the future.
6
+ * Currently StandardFirmataWiFi is configured as a Wi-Fi server. An option to
7
+ * configure as a Wi-Fi client will be added in the future.
8
8
*============================================================================*/
9
9
10
10
// STEP 1 [REQUIRED]
11
11
// Uncomment / comment the appropriate set of includes for your hardware (OPTION A, B or C)
12
12
// Option A is enabled by default.
13
13
14
14
/*
15
- * OPTION A: Configure for Arduino WiFi shield
15
+ * OPTION A: Configure for Arduino MKR1000 or Arduino WiFi Shield 101
16
16
*
17
- * This will configure StandardFirmataWiFi to use the original WiFi library (deprecated) provided
18
- * with the Arduino IDE. It is supported by the Arduino WiFi shield (a discontinued product) and
19
- * is compatible with 802.11 B/G networks.
17
+ * This will configure StandardFirmataWiFi to use the WiFi101 library, which works with the
18
+ * Arduino WiFi101 shield and devices that have the WiFi101 chip built in (such as the MKR1000).
19
+ * It is compatible with 802.11 B/G/N networks.
20
+ *
21
+ * If you are using the MKR1000 board, continue on to STEP 2. If you are using the WiFi 101 shield,
22
+ * follow the instructions below.
20
23
*
21
- * To configure StandardFirmataWiFi to use the Arduino WiFi shield
22
- * leave the #define below uncommented.
24
+ * To enable for the WiFi 101 shield, uncomment the #define WIFI_101 below and verify the
25
+ * #define ARDUINO_WIFI_SHIELD is commented out for OPTION B.
26
+ *
27
+ * IMPORTANT: You must have the WiFI 101 library installed. To easily install this library, open
28
+ * the library manager via: Arduino IDE Menus: Sketch > Include Library > Manage Libraries > filter
29
+ * search for "WiFi101" > Select the result and click 'install'
23
30
*/
24
- #define ARDUINO_WIFI_SHIELD
31
+ // #define WIFI_101
25
32
26
- //do not modify these next 5 lines
27
- #ifdef ARDUINO_WIFI_SHIELD
28
- #include <WiFi.h>
33
+ //do not modify the following 10 lines
34
+ #if defined(ARDUINO_SAMD_MKR1000 ) && !defined(WIFI_101 )
35
+ // automatically include if compiling for MRK1000
36
+ #define WIFI_101
37
+ #endif
38
+ #ifdef WIFI_101
39
+ #include <WiFi101.h>
29
40
#include "utility/WiFiStream.h"
30
41
WiFiStream stream ;
42
+ #define WIFI_LIB_INCLUDED
31
43
#endif
32
44
33
45
/*
34
- * OPTION B: Configure for WiFi 101
35
- *
36
- * This will configure StandardFirmataWiFi to use the WiFi101 library, which works with the Arduino WiFi101
37
- * shield and devices that have the WiFi101 chip built in (such as the MKR1000). It is compatible
38
- * with 802.11 B/G/N networks.
46
+ * OPTION B: Configure for legacy Arduino WiFi shield
39
47
*
40
- * To enable, uncomment the #define WIFI_101 below and verify the #define values under
41
- * options A and C are commented out.
48
+ * This will configure StandardFirmataWiFi to use the original WiFi library (deprecated) provided
49
+ * with the Arduino IDE. It is supported by the Arduino WiFi shield (a discontinued product) and
50
+ * is compatible with 802.11 B/G networks.
42
51
*
43
- * IMPORTANT: You must have the WiFI 101 library installed. To easily install this library, opent the library manager via:
44
- * Arduino IDE Menus: Sketch > Include Library > Manage Libraries > filter search for "WiFi101" > Select the result and click 'install'
52
+ * To configure StandardFirmataWiFi to use the legacy Arduino WiFi shield
53
+ * leave the #define below uncommented and ensure #define WIFI_101 is commented out for OPTION A.
45
54
*/
46
- //#define WIFI_101
55
+ //#define ARDUINO_WIFI_SHIELD
47
56
48
- //do not modify these next 5 lines
49
- #ifdef WIFI_101
50
- #include <WiFi101 .h>
51
- #include "utility/WiFi101Stream .h"
57
+ //do not modify the following 10 lines
58
+ #ifdef ARDUINO_WIFI_SHIELD
59
+ #include <WiFi .h>
60
+ #include "utility/WiFiStream .h"
52
61
WiFiStream stream ;
62
+ #ifdef WIFI_LIB_INCLUDED
63
+ #define MULTIPLE_WIFI_LIB_INCLUDES
64
+ #else
65
+ #define WIFI_LIB_INCLUDED
66
+ #endif
53
67
#endif
54
68
55
69
/*
@@ -58,25 +72,33 @@ WiFiStream stream;
58
72
* This will configure StandardFirmataWiFi to use the ESP8266WiFi library for boards
59
73
* with an ESP8266 chip. It is compatible with 802.11 B/G/N networks.
60
74
*
61
- * To enable, uncomment the #define ESP8266_WIFI below and verify the #define values under
62
- * options A and B are commented out .
75
+ * The appropriate libraries are included automatically when compiling for the ESP8266 so
76
+ * continue on to STEP 2 .
63
77
*
64
- * IMPORTANT: You must have the esp8266 board support installed. To easily install this board, open the board manager via:
65
- * Arduino IDE Menus: Tools > Board > Manage Boards > filter search for "esp8266" > Select the result and click 'install'
78
+ * IMPORTANT: You must have the esp8266 board support installed. To easily install this board, open
79
+ * see the instructions here: https://github.com/esp8266/Arduino#installing-with-boards-manager.
66
80
*/
67
- //#define ESP8266_WIFI
68
-
69
- //do not modify these next 5 lines
81
+ //do not modify the following 14 lines
82
+ #ifdef ESP8266
83
+ // automatically include if compiling for ESP8266
84
+ #define ESP8266_WIFI
85
+ #endif
70
86
#ifdef ESP8266_WIFI
71
87
#include <ESP8266WiFi.h>
72
88
#include "utility/WiFiStream.h"
73
89
WiFiStream stream ;
90
+ #ifdef WIFI_LIB_INCLUDED
91
+ #define MULTIPLE_WIFI_LIB_INCLUDES
92
+ #else
93
+ #define WIFI_LIB_INCLUDED
94
+ #endif
74
95
#endif
75
96
76
97
/*
77
98
* OPTION D: Configure for HUZZAH
78
99
*
79
- * HUZZAH with CC3000 is not yet supported, this will be added in a later revision to StandardFirmataWiFi.
100
+ * HUZZAH with CC3000 is not yet supported, this will be added in a later revision to
101
+ * StandardFirmataWiFi.
80
102
* For HUZZAH with ESP8266 use ESP8266_WIFI.
81
103
*/
82
104
@@ -90,28 +112,32 @@ WiFiStream stream;
90
112
// replace this with your wireless network SSID
91
113
char ssid [] = "your_network_name" ;
92
114
115
+
93
116
// STEP 3 [OPTIONAL for all boards and shields]
94
- // if you want to use a static IP (v4) address, uncomment the line below. You can also change the IP.
95
- // if the first line is commented out, the WiFi shield will attempt to get an IP from the DHCP server
96
- #define STATIC_IP_ADDRESS 192,168,1,113
97
- #define SUBNET_MASK 255,255,255,0 // REQUIRED for ESP8266_WIFI, ignored for others
98
- #define GATEWAY_IP_ADDRESS 0,0,0,0 // REQUIRED for ESP8266_WIFI, ignored for others
117
+ // If you want to use a static IP (v4) address, uncomment the line below. You can also change the IP.
118
+ // If the first line is commented out, the WiFi shield will attempt to get an IP from the DHCP server.
119
+ // If you are using a static IP with the ESP8266 then you must also uncomment the SUBNET and GATEWAY.
120
+ //#define STATIC_IP_ADDRESS 192,168,1,113
121
+ //#define SUBNET_MASK 255,255,255,0 // REQUIRED for ESP8266_WIFI, optional for others
122
+ //#define GATEWAY_IP_ADDRESS 0,0,0,0 // REQUIRED for ESP8266_WIFI, optional for others
123
+
99
124
100
125
// STEP 4 [REQUIRED for all boards and shields]
101
126
// define your port number here, you will need this to open a TCP connection to your Arduino
102
127
#define SERVER_PORT 3030
103
128
104
- // STEP 5 [REQUIRED for all boards and shields]
105
- // determine your network security type (OPTION A, B, or C). Option A is the most common, and the default.
106
129
130
+ // STEP 5 [REQUIRED for all boards and shields]
131
+ // determine your network security type (OPTION A, B, or C). Option A is the most common, and the
132
+ // default.
107
133
108
134
/*
109
135
* OPTION A: WPA / WPA2
110
136
*
111
137
* WPA is the most common network security type. A passphrase is required to connect to this type.
112
138
*
113
- * To enable, leave #define WIFI_WPA_SECURITY uncommented below, set your wpa_passphrase value appropriately,
114
- * and do not uncomment the #define values under options B and C
139
+ * To enable, leave #define WIFI_WPA_SECURITY uncommented below, set your wpa_passphrase value
140
+ * appropriately, and do not uncomment the #define values under options B and C
115
141
*/
116
142
#define WIFI_WPA_SECURITY
117
143
@@ -123,11 +149,11 @@ char wpa_passphrase[] = "your_wpa_passphrase";
123
149
/*
124
150
* OPTION B: WEP
125
151
*
126
- * WEP is a less common (and regarded as less safe) security type. A WEP key and its associated index are required
127
- * to connect to this type.
152
+ * WEP is a less common (and regarded as less safe) security type. A WEP key and its associated
153
+ * index are required to connect to this type.
128
154
*
129
- * To enable, Uncomment the #define below, set your wep_index and wep_key values appropriately, and verify
130
- * the #define values under options A and C are commented out.
155
+ * To enable, Uncomment the #define below, set your wep_index and wep_key values appropriately,
156
+ * and verify the #define values under options A and C are commented out.
131
157
*/
132
158
//#define WIFI_WEP_SECURITY
133
159
@@ -142,7 +168,8 @@ char wep_key[] = "your_wep_key";
142
168
/*
143
169
* OPTION C: Open network (no security)
144
170
*
145
- * Open networks have no security, can be connected to by any device that knows the ssid, and are unsafe.
171
+ * Open networks have no security, can be connected to by any device that knows the ssid, and are
172
+ * unsafe.
146
173
*
147
174
* To enable, uncomment #define WIFI_NO_SECURITY below and verify the #define values
148
175
* under options A and B are commented out.
@@ -153,11 +180,11 @@ char wep_key[] = "your_wep_key";
153
180
* CONFIGURATION ERROR CHECK (don't change anything here)
154
181
*============================================================================*/
155
182
156
- #if ((defined( ARDUINO_WIFI_SHIELD ) && (defined( WIFI_101 ) || defined( HUZZAH_WIFI ))) || (defined( WIFI_101 ) && defined( HUZZAH_WIFI )) || (defined( WIFI_101 ) && defined( ESP8266_WIFI )) || (defined( ESP8266_WIFI ) && defined( HUZZAH_WIFI )) || (defined( ESP8266_WIFI ) && defined( ARDUINO_WIFI_SHIELD )))
183
+ #ifdef MULTIPLE_WIFI_LIB_INCLUDES
157
184
#error "you may not define more than one wifi device type in wifiConfig.h."
158
- #endif //WIFI device type check
185
+ #endif
159
186
160
- #if !(defined( ARDUINO_WIFI_SHIELD ) || defined( WIFI_101 ) || defined( HUZZAH_WIFI ) || defined( ESP8266_WIFI ))
187
+ #ifndef WIFI_LIB_INCLUDED
161
188
#error "you must define a wifi device type in wifiConfig.h."
162
189
#endif
163
190
@@ -171,15 +198,15 @@ char wep_key[] = "your_wep_key";
171
198
172
199
#if (defined(ESP8266_WIFI ) && !(defined(WIFI_NO_SECURITY ) || (defined(WIFI_WPA_SECURITY ))))
173
200
#error "you must choose between WIFI_NO_SECURITY and WIFI_WPA_SECURITY"
174
- #endif
201
+ #endif
175
202
176
203
/*==============================================================================
177
204
* PIN IGNORE MACROS (don't change anything here)
178
205
*============================================================================*/
179
206
180
207
// ignore SPI pins, pin 5 (reset WiFi101 shield), pin 7 (WiFi handshake) and pin 10 (WiFi SS)
181
208
// also don't ignore SS pin if it's not pin 10
182
- // TODO - need to differentiate between Arduino WiFi1 101 Shield and Arduino MKR1000
209
+ // Not needed for Arduino MKR1000.
183
210
#define IS_IGNORE_WIFI101_SHIELD (p ) ((p) == 10 || (IS_PIN_SPI(p) && (p) != SS) || (p) == 5 || (p) == 7)
184
211
185
212
// ignore SPI pins, pin 4 (SS for SD-Card on WiFi-shield), pin 7 (WiFi handshake) and pin 10 (WiFi SS)
0 commit comments