1 | /*==============================================================================
|
---|
2 | * WIFI CONFIGURATION
|
---|
3 | *
|
---|
4 | * You must configure your particular hardware. Follow the steps below.
|
---|
5 | *
|
---|
6 | * Currently StandardFirmataWiFi is configured as a server. An option to
|
---|
7 | * configure as a client may be added in the future.
|
---|
8 | *============================================================================*/
|
---|
9 |
|
---|
10 | // STEP 1 [REQUIRED]
|
---|
11 | // Uncomment / comment the appropriate set of includes for your hardware (OPTION A, B or C)
|
---|
12 | // Option A is enabled by default.
|
---|
13 |
|
---|
14 | /*
|
---|
15 | * OPTION A: Configure for Arduino WiFi shield
|
---|
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.
|
---|
20 | *
|
---|
21 | * To configure StandardFirmataWiFi to use the Arduino WiFi shield
|
---|
22 | * leave the #define below uncommented.
|
---|
23 | */
|
---|
24 | #define ARDUINO_WIFI_SHIELD
|
---|
25 |
|
---|
26 | //do not modify these next 4 lines
|
---|
27 | #ifdef ARDUINO_WIFI_SHIELD
|
---|
28 | #include "utility/WiFiStream.h"
|
---|
29 | WiFiStream stream;
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | /*
|
---|
33 | * OPTION B: Configure for WiFi 101
|
---|
34 | *
|
---|
35 | * This will configure StandardFirmataWiFi to use the WiFi101 library, which works with the Arduino WiFi101
|
---|
36 | * shield and devices that have the WiFi101 chip built in (such as the MKR1000). It is compatible
|
---|
37 | * with 802.11 B/G/N networks.
|
---|
38 | *
|
---|
39 | * To enable, uncomment the #define WIFI_101 below and verify the #define values under
|
---|
40 | * options A and C are commented out.
|
---|
41 | *
|
---|
42 | * IMPORTANT: You must have the WiFI 101 library installed. To easily install this library, opent the library manager via:
|
---|
43 | * Arduino IDE Menus: Sketch > Include Library > Manage Libraries > filter search for "WiFi101" > Select the result and click 'install'
|
---|
44 | */
|
---|
45 | //#define WIFI_101
|
---|
46 |
|
---|
47 | //do not modify these next 4 lines
|
---|
48 | #ifdef WIFI_101
|
---|
49 | #include "utility/WiFi101Stream.h"
|
---|
50 | WiFi101Stream stream;
|
---|
51 | #endif
|
---|
52 |
|
---|
53 | /*
|
---|
54 | * OPTION C: Configure for HUZZAH
|
---|
55 | *
|
---|
56 | * HUZZAH is not yet supported, this will be added in a later revision to StandardFirmataWiFi
|
---|
57 | */
|
---|
58 |
|
---|
59 | //------------------------------
|
---|
60 | // TODO
|
---|
61 | //------------------------------
|
---|
62 | //#define HUZZAH_WIFI
|
---|
63 |
|
---|
64 |
|
---|
65 | // STEP 2 [REQUIRED for all boards and shields]
|
---|
66 | // replace this with your wireless network SSID
|
---|
67 | char ssid[] = "your_network_name";
|
---|
68 |
|
---|
69 | // STEP 3 [OPTIONAL for all boards and shields]
|
---|
70 | // if you want to use a static IP (v4) address, uncomment the line below. You can also change the IP.
|
---|
71 | // if this line is commented out, the WiFi shield will attempt to get an IP from the DHCP server
|
---|
72 | // #define STATIC_IP_ADDRESS 192,168,1,113
|
---|
73 |
|
---|
74 | // STEP 4 [REQUIRED for all boards and shields]
|
---|
75 | // define your port number here, you will need this to open a TCP connection to your Arduino
|
---|
76 | #define SERVER_PORT 3030
|
---|
77 |
|
---|
78 | // STEP 5 [REQUIRED for all boards and shields]
|
---|
79 | // determine your network security type (OPTION A, B, or C). Option A is the most common, and the default.
|
---|
80 |
|
---|
81 |
|
---|
82 | /*
|
---|
83 | * OPTION A: WPA / WPA2
|
---|
84 | *
|
---|
85 | * WPA is the most common network security type. A passphrase is required to connect to this type.
|
---|
86 | *
|
---|
87 | * To enable, leave #define WIFI_WPA_SECURITY uncommented below, set your wpa_passphrase value appropriately,
|
---|
88 | * and do not uncomment the #define values under options B and C
|
---|
89 | */
|
---|
90 | #define WIFI_WPA_SECURITY
|
---|
91 |
|
---|
92 | #ifdef WIFI_WPA_SECURITY
|
---|
93 | char wpa_passphrase[] = "your_wpa_passphrase";
|
---|
94 | #endif //WIFI_WPA_SECURITY
|
---|
95 |
|
---|
96 | /*
|
---|
97 | * OPTION B: WEP
|
---|
98 | *
|
---|
99 | * WEP is a less common (and regarded as less safe) security type. A WEP key and its associated index are required
|
---|
100 | * to connect to this type.
|
---|
101 | *
|
---|
102 | * To enable, Uncomment the #define below, set your wep_index and wep_key values appropriately, and verify
|
---|
103 | * the #define values under options A and C are commented out.
|
---|
104 | */
|
---|
105 | //#define WIFI_WEP_SECURITY
|
---|
106 |
|
---|
107 | #ifdef WIFI_WEP_SECURITY
|
---|
108 | //The wep_index below is a zero-indexed value.
|
---|
109 | //Valid indices are [0-3], even if your router/gateway numbers your keys [1-4].
|
---|
110 | byte wep_index = 0;
|
---|
111 | char wep_key[] = "your_wep_key";
|
---|
112 | #endif //WIFI_WEP_SECURITY
|
---|
113 |
|
---|
114 |
|
---|
115 | /*
|
---|
116 | * OPTION C: Open network (no security)
|
---|
117 | *
|
---|
118 | * Open networks have no security, can be connected to by any device that knows the ssid, and are unsafe.
|
---|
119 | *
|
---|
120 | * To enable, uncomment #define WIFI_NO_SECURITY below and verify the #define values
|
---|
121 | * under options A and B are commented out.
|
---|
122 | */
|
---|
123 | //#define WIFI_NO_SECURITY
|
---|
124 |
|
---|
125 | /*==============================================================================
|
---|
126 | * CONFIGURATION ERROR CHECK (don't change anything here)
|
---|
127 | *============================================================================*/
|
---|
128 |
|
---|
129 | #if ((defined(ARDUINO_WIFI_SHIELD) && (defined(WIFI_101) || defined(HUZZAH_WIFI))) || (defined(WIFI_101) && defined(HUZZAH_WIFI)))
|
---|
130 | #error "you may not define more than one wifi device type in wifiConfig.h."
|
---|
131 | #endif //WIFI device type check
|
---|
132 |
|
---|
133 | #if !(defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(HUZZAH_WIFI))
|
---|
134 | #error "you must define a wifi device type in wifiConfig.h."
|
---|
135 | #endif
|
---|
136 |
|
---|
137 | #if ((defined(WIFI_NO_SECURITY) && (defined(WIFI_WEP_SECURITY) || defined(WIFI_WPA_SECURITY))) || (defined(WIFI_WEP_SECURITY) && defined(WIFI_WPA_SECURITY)))
|
---|
138 | #error "you may not define more than one security type at the same time in wifiConfig.h."
|
---|
139 | #endif //WIFI_* security define check
|
---|
140 |
|
---|
141 | #if !(defined(WIFI_NO_SECURITY) || defined(WIFI_WEP_SECURITY) || defined(WIFI_WPA_SECURITY))
|
---|
142 | #error "you must define a wifi security type in wifiConfig.h."
|
---|
143 | #endif //WIFI_* security define check
|
---|
144 |
|
---|
145 | /*==============================================================================
|
---|
146 | * PIN IGNORE MACROS (don't change anything here)
|
---|
147 | *============================================================================*/
|
---|
148 |
|
---|
149 | // ignore SPI pins, pin 5 (reset WiFi101 shield), pin 7 (WiFi handshake) and pin 10 (WiFi SS)
|
---|
150 | // also don't ignore SS pin if it's not pin 10
|
---|
151 | // TODO - need to differentiate between Arduino WiFi1 101 Shield and Arduino MKR1000
|
---|
152 | #define IS_IGNORE_WIFI101_SHIELD(p) ((p) == 10 || (IS_PIN_SPI(p) && (p) != SS) || (p) == 5 || (p) == 7)
|
---|
153 |
|
---|
154 | // ignore SPI pins, pin 4 (SS for SD-Card on WiFi-shield), pin 7 (WiFi handshake) and pin 10 (WiFi SS)
|
---|
155 | #define IS_IGNORE_WIFI_SHIELD(p) ((IS_PIN_SPI(p) || (p) == 4) || (p) == 7 || (p) == 10)
|
---|