33 *
44 * You must configure your particular hardware. Follow the steps below.
55 *
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.
88 *============================================================================*/
99
1010// STEP 1 [REQUIRED]
1111// Uncomment / comment the appropriate set of includes for your hardware (OPTION A, B or C)
1212// Option A is enabled by default.
1313
1414/*
15- * OPTION A: Configure for Arduino WiFi shield
15+ * OPTION A: Configure for Arduino MKR1000 or Arduino WiFi Shield 101
1616 *
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.
2023 *
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'
2330 */
24- #define ARDUINO_WIFI_SHIELD
31+ // #define WIFI_101
2532
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>
2940#include "utility/WiFiStream.h"
3041WiFiStream stream ;
42+ #define WIFI_LIB_INCLUDED
3143#endif
3244
3345/*
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
3947 *
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.
4251 *
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.
4554 */
46- //#define WIFI_101
55+ //#define ARDUINO_WIFI_SHIELD
4756
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"
5261WiFiStream stream ;
62+ #ifdef WIFI_LIB_INCLUDED
63+ #define MULTIPLE_WIFI_LIB_INCLUDES
64+ #else
65+ #define WIFI_LIB_INCLUDED
66+ #endif
5367#endif
5468
5569/*
@@ -58,25 +72,33 @@ WiFiStream stream;
5872 * This will configure StandardFirmataWiFi to use the ESP8266WiFi library for boards
5973 * with an ESP8266 chip. It is compatible with 802.11 B/G/N networks.
6074 *
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 .
6377 *
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.
6680 */
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
7086#ifdef ESP8266_WIFI
7187#include <ESP8266WiFi.h>
7288#include "utility/WiFiStream.h"
7389WiFiStream stream ;
90+ #ifdef WIFI_LIB_INCLUDED
91+ #define MULTIPLE_WIFI_LIB_INCLUDES
92+ #else
93+ #define WIFI_LIB_INCLUDED
94+ #endif
7495#endif
7596
7697/*
7798 * OPTION D: Configure for HUZZAH
7899 *
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.
80102 * For HUZZAH with ESP8266 use ESP8266_WIFI.
81103 */
82104
@@ -90,28 +112,32 @@ WiFiStream stream;
90112// replace this with your wireless network SSID
91113char ssid [] = "your_network_name" ;
92114
115+
93116// 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+
99124
100125// STEP 4 [REQUIRED for all boards and shields]
101126// define your port number here, you will need this to open a TCP connection to your Arduino
102127#define SERVER_PORT 3030
103128
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.
106129
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.
107133
108134/*
109135 * OPTION A: WPA / WPA2
110136 *
111137 * WPA is the most common network security type. A passphrase is required to connect to this type.
112138 *
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
115141 */
116142#define WIFI_WPA_SECURITY
117143
@@ -123,11 +149,11 @@ char wpa_passphrase[] = "your_wpa_passphrase";
123149/*
124150 * OPTION B: WEP
125151 *
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.
128154 *
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.
131157 */
132158//#define WIFI_WEP_SECURITY
133159
@@ -142,7 +168,8 @@ char wep_key[] = "your_wep_key";
142168/*
143169 * OPTION C: Open network (no security)
144170 *
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.
146173 *
147174 * To enable, uncomment #define WIFI_NO_SECURITY below and verify the #define values
148175 * under options A and B are commented out.
@@ -153,11 +180,11 @@ char wep_key[] = "your_wep_key";
153180 * CONFIGURATION ERROR CHECK (don't change anything here)
154181 *============================================================================*/
155182
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
157184#error "you may not define more than one wifi device type in wifiConfig.h."
158- #endif //WIFI device type check
185+ #endif
159186
160- #if !(defined( ARDUINO_WIFI_SHIELD ) || defined( WIFI_101 ) || defined( HUZZAH_WIFI ) || defined( ESP8266_WIFI ))
187+ #ifndef WIFI_LIB_INCLUDED
161188#error "you must define a wifi device type in wifiConfig.h."
162189#endif
163190
@@ -171,15 +198,15 @@ char wep_key[] = "your_wep_key";
171198
172199#if (defined(ESP8266_WIFI ) && !(defined(WIFI_NO_SECURITY ) || (defined(WIFI_WPA_SECURITY ))))
173200#error "you must choose between WIFI_NO_SECURITY and WIFI_WPA_SECURITY"
174- #endif
201+ #endif
175202
176203/*==============================================================================
177204 * PIN IGNORE MACROS (don't change anything here)
178205 *============================================================================*/
179206
180207// ignore SPI pins, pin 5 (reset WiFi101 shield), pin 7 (WiFi handshake) and pin 10 (WiFi SS)
181208// 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.
183210#define IS_IGNORE_WIFI101_SHIELD (p ) ((p) == 10 || (IS_PIN_SPI(p) && (p) != SS) || (p) == 5 || (p) == 7)
184211
185212// ignore SPI pins, pin 4 (SS for SD-Card on WiFi-shield), pin 7 (WiFi handshake) and pin 10 (WiFi SS)
0 commit comments