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
74
77
#include < Wire.h>
75
78
#include < Firmata.h>
76
79
77
- // I dont understand either
78
- void disableI2CPins ();
79
- void enableI2CPins ();
80
- void reportAnalogCallback (byte analogPin, int value);
81
-
82
80
/*
83
81
* Uncomment the #define SERIAL_DEBUG line below to receive serial output messages relating to your
84
82
* connection that may help in the event of connection issues. If defined, some boards may not begin
@@ -125,6 +123,12 @@ SerialFirmata serialFeature;
125
123
#ifdef STATIC_IP_ADDRESS
126
124
IPAddress local_ip (STATIC_IP_ADDRESS);
127
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
128
132
129
133
int wifiConnectionAttemptCounter = 0 ;
130
134
int wifiStatus = WL_IDLE_STATUS;
@@ -692,7 +696,7 @@ void sysexCallback(byte command, byte argc, byte *argv)
692
696
}
693
697
if (IS_PIN_PWM (pin)) {
694
698
Firmata.write (PIN_MODE_PWM);
695
- Firmata.write (8 ); // 8 = 8-bit resolution
699
+ Firmata.write (DEFAULT_PWM_RESOLUTION);
696
700
}
697
701
if (IS_PIN_DIGITAL (pin)) {
698
702
Firmata.write (PIN_MODE_SERVO);
@@ -822,37 +826,37 @@ void systemResetCallback()
822
826
}
823
827
824
828
void printWifiStatus () {
825
- #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
829
+ #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
826
830
if ( WiFi.status () != WL_CONNECTED )
827
831
{
828
832
DEBUG_PRINT ( " WiFi connection failed. Status value: " );
829
833
DEBUG_PRINTLN ( WiFi.status () );
830
834
}
831
835
else
832
- #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
836
+ #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
833
837
{
834
838
// print the SSID of the network you're attached to:
835
839
DEBUG_PRINT ( " SSID: " );
836
840
837
- #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
841
+ #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
838
842
DEBUG_PRINTLN ( WiFi.SSID () );
839
- #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
843
+ #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
840
844
841
845
// print your WiFi shield's IP address:
842
846
DEBUG_PRINT ( " IP Address: " );
843
847
844
- #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
848
+ #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
845
849
IPAddress ip = WiFi.localIP ();
846
850
DEBUG_PRINTLN ( ip );
847
- #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
851
+ #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
848
852
849
853
// print the received signal strength:
850
854
DEBUG_PRINT ( " signal strength (RSSI): " );
851
855
852
- #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
856
+ #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
853
857
long rssi = WiFi.RSSI ();
854
858
DEBUG_PRINT ( rssi );
855
- #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
859
+ #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
856
860
857
861
DEBUG_PRINTLN ( " dBm" );
858
862
}
@@ -873,6 +877,8 @@ void setup()
873
877
DEBUG_PRINTLN ( " using the WiFi 101 library." );
874
878
#elif defined(ARDUINO_WIFI_SHIELD)
875
879
DEBUG_PRINTLN ( " using the legacy WiFi library." );
880
+ #elif defined(ESP8266_WIFI)
881
+ DEBUG_PRINTLN ( " using the ESP8266 WiFi library." );
876
882
#elif defined(HUZZAH_WIFI)
877
883
DEBUG_PRINTLN ( " using the HUZZAH WiFi library." );
878
884
// else should never happen here as error-checking in wifiConfig.h will catch this
@@ -884,9 +890,13 @@ void setup()
884
890
#ifdef STATIC_IP_ADDRESS
885
891
DEBUG_PRINT ( " Using static IP: " );
886
892
DEBUG_PRINTLN ( local_ip );
887
- // you can also provide a static IP in the begin() functions, but this simplifies
888
- // 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.
889
898
stream.config ( local_ip );
899
+ #endif
890
900
#else
891
901
DEBUG_PRINTLN ( " IP will be requested from DHCP ..." );
892
902
#endif
@@ -952,7 +962,8 @@ void setup()
952
962
|| 28 == i
953
963
#endif // defined(__AVR_ATmega32U4__)
954
964
) {
955
- #elif defined (WIFI_101)
965
+ // don't ignore pins when using Wi-Fi 101 library with the MKR1000
966
+ #elif defined (WIFI_101) && !defined(ARDUINO_SAMD_MKR1000)
956
967
if (IS_IGNORE_WIFI101_SHIELD (i)) {
957
968
#elif defined (HUZZAH_WIFI)
958
969
// TODO
0 commit comments