Skip to content

Commit beed04f

Browse files
add additional comments and apply astyle formatting
1 parent a779755 commit beed04f

File tree

6 files changed

+96
-85
lines changed

6 files changed

+96
-85
lines changed

examples/StandardFirmataWiFi/StandardFirmataWiFi.ino

+24-15
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
/*
2828
README
2929
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+
3033
To use StandardFirmataWiFi you will need to have one of the following
3134
boards or shields:
3235
@@ -38,6 +41,11 @@
3841
Follow the instructions in the wifiConfig.h file (wifiConfig.h tab in Arduino IDE) to
3942
configure your particular hardware.
4043
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+
4149
In order to use the WiFi Shield 101 with Firmata you will need a board with at least
4250
35k of Flash memory. This means you cannot use the WiFi Shield 101 with an Arduino Uno
4351
or any other ATmega328p-based microcontroller or with an Arduino Leonardo or other
@@ -99,7 +107,7 @@
99107
*============================================================================*/
100108

101109
#ifdef STATIC_IP_ADDRESS
102-
IPAddress local_ip(STATIC_IP_ADDRESS);
110+
IPAddress local_ip(STATIC_IP_ADDRESS);
103111
#endif
104112

105113
int wifiConnectionAttemptCounter = 0;
@@ -782,7 +790,7 @@ void systemResetCallback()
782790

783791
void printWifiStatus() {
784792
#if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
785-
if( WiFi.status() != WL_CONNECTED )
793+
if ( WiFi.status() != WL_CONNECTED )
786794
{
787795
DEBUG_PRINT( "WiFi connection failed. Status value: " );
788796
DEBUG_PRINTLN( WiFi.status() );
@@ -797,15 +805,15 @@ void printWifiStatus() {
797805
DEBUG_PRINTLN( WiFi.SSID() );
798806
#endif //defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
799807

800-
// print your WiFi shield's IP address:
808+
// print your WiFi shield's IP address:
801809
DEBUG_PRINT( "IP Address: " );
802810

803811
#if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
804812
IPAddress ip = WiFi.localIP();
805813
DEBUG_PRINTLN( ip );
806814
#endif //defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
807815

808-
// print the received signal strength:
816+
// print the received signal strength:
809817
DEBUG_PRINT( "signal strength (RSSI): " );
810818

811819
#if defined(ARDUINO_WIFI_SHIELD) || defined(WIFI_101)
@@ -823,7 +831,7 @@ void setup()
823831
* WIFI SETUP
824832
*/
825833
DEBUG_BEGIN(9600);
826-
834+
827835
/*
828836
* This statement will clarify how a connection is being made
829837
*/
@@ -834,7 +842,7 @@ void setup()
834842
DEBUG_PRINTLN( "using the legacy WiFi library." );
835843
#elif defined(HUZZAH_WIFI)
836844
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
838846
#endif //defined(WIFI_101)
839847

840848
/*
@@ -854,27 +862,28 @@ void setup()
854862
* Configure WiFi security
855863
*/
856864
#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: " );
859867
DEBUG_PRINTLN(ssid);
860868
wifiStatus = stream.begin( ssid, wep_index, wep_key, SERVER_PORT );
861869
delay(5000); // TODO - determine minimum delay
862870
if (++wifiConnectionAttemptCounter > WIFI_MAX_CONN_ATTEMPTS) break;
863871
}
864872

865873
#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: " );
868876
DEBUG_PRINTLN(ssid);
869877
wifiStatus = stream.begin(ssid, wpa_passphrase, SERVER_PORT);
870878
delay(5000); // TODO - determine minimum delay
871879
if (++wifiConnectionAttemptCounter > WIFI_MAX_CONN_ATTEMPTS) break;
872880
}
873881

874882
#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);
878887
delay(5000); // TODO - determine minimum delay
879888
if (++wifiConnectionAttemptCounter > WIFI_MAX_CONN_ATTEMPTS) break;
880889
}
@@ -909,7 +918,7 @@ void setup()
909918
|| 24 == i // On Leonardo, pin 24 maps to D4 and pin 28 maps to D10
910919
|| 28 == i
911920
#endif //defined(__AVR_ATmega32U4__)
912-
) {
921+
) {
913922
#elif defined (WIFI_101)
914923
if (IS_IGNORE_WIFI101_SHIELD(i)) {
915924
#elif defined (HUZZAH_WIFI)
@@ -922,7 +931,7 @@ void setup()
922931
}
923932
}
924933

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
926935
#ifdef ARDUINO_WIFI_SHIELD
927936
// Arduino WiFi, Arduino WiFi Shield and Arduino Yun all have SD SS wired to D4
928937
pinMode(PIN_TO_DIGITAL(4), OUTPUT); // switch off SD card bypassing Firmata

examples/StandardFirmataWiFi/wifiConfig.h

+12-10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
* WIFI CONFIGURATION
33
*
44
* 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.
58
*============================================================================*/
69

710
// STEP 1 [REQUIRED]
@@ -10,12 +13,12 @@
1013

1114
/*
1215
* OPTION A: Configure for Arduino WiFi shield
13-
*
16+
*
1417
* This will configure StandardFirmataWiFi to use the original WiFi library (deprecated) provided
1518
* with the Arduino IDE. It is supported by the Arduino WiFi shield (a discontinued product) and
1619
* is compatible with 802.11 B/G networks.
1720
*
18-
* To configure StandardFirmataWiFi to use the Arduino WiFi shield
21+
* To configure StandardFirmataWiFi to use the Arduino WiFi shield
1922
* leave the #define below uncommented.
2023
*/
2124
#define ARDUINO_WIFI_SHIELD
@@ -28,9 +31,9 @@ WiFiStream stream;
2831

2932
/*
3033
* OPTION B: Configure for WiFi 101
31-
*
34+
*
3235
* This will configure StandardFirmataWiFi to use the WiFi101 library, which works with the Arduino WiFi101
33-
* shield and devices that have the WiFi101 chip built in (such as the MKR1000). It is compatible
36+
* shield and devices that have the WiFi101 chip built in (such as the MKR1000). It is compatible
3437
* with 802.11 B/G/N networks.
3538
*
3639
* To enable, uncomment the #define WIFI_101 below and verify the #define values under
@@ -49,7 +52,7 @@ WiFi101Stream stream;
4952

5053
/*
5154
* OPTION C: Configure for HUZZAH
52-
*
55+
*
5356
* HUZZAH is not yet supported, this will be added in a later revision to StandardFirmataWiFi
5457
*/
5558

@@ -78,9 +81,9 @@ char ssid[] = "your_network_name";
7881

7982
/*
8083
* OPTION A: WPA / WPA2
81-
*
84+
*
8285
* WPA is the most common network security type. A passphrase is required to connect to this type.
83-
*
86+
*
8487
* To enable, leave #define WIFI_WPA_SECURITY uncommented below, set your wpa_passphrase value appropriately,
8588
* and do not uncomment the #define values under options B and C
8689
*/
@@ -95,7 +98,7 @@ char wpa_passphrase[] = "your_wpa_passphrase";
9598
*
9699
* WEP is a less common (and regarded as less safe) security type. A WEP key and its associated index are required
97100
* to connect to this type.
98-
*
101+
*
99102
* To enable, Uncomment the #define below, set your wep_index and wep_key values appropriately, and verify
100103
* the #define values under options A and C are commented out.
101104
*/
@@ -111,7 +114,7 @@ char wep_key[] = "your_wep_key";
111114

112115
/*
113116
* OPTION C: Open network (no security)
114-
*
117+
*
115118
* Open networks have no security, can be connected to by any device that knows the ssid, and are unsafe.
116119
*
117120
* To enable, uncomment #define WIFI_NO_SECURITY below and verify the #define values
@@ -150,4 +153,3 @@ char wep_key[] = "your_wep_key";
150153

151154
// ignore SPI pins, pin 4 (SS for SD-Card on WiFi-shield), pin 7 (WiFi handshake) and pin 10 (WiFi SS)
152155
#define IS_IGNORE_WIFI_SHIELD(p) ((IS_PIN_SPI(p) || (p) == 4) || (p) == 7 || (p) == 10)
153-

utility/WiFi101Stream.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/*
22
* Implementation is in WiFi101Stream.h to avoid linker issues. Legacy WiFi and modern WiFi101 both define WiFiClass which
33
* will cause linker errors whenever Firmata.h is included.
4-
*/
4+
*/

0 commit comments

Comments
 (0)