1313 Copyright (C) 2009 Shigeru Kobayashi. All rights reserved.
1414 Copyright (C) 2009-2016 Jeff Hoefs. All rights reserved.
1515 Copyright (C) 2015-2016 Jesse Frush. All rights reserved.
16+ Copyright (C) 2016 Jens B. All rights reserved.
1617
1718 This library is free software; you can redistribute it and/or
1819 modify it under the terms of the GNU Lesser General Public
2122
2223 See file LICENSE.txt for further informations on licensing terms.
2324
24- Last updated by Jeff Hoefs: January 10th, 2016
25+ Last updated by Jeff Hoefs: April 10th, 2016
2526*/
2627
2728/*
3637 - Arduino WiFi Shield (or clone)
3738 - Arduino WiFi Shield 101
3839 - 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
4041
4142 Follow the instructions in the wifiConfig.h file (wifiConfig.h tab in Arduino IDE) to
4243 configure your particular hardware.
4546 - WiFi Shield 101 requires version 0.7.0 or higher of the WiFi101 library (available in Arduino
4647 1.6.8 or higher, or update the library via the Arduino Library Manager or clone from source:
4748 https://github.com/arduino-libraries/WiFi101)
49+ - ESP8266 requires the Arduino ESP8266 core which can be obtained here:
50+ https://github.com/esp8266/Arduino
4851
4952 In order to use the WiFi Shield 101 with Firmata you will need a board with at least
5053 35k of Flash memory. This means you cannot use the WiFi Shield 101 with an Arduino Uno
7477#include < Wire.h>
7578#include < Firmata.h>
7679
77- // I dont understand either
78- void disableI2CPins ();
79- void enableI2CPins ();
80- void reportAnalogCallback (byte analogPin, int value);
81-
8280/*
8381 * Uncomment the #define SERIAL_DEBUG line below to receive serial output messages relating to your
8482 * connection that may help in the event of connection issues. If defined, some boards may not begin
@@ -125,6 +123,12 @@ SerialFirmata serialFeature;
125123#ifdef STATIC_IP_ADDRESS
126124IPAddress local_ip (STATIC_IP_ADDRESS);
127125#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
128132
129133int wifiConnectionAttemptCounter = 0 ;
130134int wifiStatus = WL_IDLE_STATUS;
@@ -692,7 +696,7 @@ void sysexCallback(byte command, byte argc, byte *argv)
692696 }
693697 if (IS_PIN_PWM (pin)) {
694698 Firmata.write (PIN_MODE_PWM);
695- Firmata.write (8 ); // 8 = 8-bit resolution
699+ Firmata.write (DEFAULT_PWM_RESOLUTION);
696700 }
697701 if (IS_PIN_DIGITAL (pin)) {
698702 Firmata.write (PIN_MODE_SERVO);
@@ -822,37 +826,37 @@ void systemResetCallback()
822826}
823827
824828void printWifiStatus () {
825- #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
829+ #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
826830 if ( WiFi.status () != WL_CONNECTED )
827831 {
828832 DEBUG_PRINT ( " WiFi connection failed. Status value: " );
829833 DEBUG_PRINTLN ( WiFi.status () );
830834 }
831835 else
832- #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
836+ #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
833837 {
834838 // print the SSID of the network you're attached to:
835839 DEBUG_PRINT ( " SSID: " );
836840
837- #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
841+ #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
838842 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)
840844
841845 // print your WiFi shield's IP address:
842846 DEBUG_PRINT ( " IP Address: " );
843847
844- #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
848+ #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
845849 IPAddress ip = WiFi.localIP ();
846850 DEBUG_PRINTLN ( ip );
847- #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
851+ #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
848852
849853 // print the received signal strength:
850854 DEBUG_PRINT ( " signal strength (RSSI): " );
851855
852- #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
856+ #if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
853857 long rssi = WiFi.RSSI ();
854858 DEBUG_PRINT ( rssi );
855- #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
859+ #endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101) || defined(ESP8266_WIFI)
856860
857861 DEBUG_PRINTLN ( " dBm" );
858862 }
@@ -873,6 +877,8 @@ void setup()
873877 DEBUG_PRINTLN ( " using the WiFi 101 library." );
874878#elif defined(ARDUINO_WIFI_SHIELD)
875879 DEBUG_PRINTLN ( " using the legacy WiFi library." );
880+ #elif defined(ESP8266_WIFI)
881+ DEBUG_PRINTLN ( " using the ESP8266 WiFi library." );
876882#elif defined(HUZZAH_WIFI)
877883 DEBUG_PRINTLN ( " using the HUZZAH WiFi library." );
878884 // else should never happen here as error-checking in wifiConfig.h will catch this
@@ -884,9 +890,13 @@ void setup()
884890#ifdef STATIC_IP_ADDRESS
885891 DEBUG_PRINT ( " Using static IP: " );
886892 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.
889898 stream.config ( local_ip );
899+ #endif
890900#else
891901 DEBUG_PRINTLN ( " IP will be requested from DHCP ..." );
892902#endif
@@ -952,7 +962,8 @@ void setup()
952962 || 28 == i
953963 #endif // defined(__AVR_ATmega32U4__)
954964 ) {
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)
956967 if (IS_IGNORE_WIFI101_SHIELD (i)) {
957968#elif defined (HUZZAH_WIFI)
958969 // TODO
0 commit comments