27
27
/*
28
28
README
29
29
30
+ StandardFirmataWiFi is a WiFi server application. You will need a Firmata client library with
31
+ a network transport in order to establish a connection with StandardFirmataWiFi.
32
+
30
33
To use StandardFirmataWiFi you will need to have one of the following
31
34
boards or shields:
32
35
38
41
Follow the instructions in the wifiConfig.h file (wifiConfig.h tab in Arduino IDE) to
39
42
configure your particular hardware.
40
43
44
+ Dependencies:
45
+ - WiFi Shield 101 requires version 0.7.0 or higher of the WiFi101 library (available in Arduino
46
+ 1.6.8 or higher, or update the library via the Arduino Library Manager or clone from source:
47
+ https://github.com/arduino-libraries/WiFi101)
48
+
41
49
In order to use the WiFi Shield 101 with Firmata you will need a board with at least
42
50
35k of Flash memory. This means you cannot use the WiFi Shield 101 with an Arduino Uno
43
51
or any other ATmega328p-based microcontroller or with an Arduino Leonardo or other
99
107
*============================================================================*/
100
108
101
109
#ifdef STATIC_IP_ADDRESS
102
- IPAddress local_ip (STATIC_IP_ADDRESS);
110
+ IPAddress local_ip (STATIC_IP_ADDRESS);
103
111
#endif
104
112
105
113
int wifiConnectionAttemptCounter = 0 ;
@@ -782,7 +790,7 @@ void systemResetCallback()
782
790
783
791
void printWifiStatus () {
784
792
#if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
785
- if ( WiFi.status () != WL_CONNECTED )
793
+ if ( WiFi.status () != WL_CONNECTED )
786
794
{
787
795
DEBUG_PRINT ( " WiFi connection failed. Status value: " );
788
796
DEBUG_PRINTLN ( WiFi.status () );
@@ -797,15 +805,15 @@ void printWifiStatus() {
797
805
DEBUG_PRINTLN ( WiFi.SSID () );
798
806
#endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
799
807
800
- // print your WiFi shield's IP address:
808
+ // print your WiFi shield's IP address:
801
809
DEBUG_PRINT ( " IP Address: " );
802
810
803
811
#if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
804
812
IPAddress ip = WiFi.localIP ();
805
813
DEBUG_PRINTLN ( ip );
806
814
#endif // defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
807
815
808
- // print the received signal strength:
816
+ // print the received signal strength:
809
817
DEBUG_PRINT ( " signal strength (RSSI): " );
810
818
811
819
#if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
@@ -823,7 +831,7 @@ void setup()
823
831
* WIFI SETUP
824
832
*/
825
833
DEBUG_BEGIN (9600 );
826
-
834
+
827
835
/*
828
836
* This statement will clarify how a connection is being made
829
837
*/
@@ -834,7 +842,7 @@ void setup()
834
842
DEBUG_PRINTLN ( " using the legacy WiFi library." );
835
843
#elif defined(HUZZAH_WIFI)
836
844
DEBUG_PRINTLN ( " using the HUZZAH WiFi library." );
837
- // else should never happen here as error-checking in wifiConfig.h will catch this
845
+ // else should never happen here as error-checking in wifiConfig.h will catch this
838
846
#endif // defined(WIFI_101)
839
847
840
848
/*
@@ -854,27 +862,28 @@ void setup()
854
862
* Configure WiFi security
855
863
*/
856
864
#if defined(WIFI_WEP_SECURITY)
857
- while (wifiStatus != WL_CONNECTED) {
858
- DEBUG_PRINT (" Attempting to connect to WEP SSID: " );
865
+ while (wifiStatus != WL_CONNECTED) {
866
+ DEBUG_PRINT ( " Attempting to connect to WEP SSID: " );
859
867
DEBUG_PRINTLN (ssid);
860
868
wifiStatus = stream.begin ( ssid, wep_index, wep_key, SERVER_PORT );
861
869
delay (5000 ); // TODO - determine minimum delay
862
870
if (++wifiConnectionAttemptCounter > WIFI_MAX_CONN_ATTEMPTS) break ;
863
871
}
864
872
865
873
#elif defined(WIFI_WPA_SECURITY)
866
- while (wifiStatus != WL_CONNECTED) {
867
- DEBUG_PRINT (" Attempting to connect to WPA SSID: " );
874
+ while (wifiStatus != WL_CONNECTED) {
875
+ DEBUG_PRINT ( " Attempting to connect to WPA SSID: " );
868
876
DEBUG_PRINTLN (ssid);
869
877
wifiStatus = stream.begin (ssid, wpa_passphrase, SERVER_PORT);
870
878
delay (5000 ); // TODO - determine minimum delay
871
879
if (++wifiConnectionAttemptCounter > WIFI_MAX_CONN_ATTEMPTS) break ;
872
880
}
873
881
874
882
#else // OPEN network
875
- DEBUG_PRINTLN ( " Connecting to an open network ..." );
876
- while (wifiStatus != WL_CONNECTED) {
877
- wifiStatus = stream.begin ( ssid, SERVER_PORT );
883
+ while (wifiStatus != WL_CONNECTED) {
884
+ DEBUG_PRINTLN ( " Attempting to connect to open SSID: " );
885
+ DEBUG_PRINTLN (ssid);
886
+ wifiStatus = stream.begin (ssid, SERVER_PORT);
878
887
delay (5000 ); // TODO - determine minimum delay
879
888
if (++wifiConnectionAttemptCounter > WIFI_MAX_CONN_ATTEMPTS) break ;
880
889
}
@@ -909,7 +918,7 @@ void setup()
909
918
|| 24 == i // On Leonardo, pin 24 maps to D4 and pin 28 maps to D10
910
919
|| 28 == i
911
920
#endif // defined(__AVR_ATmega32U4__)
912
- ) {
921
+ ) {
913
922
#elif defined (WIFI_101)
914
923
if (IS_IGNORE_WIFI101_SHIELD (i)) {
915
924
#elif defined (HUZZAH_WIFI)
@@ -922,7 +931,7 @@ void setup()
922
931
}
923
932
}
924
933
925
- // Set up controls for the Arduino WiFi Shield SS for the SD Card
934
+ // Set up controls for the Arduino WiFi Shield SS for the SD Card
926
935
#ifdef ARDUINO_WIFI_SHIELD
927
936
// Arduino WiFi, Arduino WiFi Shield and Arduino Yun all have SD SS wired to D4
928
937
pinMode (PIN_TO_DIGITAL (4 ), OUTPUT); // switch off SD card bypassing Firmata
0 commit comments