13
13
Copyright (C) 2009 Shigeru Kobayashi. All rights reserved.
14
14
Copyright (C) 2009-2016 Jeff Hoefs. All rights reserved.
15
15
Copyright (C) 2015-2016 Jesse Frush. All rights reserved.
16
+ Copyright (C) 2016 Jens B. All rights reserved.
16
17
17
18
This library is free software; you can redistribute it and/or
18
19
modify it under the terms of the GNU Lesser General Public
21
22
22
23
See file LICENSE.txt for further informations on licensing terms.
23
24
24
- Last updated by Jeff Hoefs: January 10th, 2016
25
+ Last updated by Jeff Hoefs: April 10th, 2016
25
26
*/
26
27
27
28
/*
36
37
- Arduino WiFi Shield (or clone)
37
38
- Arduino WiFi Shield 101
38
39
- Arduino MKR1000 board (built-in WiFi 101)
39
- - Adafruit HUZZAH CC3000 WiFi Shield (support coming soon)
40
+ - ESP8266 WiFi board compatible with ESP8266 Arduino core
40
41
41
42
Follow the instructions in the wifiConfig.h file (wifiConfig.h tab in Arduino IDE) to
42
43
configure your particular hardware.
45
46
- WiFi Shield 101 requires version 0.7.0 or higher of the WiFi101 library (available in Arduino
46
47
1.6.8 or higher, or update the library via the Arduino Library Manager or clone from source:
47
48
https://github.com/arduino-libraries/WiFi101)
49
+ - ESP8266 requires the Arduino ESP8266 core which can be obtained here:
50
+ https://github.com/esp8266/Arduino
48
51
49
52
In order to use the WiFi Shield 101 with Firmata you will need a board with at least
50
53
35k of Flash memory. This means you cannot use the WiFi Shield 101 with an Arduino Uno
@@ -120,6 +123,12 @@ SerialFirmata serialFeature;
120
123
#ifdef STATIC_IP_ADDRESS
121
124
IPAddress local_ip (STATIC_IP_ADDRESS);
122
125
#endif
126
+ #ifdef SUBNET_MASK
127
+ IPAddress subnet (SUBNET_MASK);
128
+ #endif
129
+ #ifdef GATEWAY_IP_ADDRESS
130
+ IPAddress gateway (GATEWAY_IP_ADDRESS);
131
+ #endif
123
132
124
133
int wifiConnectionAttemptCounter = 0 ;
125
134
int wifiStatus = WL_IDLE_STATUS;
@@ -687,7 +696,7 @@ void sysexCallback(byte command, byte argc, byte *argv)
687
696
}
688
697
if (IS_PIN_PWM (pin)) {
689
698
Firmata.write (PIN_MODE_PWM);
690
- Firmata.write (8 ); // 8 = 8-bit resolution
699
+ Firmata.write (DEFAULT_PWM_RESOLUTION);
691
700
}
692
701
if (IS_PIN_DIGITAL (pin)) {
693
702
Firmata.write (PIN_MODE_SERVO);
@@ -817,37 +826,37 @@ void systemResetCallback()
817
826
}
818
827
819
828
void printWifiStatus () {
820
- #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
829
+ #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
821
830
if ( WiFi.status () != WL_CONNECTED )
822
831
{
823
832
DEBUG_PRINT ( " WiFi connection failed. Status value: " );
824
833
DEBUG_PRINTLN ( WiFi.status () );
825
834
}
826
835
else
827
- #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
836
+ #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
828
837
{
829
838
// print the SSID of the network you're attached to:
830
839
DEBUG_PRINT ( " SSID: " );
831
840
832
- #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
841
+ #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
833
842
DEBUG_PRINTLN ( WiFi.SSID () );
834
- #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
843
+ #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
835
844
836
845
// print your WiFi shield's IP address:
837
846
DEBUG_PRINT ( " IP Address: " );
838
847
839
- #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
848
+ #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
840
849
IPAddress ip = WiFi.localIP ();
841
850
DEBUG_PRINTLN ( ip );
842
- #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
851
+ #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
843
852
844
853
// print the received signal strength:
845
854
DEBUG_PRINT ( " signal strength (RSSI): " );
846
855
847
- #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
856
+ #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
848
857
long rssi = WiFi.RSSI ();
849
858
DEBUG_PRINT ( rssi );
850
- #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
859
+ #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
851
860
852
861
DEBUG_PRINTLN ( " dBm" );
853
862
}
@@ -868,6 +877,8 @@ void setup()
868
877
DEBUG_PRINTLN ( " using the WiFi 101 library." );
869
878
#elif defined(ARDUINO_WIFI_SHIELD)
870
879
DEBUG_PRINTLN ( " using the legacy WiFi library." );
880
+ #elif defined(ESP8266_WIFI)
881
+ DEBUG_PRINTLN ( " using the ESP8266 WiFi library." );
871
882
#elif defined(HUZZAH_WIFI)
872
883
DEBUG_PRINTLN ( " using the HUZZAH WiFi library." );
873
884
// else should never happen here as error-checking in wifiConfig.h will catch this
@@ -879,9 +890,13 @@ void setup()
879
890
#ifdef STATIC_IP_ADDRESS
880
891
DEBUG_PRINT ( " Using static IP: " );
881
892
DEBUG_PRINTLN ( local_ip );
882
- // you can also provide a static IP in the begin() functions, but this simplifies
883
- // ifdef logic in this sketch due to support for all different encryption types.
893
+ #ifdef ESP8266_WIFI
894
+ stream.config ( local_ip , gateway, subnet );
895
+ #else
896
+ // you can also provide a static IP in the begin() functions, but this simplifies
897
+ // ifdef logic in this sketch due to support for all different encryption types.
884
898
stream.config ( local_ip );
899
+ #endif
885
900
#else
886
901
DEBUG_PRINTLN ( " IP will be requested from DHCP ..." );
887
902
#endif
0 commit comments