[gnoduino] Update libraries to Arduino SDK 1.0.3



commit fda9b90d837c1728e53816bb92000fe29a3d8f11
Author: Pascal de Bruijn <pmjdebruijn pcode nl>
Date:   Thu Jan 3 01:51:43 2013 +0100

    Update libraries to Arduino SDK 1.0.3

 libraries/Esplora/Esplora.cpp                      |  175 ++++
 libraries/Esplora/Esplora.h                        |  163 ++++
 .../Esplora/examples/EsploraKart/EsploraKart.ino   |  125 +++
 .../examples/EsploraLedShow/EsploraLedShow.ino     |   42 +
 .../examples/EsploraLedShow2/EsploraLedShow2.ino   |   55 ++
 .../Esplora/examples/EsploraMusic/EsploraMusic.ino |   52 +
 .../examples/EsploraRemote/EsploraRemote.ino       |   94 ++
 .../Esplora/examples/EsploraTable/EsploraTable.ino |  219 +++++
 libraries/Esplora/keywords.txt                     |   68 ++
 .../PachubeClientString/PachubeClientString.ino    |   24 +-
 .../examples/UdpNtpClient/UdpNtpClient.ino         |   11 +-
 libraries/Servo/Servo.h                            |    5 +-
 libraries/SoftwareSerial/SoftwareSerial.cpp        |    7 +-
 .../ConnectNoEncryption/ConnectNoEncryption.ino    |    2 +-
 .../examples/ConnectWithWPA/ConnectWithWPA.ino     |    2 +-
 .../SimpleWebServerWiFi/SimpleWebServerWiFi.ino    |  129 +++
 .../WifiPachubeClient/WifiPachubeClient.ino        |  190 ++++
 .../WifiPachubeClientString.ino                    |  177 ++++
 libraries/WiFi/utility/server_drv.cpp              |  520 ++++++------
 libraries/WiFi/utility/server_drv.h                |   68 +-
 libraries/WiFi/utility/socket.c                    |   40 +-
 libraries/WiFi/utility/socket.h                    |  174 ++--
 libraries/WiFi/utility/spi_drv.h                   |  166 ++--
 libraries/WiFi/utility/wifi_drv.cpp                |  982 ++++++++++----------
 libraries/WiFi/utility/wifi_drv.h                  |  438 +++++-----
 libraries/WiFi/utility/wifi_spi.h                  |  288 +++---
 libraries/WiFi/utility/wl_types.h                  |   62 +-
 27 files changed, 2890 insertions(+), 1388 deletions(-)
---
diff --git a/libraries/EEPROM/EEPROM.cpp b/libraries/EEPROM/EEPROM.cpp
old mode 100755
new mode 100644
diff --git a/libraries/EEPROM/EEPROM.h b/libraries/EEPROM/EEPROM.h
old mode 100755
new mode 100644
diff --git a/libraries/Esplora/Esplora.cpp b/libraries/Esplora/Esplora.cpp
new file mode 100644
index 0000000..83df0d7
--- /dev/null
+++ b/libraries/Esplora/Esplora.cpp
@@ -0,0 +1,175 @@
+/*
+  Esplora.cpp - Arduino Esplora board library
+  Written by Enrico Gueli
+  Copyright (c) 2012 Arduino(TM)  All right reserved.
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+
+#include "Esplora.h"
+
+_Esplora Esplora;
+
+/*
+ * The following constants tell, for each accelerometer
+ * axis, which values are returned when the axis measures
+ * zero acceleration.
+ */
+const int ACCEL_ZERO_X = 320;
+const int ACCEL_ZERO_Y = 330;
+const int ACCEL_ZERO_Z = 310;
+
+const byte MUX_ADDR_PINS[] = { A0, A1, A2, A3 };
+const byte MUX_COM_PIN = A4;
+
+const int JOYSTICK_DEAD_ZONE = 100;
+
+const byte RED_PIN    = 5;
+const byte BLUE_PIN   = 9;
+const byte GREEN_PIN  = 10;
+
+const byte BUZZER_PIN = 6;
+
+// non-multiplexer Esplora pins: 
+// Accelerometer: x-A5, y-A7, z-A6
+// External outputs: D3, D11
+// Buzzer: A8
+// RGB Led: red-D5, green-D10/A11, blue-D9/A10
+// Led 13: D13
+
+const byte ACCEL_X_PIN = A5;
+const byte ACCEL_Y_PIN = A11;
+const byte ACCEL_Z_PIN = A6;
+
+const byte LED_PIN     = 13;
+
+_Esplora::_Esplora() {
+  for (byte p=0; p<4; p++) {
+    pinMode(MUX_ADDR_PINS[p], OUTPUT);
+  }
+  pinMode(RED_PIN, OUTPUT);
+  pinMode(GREEN_PIN, OUTPUT);
+  pinMode(BLUE_PIN, OUTPUT);
+}
+
+unsigned int _Esplora::readChannel(byte channel) {
+  digitalWrite(MUX_ADDR_PINS[0], (channel & 1) ? HIGH : LOW);
+  digitalWrite(MUX_ADDR_PINS[1], (channel & 2) ? HIGH : LOW);
+  digitalWrite(MUX_ADDR_PINS[2], (channel & 4) ? HIGH : LOW);
+  digitalWrite(MUX_ADDR_PINS[3], (channel & 8) ? HIGH : LOW);
+  // workaround to cope with lack of pullup resistor on joystick switch
+  if (channel == CH_JOYSTICK_SW) {
+    pinMode(MUX_COM_PIN, INPUT_PULLUP); 
+    unsigned int joystickSwitchState = (digitalRead(MUX_COM_PIN) == HIGH) ? 1023 : 0;
+    digitalWrite(MUX_COM_PIN, LOW);
+    return joystickSwitchState;
+  }
+  else
+    return analogRead(MUX_COM_PIN);
+}
+
+boolean _Esplora::joyLowHalf(byte joyCh) {
+  return (readChannel(joyCh) < 512 - JOYSTICK_DEAD_ZONE)
+    ? LOW : HIGH;
+}
+
+boolean _Esplora::joyHighHalf(byte joyCh) {
+  return (readChannel(joyCh) > 512 + JOYSTICK_DEAD_ZONE)
+    ? LOW : HIGH;
+}
+
+boolean _Esplora::readButton(byte ch) {
+  if (ch >= SWITCH_1 && ch <= SWITCH_4) {
+    ch--;
+  }
+  
+  switch(ch) {
+  case JOYSTICK_RIGHT:
+    return joyLowHalf(CH_JOYSTICK_X);
+  case JOYSTICK_LEFT:
+    return joyHighHalf(CH_JOYSTICK_X);
+  case JOYSTICK_UP:
+    return joyLowHalf(CH_JOYSTICK_Y);
+  case JOYSTICK_DOWN:
+    return joyHighHalf(CH_JOYSTICK_Y);
+  }
+    
+  unsigned int val = readChannel(ch);
+  return (val > 512) ? HIGH : LOW;
+}
+
+void _Esplora::writeRGB(byte r, byte g, byte b) {
+  writeRed(r);
+  writeGreen(g);
+  writeBlue(b);
+}
+
+#define RGB_FUNC(name, pin, lastVar) \
+void _Esplora::write##name(byte val) { \
+  if (val == lastVar) \
+    return; \
+  analogWrite(pin, val);  \
+  lastVar = val; \
+  delay(5); \
+} \
+\
+byte _Esplora::read##name() { \
+  return lastVar; \
+}
+  
+RGB_FUNC(Red,   RED_PIN,   lastRed)
+RGB_FUNC(Green, GREEN_PIN, lastGreen)
+RGB_FUNC(Blue,  BLUE_PIN,  lastBlue)
+
+void _Esplora::tone(unsigned int freq) {
+  if (freq > 0)
+    ::tone(BUZZER_PIN, freq);
+  else
+    ::noTone(BUZZER_PIN);
+}
+
+void _Esplora::tone(unsigned int freq, unsigned long duration) {
+  if (freq > 0)
+    ::tone(BUZZER_PIN, freq, duration);
+  else
+    ::noTone(BUZZER_PIN);
+}
+
+void _Esplora::noTone() {
+  ::noTone(BUZZER_PIN);
+}
+
+int _Esplora::readTemperature(const byte scale) {
+  long rawT = readChannel(CH_TEMPERATURE);
+  if (scale == DEGREES_C) {
+    return (int)((rawT * 500 / 1024) - 50);
+  }
+  else if (scale == DEGREES_F) {
+    return (int)((rawT * 450 / 512 ) - 58);
+  }
+  else {
+    return readTemperature(DEGREES_C);
+  }
+}
+
+int _Esplora::readAccelerometer(const byte axis) {
+  switch (axis) {
+    case X_AXIS: return analogRead(ACCEL_X_PIN) - ACCEL_ZERO_X;
+    case Y_AXIS: return analogRead(ACCEL_Y_PIN) - ACCEL_ZERO_Y;
+    case Z_AXIS: return analogRead(ACCEL_Z_PIN) - ACCEL_ZERO_Z;
+    default: return 0;
+  }
+}
diff --git a/libraries/Esplora/Esplora.h b/libraries/Esplora/Esplora.h
new file mode 100644
index 0000000..74fa88b
--- /dev/null
+++ b/libraries/Esplora/Esplora.h
@@ -0,0 +1,163 @@
+/*
+  Esplora.h - Arduino Esplora board library
+  Written by Enrico Gueli
+  Copyright (c) 2012 Arduino(TM)  All right reserved.
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#ifndef ESPLORA_H_
+#define ESPLORA_H_
+
+#include "Arduino.h"
+
+/*
+ * The following constants are used internally by the Esplora
+ * library code.
+ */
+
+const byte JOYSTICK_BASE  = 16; // it's a "virtual" channel: its ID won't conflict with real ones
+
+const byte MAX_CHANNELS   = 13;
+
+const byte CH_SWITCH_1    = 0;
+const byte CH_SWITCH_2    = 1;
+const byte CH_SWITCH_3    = 2;
+const byte CH_SWITCH_4    = 3;
+const byte CH_SLIDER      = 4;
+const byte CH_LIGHT       = 5;
+const byte CH_TEMPERATURE = 6;
+const byte CH_MIC         = 7;
+const byte CH_JOYSTICK_SW = 10;
+const byte CH_JOYSTICK_X  = 11;
+const byte CH_JOYSTICK_Y  = 12;
+
+/*
+ * The following constants can be used with the readButton()
+ * method.
+ */
+
+const byte SWITCH_1       = 1;
+const byte SWITCH_2       = 2;
+const byte SWITCH_3       = 3;
+const byte SWITCH_4       = 4;
+
+const byte SWITCH_DOWN  = SWITCH_1;
+const byte SWITCH_LEFT  = SWITCH_2;
+const byte SWITCH_UP    = SWITCH_3;
+const byte SWITCH_RIGHT = SWITCH_4;
+
+const byte JOYSTICK_DOWN  = JOYSTICK_BASE;
+const byte JOYSTICK_LEFT  = JOYSTICK_BASE+1;
+const byte JOYSTICK_UP    = JOYSTICK_BASE+2;
+const byte JOYSTICK_RIGHT = JOYSTICK_BASE+3;
+
+/*
+ * These constants can be use for comparison with the value returned
+ * by the readButton() method.
+ */
+const boolean PRESSED   = LOW;
+const boolean RELEASED  = HIGH;
+
+/*
+ * The following constants can be used with the readTemperature()
+ * method to specify the desired scale.
+ */
+const byte DEGREES_C = 0;
+const byte DEGREES_F = 1;
+
+/*
+ * The following constants can be used with the readAccelerometer()
+ * method to specify the desired axis to return.
+ */
+const byte X_AXIS = 0;
+const byte Y_AXIS = 1;
+const byte Z_AXIS = 2;
+
+
+class _Esplora {
+private:
+  byte lastRed;
+  byte lastGreen;
+  byte lastBlue;
+
+  unsigned int readChannel(byte channel);    
+  
+  boolean joyLowHalf(byte joyCh);
+  boolean joyHighHalf(byte joyCh);
+    
+public:
+  _Esplora();
+  
+  /*
+   * Returns a number corresponding to the position of the
+   * linear potentiometer. 0 means full right, 1023 means
+   * full left.
+   */
+  inline unsigned int readSlider() { return readChannel(CH_SLIDER); }
+
+  /*
+   * Returns a number corresponding to the amount of ambient
+   * light sensed by the light sensor.
+   */
+  inline unsigned int readLightSensor() { return readChannel(CH_LIGHT); }
+
+  /*
+   * Returns the current ambient temperature, expressed either in Celsius
+   * or Fahreneit scale.
+   */
+  int readTemperature(const byte scale);
+
+  /*
+   * Returns a number corresponding to the amount of ambient noise.
+   */
+  inline unsigned int readMicrophone() { return readChannel(CH_MIC); }
+  
+  inline unsigned int readJoystickSwitch() { return readChannel(CH_JOYSTICK_SW); }
+
+  inline int readJoystickX() { 
+    return readChannel(CH_JOYSTICK_X) - 512;
+  }
+  inline int readJoystickY() {
+    return readChannel(CH_JOYSTICK_Y) - 512;
+  }
+
+  int readAccelerometer(const byte axis);
+  
+  /*
+   * Reads the current state of a button. It will return
+   * LOW if the button is pressed, and HIGH otherwise.
+   */
+  boolean readButton(byte channel);
+  
+  void writeRGB(byte red, byte green, byte blue);
+  void writeRed(byte red);
+  void writeGreen(byte green);
+  void writeBlue(byte blue);
+
+  byte readRed();
+  byte readGreen();
+  byte readBlue();
+  
+  void tone(unsigned int freq);
+  void tone(unsigned int freq, unsigned long duration);
+  void noTone();
+};
+
+
+
+extern _Esplora Esplora;
+
+#endif // ESPLORA_H_
diff --git a/libraries/Esplora/examples/EsploraKart/EsploraKart.ino b/libraries/Esplora/examples/EsploraKart/EsploraKart.ino
new file mode 100644
index 0000000..4c1621c
--- /dev/null
+++ b/libraries/Esplora/examples/EsploraKart/EsploraKart.ino
@@ -0,0 +1,125 @@
+/*
+  Esplora Kart
+
+  This sketch turns the Esplora into a PC game pad.
+
+  It uses the both the analog joystick and the four switches.
+  By moving the joystick in a direction or by pressing a switch,
+  the PC will "see" that a key is pressed. If the PC is running
+  a game that has keyboard input, the Esplora can control it.
+  
+  The default configuration is suitable for SuperTuxKart, an
+  open-source racing game. It can be downloaded from
+  http://supertuxkart.sourceforge.net/ .
+
+  Created on 22 november 2012
+  By Enrico Gueli <enrico gueli gmail com>
+*/
+
+
+#include <Esplora.h>
+
+/*
+  You're going to handle eight different buttons. You'll use arrays, 
+  which are ordered lists of variables with a fixed size. Each array 
+  has an index (counting from 0) to keep track of the position
+  you're reading in the array, and each position can contain a number.
+ 
+  This code uses three different arrays: one for the buttons you'll read;
+  a second to hold the current states of those buttons; and a third to hold
+  the keystrokes associated with each button.
+ */
+
+/*
+  This array holds the last sensed state of each of the buttons
+  you're reading.
+  Later in the code, you'll read the button states, and compare them
+  to the previous states that are stored in this array. If the two
+  states are different, it means that the button was either
+  pressed or released.
+ */
+boolean buttonStates[8];
+
+/*
+  This array holds the names of the buttons being read.
+  Later in the sketch, you'll use these names with
+  the method Esplora.readButton(x), where x
+  is one of these buttons.
+ */
+const byte buttons[] = {
+  JOYSTICK_DOWN,
+  JOYSTICK_LEFT,
+  JOYSTICK_UP,
+  JOYSTICK_RIGHT,
+  SWITCH_RIGHT, // fire
+  SWITCH_LEFT, // bend
+  SWITCH_UP, // nitro
+  SWITCH_DOWN, // look back
+};
+
+/*
+  This array tells what keystroke to send to the PC when a
+  button is pressed.
+  If you look at this array and the above one, you can see that
+  the "cursor down" keystroke is sent when the joystick is moved
+  down, the "cursor up" keystroke when the joystick is moved up
+  and so on.
+*/
+const char keystrokes[] = {
+  KEY_DOWN_ARROW,
+  KEY_LEFT_ARROW,
+  KEY_UP_ARROW,
+  KEY_RIGHT_ARROW,
+  ' ',
+  'V',
+  'N',
+  'B'
+};
+
+/*
+  This is code is run only at startup, to initialize the
+  virtual USB keyboard.
+*/
+void setup() {
+  Keyboard.begin();
+}
+
+/*
+  After setup() is finished, this code is run continuously.
+  Here we continuously check if something happened with the
+  buttons.
+*/
+void loop() { 
+  
+  // Iterate through all the buttons:
+  for (byte thisButton=0; thisButton<8; thisButton++) {
+    boolean lastState = buttonStates[thisButton];
+    boolean newState = Esplora.readButton(buttons[thisButton]);
+    if (lastState != newState) { // Something changed!
+      /* 
+        The Keyboard library allows you to "press" and "release" the
+        keys as two distinct actions. These actions can be
+        linked to the buttons we're handling.
+       */
+      if (newState == PRESSED) {
+        Keyboard.press(keystrokes[thisButton]);
+      }
+      else if (newState == RELEASED) {
+        Keyboard.release(keystrokes[thisButton]);
+      }
+    }
+
+    // Store the new button state, so you can sense a difference later:
+    buttonStates[thisButton] = newState;
+  }
+  
+  /*
+    Wait a little bit (50ms) between a check and another.
+    When a mechanical switch is pressed or released, the
+    contacts may bounce very rapidly. If the check is done too
+    fast, these bounces may be confused as multiple presses and
+    may lead to unexpected behaviour.
+   */
+  delay(50);
+}
+
diff --git a/libraries/Esplora/examples/EsploraLedShow/EsploraLedShow.ino b/libraries/Esplora/examples/EsploraLedShow/EsploraLedShow.ino
new file mode 100644
index 0000000..84f049a
--- /dev/null
+++ b/libraries/Esplora/examples/EsploraLedShow/EsploraLedShow.ino
@@ -0,0 +1,42 @@
+/*
+  Esplora LED Show
+
+  Makes the RGB LED bright and glow as the joystick or the
+  slider are moved.
+  
+  Created on 22 november 2012
+  By Enrico Gueli <enrico gueli gmail com>
+  Modified 24 Nov 2012
+  by Tom Igoe
+*/
+#include <Esplora.h>
+
+void setup() {
+  // initialize the serial communication:
+  Serial.begin(9600);
+}
+
+void loop() {
+  // read the sensors into variables:
+  int xAxis = Esplora.readJoystickX();
+  int yAxis = Esplora.readJoystickY();
+  int slider = Esplora.readSlider();
+  
+  // convert the sensor readings to light levels:
+  byte red   = map(xAxis, -512, 512, 0, 255);
+  byte green = map(xAxis, -512, 512, 0, 255);
+  byte blue  = slider/4;
+ 
+  // print the light levels:
+  Serial.print(red);
+  Serial.print(' ');
+  Serial.print(green);
+  Serial.print(' ');
+  Serial.println(blue);
+
+  // write the light levels to the LED. 
+  Esplora.writeRGB(red, green, blue);
+
+  // add a delay to keep the LED from flickering:  
+  delay(10);
+}
diff --git a/libraries/Esplora/examples/EsploraLedShow2/EsploraLedShow2.ino b/libraries/Esplora/examples/EsploraLedShow2/EsploraLedShow2.ino
new file mode 100644
index 0000000..8f9f8a2
--- /dev/null
+++ b/libraries/Esplora/examples/EsploraLedShow2/EsploraLedShow2.ino
@@ -0,0 +1,55 @@
+/*
+  Esplora Led/Microphone
+
+  This simple sketch reads the microphone, light sensor, and slider.
+  Then it uses those readings to set the brightness of red, green and blue
+  channels of the RGB LED. The red channel will change with the loudness
+  "heared" by the microphone, the green channel changes as the
+  amount of light in the room and the blue channel will change
+  with the position of the slider.
+
+  Created on 22 november 2012
+  By Enrico Gueli <enrico gueli gmail com>
+  Modified 24 Nov 2012
+  by Tom Igoe
+*/
+
+#include <Esplora.h>
+
+void setup() {
+  // initialize the serial communication:
+  Serial.begin(9600);
+}
+
+int lowLight = 400;   // the light sensor reading when it's covered
+int highLight = 1023; // the maximum light sensor reading 
+int minGreen = 0;     // minimum brightness of the green LED
+int maxGreen = 100;   // maximum brightness of the green LED
+
+void loop() {
+  // read the sensors into variables:
+  int mic = Esplora.readMicrophone();
+  int light = Esplora.readLightSensor();
+  int slider = Esplora.readSlider();
+  
+  // convert the sensor readings to light levels:
+  byte red   = constrain(mic, 0, 255);
+  byte green = constrain(
+                  map(light, lowLight, highLight, minGreen, maxGreen),
+                  0, 255);
+  byte blue  = slider/4;
+
+  // print the light levels (to see what's going on):
+  Serial.print(red);
+  Serial.print(' ');
+  Serial.print(green);
+  Serial.print(' ');
+  Serial.println(blue);
+
+  // write the light levels to the LED. 
+  // note that the green value is always 0:
+  Esplora.writeRGB(red, green, blue);
+  
+  // add a delay to keep the LED from flickering:
+  delay(10); 
+}
diff --git a/libraries/Esplora/examples/EsploraMusic/EsploraMusic.ino b/libraries/Esplora/examples/EsploraMusic/EsploraMusic.ino
new file mode 100644
index 0000000..10c17f7
--- /dev/null
+++ b/libraries/Esplora/examples/EsploraMusic/EsploraMusic.ino
@@ -0,0 +1,52 @@
+/*
+  Esplora Music
+
+  This sketch turns the Esplora in a simple musical instrument.
+  Press the Switch 1 and move the slider to see how it works.
+
+  Created on 22 november 2012
+  By Enrico Gueli <enrico gueli gmail com>
+  modified 24 Nov 2012
+  by Tom Igoe
+*/
+
+
+#include <Esplora.h>
+
+
+const int note[] = {
+262, // C
+277, // C#
+294, // D
+311, // D#
+330, // E
+349, // F
+370, // F#
+392, // G
+415, // G#
+440, // A
+466, // A#
+494, // B
+523  // C next octave
+};
+
+void setup() {
+}
+
+void loop() {
+  // read the button labeled SWITCH_DOWN. If it's low,
+  // then play a note:
+  if (Esplora.readButton(SWITCH_DOWN) == LOW) {
+    int slider = Esplora.readSlider();
+    
+    // use map() to map the slider's range to the 
+    // range of notes you have:
+    byte thisNote = map(slider, 0, 1023, 0, 13);
+    // play the note corresponding to the slider's position:
+    Esplora.tone(note[thisNote]);
+  }
+  else {
+    // if the button isn't pressed, turn the note off:
+    Esplora.noTone();
+  }
+}
diff --git a/libraries/Esplora/examples/EsploraRemote/EsploraRemote.ino b/libraries/Esplora/examples/EsploraRemote/EsploraRemote.ino
new file mode 100644
index 0000000..135b26a
--- /dev/null
+++ b/libraries/Esplora/examples/EsploraRemote/EsploraRemote.ino
@@ -0,0 +1,94 @@
+/*
+  Esplora Slave
+
+  This sketch allows to test all the Esplora's peripherals.
+  It is also used with the ProcessingStart sketch (for Processing).
+  
+  When uploaded, you can open the Serial monitor and write one of
+  the following commands (without quotes) to get an answer:
+  
+  "D": prints the current value of all sensors, separated by a comma.
+       See the dumpInputs() function below to get the meaning of
+       each value.
+       
+  "Rxxx"
+  "Gxxx"
+  "Bxxx": set the color of the RGB led. For example, write "R255"
+          to turn on the red to full brightness, "G128" to turn
+          the green to half brightness, or "G0" to turn off
+          the green channel.
+  
+  "Txxxx": play a tone with the buzzer. The number is the
+           frequency, e.g. "T440" plays the central A note.
+           Write "T0" to turn off the buzzer.
+  
+
+  Created on 22 november 2012
+  By Enrico Gueli <enrico gueli gmail com>
+*/
+
+#include <Esplora.h>
+
+void setup() {
+  while(!Serial); // needed for Leonardo-based board like Esplora
+  Serial.begin(9600);
+}
+
+void loop() {
+  if (Serial.available())
+    parseCommand();
+}
+
+/*
+ * This function reads a character from the serial line and
+ * decide what to do next. The "what to do" part is given by
+ * function it calls (e.g. dumpInputs(), setRed() and so on).
+ */
+void parseCommand() {
+  char cmd = Serial.read();
+  switch(cmd) {
+    case 'D': dumpInputs(); break;
+    case 'R': setRed(); break;
+    case 'G': setGreen(); break;
+    case 'B': setBlue(); break;
+    case 'T': setTone(); break;
+  }
+}
+
+void dumpInputs() {  
+  /*
+   * please note: a single row contains two instructions.
+   * one is to print the sensor value, the other to print the
+   * comma symbol.
+   */
+  Serial.print(Esplora.readButton(SWITCH_1)); Serial.print(',');
+  Serial.print(Esplora.readButton(SWITCH_2)); Serial.print(',');
+  Serial.print(Esplora.readButton(SWITCH_3)); Serial.print(',');
+  Serial.print(Esplora.readButton(SWITCH_4)); Serial.print(',');
+  Serial.print(Esplora.readSlider());         Serial.print(',');
+  Serial.print(Esplora.readLightSensor());    Serial.print(',');
+  Serial.print(Esplora.readTemperature(DEGREES_C)); Serial.print(',');
+  Serial.print(Esplora.readMicrophone());     Serial.print(',');
+  Serial.print(Esplora.readJoystickSwitch()); Serial.print(',');
+  Serial.print(Esplora.readJoystickX());      Serial.print(',');
+  Serial.print(Esplora.readJoystickY());      Serial.print(',');
+  Serial.print(Esplora.readAccelerometer(X_AXIS)); Serial.print(',');
+  Serial.print(Esplora.readAccelerometer(Y_AXIS)); Serial.print(',');
+  Serial.print(Esplora.readAccelerometer(Z_AXIS)); Serial.println();
+}
+
+void setRed() {
+  Esplora.writeRed(Serial.parseInt());
+}
+
+void setGreen() {
+  Esplora.writeGreen(Serial.parseInt());
+}
+
+void setBlue() {
+  Esplora.writeBlue(Serial.parseInt());
+}
+
+void setTone() {
+  Esplora.tone(Serial.parseInt());
+}
diff --git a/libraries/Esplora/examples/EsploraTable/EsploraTable.ino b/libraries/Esplora/examples/EsploraTable/EsploraTable.ino
new file mode 100644
index 0000000..73d5652
--- /dev/null
+++ b/libraries/Esplora/examples/EsploraTable/EsploraTable.ino
@@ -0,0 +1,219 @@
+/*
+  Esplora Table
+
+  Acts like a keyboard that prints some of its sensors'
+  data in a table-like text, row by row.
+  It is a sort of "data-logger".
+  
+  At startup, it does nothing. It just waits for you to open a
+  spreadsheet (e.g. Google Drive spreadsheet) so it can put its
+  data. Then, by pressing Switch 1, it starts printing the table
+  headers and the first row of data. It waits a bit, then it
+  will print another row, and so on.
+  
+  The amount of time between each row is given by the slider.
+  If put to full left, the sketch will wait 10 seconds; at
+  full right position, it will wait 5 minutes. An intermediate
+  position will make the sketch wait for some time in-between.
+  
+  Clicking the Switch 1 at any time will stop the logging.
+
+  The color LED shows what the sketch is doing:
+  blue  = idle, waiting for you to press Switch 1 to start logging
+  green = active; will print soon
+  red   = printing data to the PC
+
+  Created on 22 november 2012
+  By Enrico Gueli <enrico gueli gmail com>
+  modified 24 Nov 2012
+  by Tom Igoe
+*/
+
+#include <Esplora.h>
+
+/*
+ * this variable tells if the data-logging is currently active.
+ */
+boolean active = false;
+
+/*
+ * this variable holds the time in the future when the sketch
+ * will "sample" the data (sampling is the act of reading some
+ * input at a known time). This variable is checked continuously
+ * against millis() to know when it's time to sample.
+ */
+unsigned long nextSampleAt = 0;
+
+/*
+ * This variable just holds the millis() value at the time the
+ * logging was activated. This is needed to enter the correct
+ * value in the "Time" column in the printed table.
+ */
+unsigned long startedAt = 0;
+
+
+/*
+ * when the "active" variable is set to true, the same is done
+ * with this variable. This is needed because the code that does
+ * the "just-after-activation" stuff is run some time later than
+ * the code that says "be active now".
+ */
+boolean justActivated = false;
+
+
+/*
+ * this variable holds the last sensed status of the switch press
+ * button. If the code sees a difference between the value of
+ * this variable and the current status of the switch, it means
+ * that the button was either pressed or released.
+ */
+boolean lastStartBtn = HIGH;
+
+/*
+ * Initialization code. The virtual USB keyboard must be
+ * initialized; the Serial class is needed just for debugging.
+ */
+void setup() {
+  Keyboard.begin();
+  Serial.begin(9600);
+}
+
+/*
+ * This code is run continuously.
+ */
+void loop() {
+  /*
+   * note: we don't use Arduino's delay() here, because we can't
+   * normally do anything while delaying. Our own version lets us
+   * check for button presses often enough to not miss any event.
+   */
+  activeDelay(50);
+ 
+  /*
+   * the justActivated variable may be set to true in the
+   * checkSwitchPress() function. Here we check its status to
+   * print the table headers and configure what's needed to.
+   */
+  if (justActivated == true) {
+    justActivated = false; // do this just once
+    printHeaders();
+    // do next sampling ASAP
+    nextSampleAt = startedAt = millis();
+  }
+  
+  if (active == true) {
+    if (nextSampleAt < millis()) {
+      // it's time to sample!
+      int slider = Esplora.readSlider();
+      // the row below maps the slider position to a range between
+      // 10 and 290 seconds.
+      int sampleInterval = map(slider, 0, 1023, 10, 290);
+      nextSampleAt = millis() + sampleInterval * 1000;
+      
+      logAndPrint();
+    }
+    
+    // let the RGB led blink green once per second, for 200ms.
+    unsigned int ms = millis() % 1000;
+    if (ms < 200)
+      Esplora.writeGreen(50);
+    else
+      Esplora.writeGreen(0);
+    
+    Esplora.writeBlue(0);
+  } 
+  else
+    // while not active, keep a reassuring blue color coming
+    // from the Esplora...
+    Esplora.writeBlue(20);
+    
+}
+
+/*
+ * Print the table headers.
+ */
+void printHeaders() {
+  Keyboard.print("Time");
+  Keyboard.write(KEY_TAB);
+  activeDelay(300); // Some spreadsheets are slow, e.g. Google
+                    // Drive that wants to save every edit.
+  Keyboard.print("Accel X");
+  Keyboard.write(KEY_TAB);
+  activeDelay(300);
+  Keyboard.print("Accel Y");
+  Keyboard.write(KEY_TAB);
+  activeDelay(300);
+  Keyboard.print("Accel Z");
+  Keyboard.println();
+  activeDelay(300);
+}
+
+void logAndPrint() {
+  // do all the samplings at once, because keystrokes have delays
+  unsigned long timeSecs = (millis() - startedAt) /1000;
+  int xAxis = Esplora.readAccelerometer(X_AXIS);
+  int yAxis = Esplora.readAccelerometer(Y_AXIS);
+  int zAxis = Esplora.readAccelerometer(Z_AXIS);
+  
+  Esplora.writeRed(100);
+  
+  Keyboard.print(timeSecs);
+  Keyboard.write(KEY_TAB);
+  activeDelay(300);
+  Keyboard.print(xAxis);
+  Keyboard.write(KEY_TAB);
+  activeDelay(300);
+  Keyboard.print(yAxis);
+  Keyboard.write(KEY_TAB);
+  activeDelay(300);
+  Keyboard.print(zAxis);
+  Keyboard.println();
+  activeDelay(300);
+  Keyboard.write(KEY_HOME);
+  
+  Esplora.writeRed(0);
+}
+
+/**
+ * Similar to delay(), but allows to do something else
+ * in the meanwhile. In particular, it calls waitLoop().
+ * Note 1: it may wait longer than the specified amount, not less;
+ * Note 2: beware of data synchronization issues, e.g. if the
+ * whileWaiting() function alters some variables used by the
+ * caller of this function.
+ *
+ * I discovered by chance that there's an ongoing discussion about
+ * adding yield() in the Arduino API:
+ * http://comments.gmane.org/gmane.comp.hardware.arduino.devel/1381
+ * The purpose is the same, but for now I'm using this implementation.
+ */
+void activeDelay(unsigned long amount) {
+  unsigned long at = millis() + amount;
+  while (millis() < at) {
+    checkSwitchPress();
+  }
+}
+
+/*
+ * This function reads the status of the switch; if it sees that
+ * it was pressed, toggles the status of the "active" variable.
+ * If it's set to true, also the justActivated variable is set to
+ * true, so the loop() function above can do the right things.
+ * This function should be called as often as possible and do as
+ * little as possible, because it can be called while another
+ * function is running.
+ */
+void checkSwitchPress() {
+  boolean startBtn = Esplora.readButton(SWITCH_DOWN);
+
+  if (startBtn != lastStartBtn) {
+    if (startBtn == HIGH) { // button released
+      active = !active;
+      if (active)
+        justActivated = true;    
+    }
+    
+    lastStartBtn = startBtn;
+  }
+}
+
diff --git a/libraries/Esplora/keywords.txt b/libraries/Esplora/keywords.txt
new file mode 100644
index 0000000..02ba660
--- /dev/null
+++ b/libraries/Esplora/keywords.txt
@@ -0,0 +1,68 @@
+#######################################
+# Syntax Coloring Map For Esplora
+####################################### 
+# Class
+#######################################
+
+Esplora	KEYWORD3
+
+#######################################
+# Methods and Functions 
+#######################################	
+
+begin	KEYWORD2
+readSlider	KEYWORD2
+readLightSensor	KEYWORD2
+readTemperature	KEYWORD2
+readMicrophone	KEYWORD2
+readJoystickSwitch	KEYWORD2
+readJoystickX	KEYWORD2
+readJoystickY	KEYWORD2
+readAccelerometer	KEYWORD2
+readButton	KEYWORD2
+writeRGB	KEYWORD2
+writeRed	KEYWORD2
+writeGreen	KEYWORD2
+writeBlue	KEYWORD2
+readRed	KEYWORD2
+readGreen	KEYWORD2
+readBlue	KEYWORD2
+tone	KEYWORD2
+noTone	KEYWORD2
+
+
+#######################################
+# Constants
+#######################################
+ 
+JOYSTICK_BASE	LITERAL1
+MAX_CHANNELS	LITERAL1
+CH_SWITCH_1	LITERAL1
+CH_SWITCH_2	LITERAL1
+CH_SWITCH_3	LITERAL1
+CH_SWITCH_4	LITERAL1
+CH_SLIDER	LITERAL1
+CH_LIGHT	LITERAL1
+CH_TEMPERATURE	LITERAL1
+CH_MIC	LITERAL1
+CH_JOYSTICK_SW	LITERAL1
+CH_JOYSTICK_X	LITERAL1
+CH_JOYSTICK_Y	LITERAL1
+SWITCH_1	LITERAL1
+SWITCH_2	LITERAL1
+SWITCH_3	LITERAL1
+SWITCH_4	LITERAL1
+SWITCH_DOWN	LITERAL1
+SWITCH_LEFT	LITERAL1
+SWITCH_UP	LITERAL1
+SWITCH_RIGHT	LITERAL1
+JOYSTICK_DOWN	LITERAL1
+JOYSTICK_LEFT	LITERAL1
+JOYSTICK_UP	LITERAL1
+PRESSED	LITERAL1
+RELEASED	LITERAL1
+DEGREES_C	LITERAL1
+DEGREES_F	LITERAL1
+X_AXIS	LITERAL1
+Y_AXIS	LITERAL1
+Z_AXIS	LITERAL1
diff --git a/libraries/Ethernet/Dhcp.cpp b/libraries/Ethernet/Dhcp.cpp
old mode 100755
new mode 100644
diff --git a/libraries/Ethernet/Dhcp.h b/libraries/Ethernet/Dhcp.h
old mode 100755
new mode 100644
diff --git a/libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino b/libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino
index 2a96e9f..26472d1 100644
--- a/libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino
+++ b/libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino
@@ -1,12 +1,12 @@
 /*
-  Cosm sensor client with Strings
+  Pachube sensor client with Strings
  
- This sketch connects an analog sensor to Cosm (http://www.cosm.com)
+ This sketch connects an analog sensor to Pachube (http://www.pachube.com)
  using a Wiznet Ethernet shield. You can use the Arduino Ethernet shield, or
  the Adafruit Ethernet shield, either one will work, as long as it's got
  a Wiznet Ethernet module on board.
  
- This example has been updated to use version 2.0 of the Cosm.com API. 
+ This example has been updated to use version 2.0 of the pachube.com API. 
  To make it work, create a feed with two datastreams, and give them the IDs
  sensor1 and sensor2. Or change the code below to match your feed.
  
@@ -20,8 +20,10 @@
  created 15 March 2010
  modified 9 Apr 2012
  by Tom Igoe with input from Usman Haque and Joe Saavedra
+ modified 8 September 2012
+ by Scott Fitzgerald
  
- http://arduino.cc/en/Tutorial/CosmClientString
+ http://arduino.cc/en/Tutorial/PachubeClientString
  This code is in the public domain.
  
  */
@@ -30,7 +32,7 @@
 #include <Ethernet.h>
 
 
-/#define APIKEY         "YOUR API KEY GOES HERE" // replace your Cosm api key here
+#define APIKEY         "YOUR API KEY GOES HERE" // replace your Pachube api key here
 #define FEEDID         00000 // replace your feed ID
 #define USERAGENT      "My Project" // user agent is the project name
 
@@ -49,12 +51,12 @@ EthernetClient client;
 
 // if you don't want to use DNS (and reduce your sketch size)
 // use the numeric IP instead of the name for the server:
-IPAddress server(216,52,233,121);      // numeric IP for api.cosm.com
-//char server[] = "api.cosm.com";   // name address for Cosm API
+IPAddress server(216,52,233,121);      // numeric IP for api.pachube.com
+//char server[] = "api.pachube.com";   // name address for pachube API
 
 unsigned long lastConnectionTime = 0;          // last time you connected to the server, in milliseconds
 boolean lastConnected = false;                 // state of the connection last time through the main loop
-const unsigned long postingInterval = 10*1000;  //delay between updates to Cosm.com
+const unsigned long postingInterval = 10*1000;  //delay between updates to pachube.com
 
 void setup() {
  // Open serial communications and wait for port to open:
@@ -83,7 +85,7 @@ void loop() {
   dataString += sensorReading;
 
   // you can append multiple readings to this String if your
-  // Cosm feed is set up to handle multiple values:
+  // pachube feed is set up to handle multiple values:
   int otherSensorReading = analogRead(A1);
   dataString += "\nsensor2,";
   dataString += otherSensorReading;
@@ -123,8 +125,8 @@ void sendData(String thisData) {
     client.print("PUT /v2/feeds/");
     client.print(FEEDID);
     client.println(".csv HTTP/1.1");
-    client.println("Host: api.cosm.com");
-    client.print("X-CosmApiKey: ");
+    client.println("Host: api.pachube.com");
+    client.print("X-pachubeApiKey: ");
     client.println(APIKEY);
     client.print("User-Agent: ");
     client.println(USERAGENT);
diff --git a/libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino b/libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino
index 93ffe39..6b3b53d 100644
--- a/libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino
+++ b/libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino
@@ -7,6 +7,13 @@
  For more on NTP time servers and the messages needed to communicate with them, 
  see http://en.wikipedia.org/wiki/Network_Time_Protocol
  
+ Warning: NTP Servers are subject to temporary failure or IP address change.
+ Plese check 
+
+    http://tf.nist.gov/tf-cgi/servers.cgi
+
+ if the time server used in the example didn't work.
+
  created 4 Sep 2010 
  by Michael Margolis
  modified 9 Apr 2012
@@ -27,7 +34,9 @@ byte mac[] = {
 
 unsigned int localPort = 8888;      // local port to listen for UDP packets
 
-IPAddress timeServer(192, 43, 244, 18); // time.nist.gov NTP server
+IPAddress timeServer(132, 163, 4, 101); // time-a.timefreq.bldrdoc.gov NTP server
+// IPAddress timeServer(132, 163, 4, 102); // time-b.timefreq.bldrdoc.gov NTP server
+// IPAddress timeServer(132, 163, 4, 103); // time-c.timefreq.bldrdoc.gov NTP server
 
 const int NTP_PACKET_SIZE= 48; // NTP time stamp is in the first 48 bytes of the message
 
diff --git a/libraries/Ethernet/utility/socket.h b/libraries/Ethernet/utility/socket.h
old mode 100755
new mode 100644
diff --git a/libraries/Ethernet/utility/w5100.h b/libraries/Ethernet/utility/w5100.h
old mode 100755
new mode 100644
diff --git a/libraries/LiquidCrystal/LiquidCrystal.h b/libraries/LiquidCrystal/LiquidCrystal.h
old mode 100755
new mode 100644
diff --git a/libraries/LiquidCrystal/keywords.txt b/libraries/LiquidCrystal/keywords.txt
old mode 100755
new mode 100644
diff --git a/libraries/Servo/Servo.cpp b/libraries/Servo/Servo.cpp
old mode 100755
new mode 100644
diff --git a/libraries/Servo/Servo.h b/libraries/Servo/Servo.h
old mode 100755
new mode 100644
index bf3e012..8168494
--- a/libraries/Servo/Servo.h
+++ b/libraries/Servo/Servo.h
@@ -65,9 +65,8 @@
 typedef enum { _timer5, _timer1, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t ;
 
 #elif defined(__AVR_ATmega32U4__)  
-#define _useTimer3
 #define _useTimer1 
-typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ;
+typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ;
 
 #elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
 #define _useTimer3
@@ -124,4 +123,4 @@ private:
    int8_t max;                       // maximum is this value times 4 added to MAX_PULSE_WIDTH   
 };
 
-#endif
\ No newline at end of file
+#endif
diff --git a/libraries/Servo/keywords.txt b/libraries/Servo/keywords.txt
old mode 100755
new mode 100644
diff --git a/libraries/SoftwareSerial/SoftwareSerial.cpp b/libraries/SoftwareSerial/SoftwareSerial.cpp
old mode 100755
new mode 100644
index c15bdda..64496fe
--- a/libraries/SoftwareSerial/SoftwareSerial.cpp
+++ b/libraries/SoftwareSerial/SoftwareSerial.cpp
@@ -40,8 +40,8 @@ http://arduiniana.org.
 // 
 #include <avr/interrupt.h>
 #include <avr/pgmspace.h>
-#include "Arduino.h"
-#include "SoftwareSerial.h"
+#include <Arduino.h>
+#include <SoftwareSerial.h>
 //
 // Lookup table
 //
@@ -70,6 +70,7 @@ static const DELAY_TABLE PROGMEM table[] =
   { 4800,     233,       474,       474,      471,   },
   { 2400,     471,       950,       950,      947,   },
   { 1200,     947,       1902,      1902,     1899,  },
+  { 600,      1902,      3804,      3804,     3800,  },
   { 300,      3804,      7617,      7617,     7614,  },
 };
 
@@ -91,6 +92,7 @@ static const DELAY_TABLE table[] PROGMEM =
   { 4800,     110,        233,       233,    230,    },
   { 2400,     229,        472,       472,    469,    },
   { 1200,     467,        948,       948,    945,    },
+  { 600,      948,        1895,      1895,   1890,   },
   { 300,      1895,       3805,      3805,   3802,   },
 };
 
@@ -115,6 +117,7 @@ static const DELAY_TABLE PROGMEM table[] =
   { 4800,     296,        595,       595,    592,    },
   { 2400,     592,        1189,      1189,   1186,   },
   { 1200,     1187,       2379,      2379,   2376,   },
+  { 600,      2379,       4759,      4759,   4755,   },
   { 300,      4759,       9523,      9523,   9520,   },
 };
 
diff --git a/libraries/SoftwareSerial/SoftwareSerial.h b/libraries/SoftwareSerial/SoftwareSerial.h
old mode 100755
new mode 100644
diff --git a/libraries/SoftwareSerial/keywords.txt b/libraries/SoftwareSerial/keywords.txt
old mode 100755
new mode 100644
diff --git a/libraries/WiFi/examples/ConnectNoEncryption/ConnectNoEncryption.ino b/libraries/WiFi/examples/ConnectNoEncryption/ConnectNoEncryption.ino
index 81cc5cb..f42a7f3 100644
--- a/libraries/WiFi/examples/ConnectNoEncryption/ConnectNoEncryption.ino
+++ b/libraries/WiFi/examples/ConnectNoEncryption/ConnectNoEncryption.ino
@@ -12,7 +12,7 @@
  modified 31 May 2012
  by Tom Igoe
  */
-#include <WiFi.h>
+ #include <WiFi.h>
 
 char ssid[] = "yourNetwork";     // the name of your network
 int status = WL_IDLE_STATUS;     // the Wifi radio's status
diff --git a/libraries/WiFi/examples/ConnectWithWPA/ConnectWithWPA.ino b/libraries/WiFi/examples/ConnectWithWPA/ConnectWithWPA.ino
index cfd2d0a..fcc33ec 100644
--- a/libraries/WiFi/examples/ConnectWithWPA/ConnectWithWPA.ino
+++ b/libraries/WiFi/examples/ConnectWithWPA/ConnectWithWPA.ino
@@ -12,7 +12,7 @@
  modified 31 May 2012
  by Tom Igoe
  */
-#include <WiFi.h>
+ #include <WiFi.h>
 
 char ssid[] = "yourNetwork";     //  your network SSID (name) 
 char pass[] = "secretPassword";  // your network password
diff --git a/libraries/WiFi/examples/SimpleWebServerWiFi/SimpleWebServerWiFi.ino b/libraries/WiFi/examples/SimpleWebServerWiFi/SimpleWebServerWiFi.ino
new file mode 100644
index 0000000..cdb4e62
--- /dev/null
+++ b/libraries/WiFi/examples/SimpleWebServerWiFi/SimpleWebServerWiFi.ino
@@ -0,0 +1,129 @@
+/*
+  WiFi Web Server LED Blink
+ 
+ A simple web server that lets you blink an LED via the web.
+ This sketch will print the IP address of your WiFi Shield (once connected)
+ to the Serial monitor. From there, you can open that address in a web browser
+ to turn on and off the LED on pin 9.
+ 
+ If the IP address of your shield is yourAddress:
+ http://yourAddress/H turns the LED on
+ http://yourAddress/L turns it off
+ 
+ This example is written for a network using WPA encryption. For 
+ WEP or WPA, change the Wifi.begin() call accordingly.
+ 
+ Circuit:
+ * WiFi shield attached
+ * LED attached to pin 9
+ 
+ created 25 Nov 2012
+ by Tom Igoe
+ */
+#include <SPI.h>
+#include <WiFi.h>
+
+char ssid[] = "yourNetwork";      //  your network SSID (name) 
+char pass[] = "secretPassword";   // your network password
+int keyIndex = 0;                 // your network key Index number (needed only for WEP)
+
+int status = WL_IDLE_STATUS;
+WiFiServer server(80);
+
+void setup() {
+  Serial.begin(9600);      // initialize serial communication
+  pinMode(9, OUTPUT);      // set the LED pin mode
+
+  // check for the presence of the shield:
+  if (WiFi.status() == WL_NO_SHIELD) {
+    Serial.println("WiFi shield not present"); 
+    while(true);        // don't continue
+  } 
+
+  // attempt to connect to Wifi network:
+  while ( status != WL_CONNECTED) { 
+    Serial.print("Attempting to connect to Network named: ");
+    Serial.println(ssid);                   // print the network name (SSID);
+
+    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:    
+    status = WiFi.begin(ssid, pass);
+    // wait 10 seconds for connection:
+    delay(10000);
+  } 
+  server.begin();                           // start the web server on port 80
+  printWifiStatus();                        // you're connected now, so print out the status
+}
+
+
+void loop() {
+  WiFiClient client = server.available();   // listen for incoming clients
+
+  if (client) {                             // if you get a client,
+    Serial.println("new client");           // print a message out the serial port
+    String currentLine = "";                // make a String to hold incoming data from the client
+    while (client.connected()) {            // loop while the client's connected
+      if (client.available()) {             // if there's bytes to read from the client,
+        char c = client.read();             // read a byte, then
+        Serial.write(c);                    // print it out the serial monitor
+        if (c == '\n') {                    // if the byte is a newline character
+
+          // if the current line is blank, you got two newline characters in a row.
+          // that's the end of the client HTTP request, so send a response:
+          if (currentLine.length() == 0) {  
+            // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
+            // and a content-type so the client knows what's coming, then a blank line:    
+            client.println("HTTP/1.1 200 OK");
+            client.println("Content-type:text/html");
+            client.println();
+
+            // the content of the HTTP response follows the header:
+            client.print("Click <a href=\"/H\">here</a> turn the LED on pin 9 on<br>");
+            client.print("Click <a href=\"/L\">here</a> turn the LED on pin 9 off<br>");
+
+            // The HTTP response ends with another blank line:
+            client.println();
+            // break out of the while loop:
+            break;         
+          } 
+          else {      // if you got a newline, then clear currentLine:
+            currentLine = "";
+          }
+        }     
+        else if (c != '\r') {    // if you got anything else but a carriage return character,
+          currentLine += c;      // add it to the end of the currentLine
+        }
+
+        // Check to see if the client request was "GET /H" or "GET /L":
+        if (currentLine.endsWith("GET /H")) {
+          digitalWrite(9, HIGH);               // GET /H turns the LED on
+        }
+        if (currentLine.endsWith("GET /L")) {
+          digitalWrite(9, LOW);                // GET /L turns the LED off
+        }
+      }
+    }
+    // close the connection:
+    client.stop();
+    Serial.println("client disonnected");
+  }
+}
+
+void printWifiStatus() {
+  // print the SSID of the network you're attached to:
+  Serial.print("SSID: ");
+  Serial.println(WiFi.SSID());
+
+  // print your WiFi shield's IP address:
+  IPAddress ip = WiFi.localIP();
+  Serial.print("IP Address: ");
+  Serial.println(ip);
+
+  // print the received signal strength:
+  long rssi = WiFi.RSSI();
+  Serial.print("signal strength (RSSI):");
+  Serial.print(rssi);
+  Serial.println(" dBm");
+  // print where to go in a browser:
+  Serial.print("To see this page in action, open a browser to http://";);
+  Serial.println(ip);
+}
diff --git a/libraries/WiFi/examples/WifiPachubeClient/WifiPachubeClient.ino b/libraries/WiFi/examples/WifiPachubeClient/WifiPachubeClient.ino
new file mode 100644
index 0000000..f8ffc07
--- /dev/null
+++ b/libraries/WiFi/examples/WifiPachubeClient/WifiPachubeClient.ino
@@ -0,0 +1,190 @@
+/*
+  Wifi Pachube sensor client
+ 
+ This sketch connects an analog sensor to Pachube (http://www.pachube.com)
+ using an Arduino Wifi shield.
+ 
+ This example is written for a network using WPA encryption. For 
+ WEP or WPA, change the Wifi.begin() call accordingly.
+ 
+ This example has been updated to use version 2.0 of the Pachube API. 
+ To make it work, create a feed with a datastream, and give it the ID
+ sensor1. Or change the code below to match your feed.
+ 
+ Circuit:
+ * Analog sensor attached to analog in 0
+ * Wifi shield attached to pins 10, 11, 12, 13
+ 
+ created 13 Mar 2012
+ modified 31 May 2012
+ by Tom Igoe
+ modified 8 Sept 2012
+ by Scott Fitzgerald
+ 
+ This code is in the public domain.
+ 
+ */
+#include <SPI.h>
+#include <WiFi.h>
+
+#define APIKEY         "YOUR API KEY GOES HERE" // replace your pachube api key here
+#define FEEDID         00000                    // replace your feed ID
+#define USERAGENT      "My Arduino Project"     // user agent is the project name
+
+char ssid[] = "yourNetwork";      //  your network SSID (name) 
+char pass[] = "secretPassword";   // your network password
+
+int status = WL_IDLE_STATUS;
+
+// initialize the library instance:
+WiFiClient client;
+// if you don't want to use DNS (and reduce your sketch size)
+// use the numeric IP instead of the name for the server:
+IPAddress server(216,52,233,121);      // numeric IP for api.pachube.com
+//char server[] = "api.pachube.com";   // name address for pachube API
+
+unsigned long lastConnectionTime = 0;          // last time you connected to the server, in milliseconds
+boolean lastConnected = false;                 // state of the connection last time through the main loop
+const unsigned long postingInterval = 10*1000; //delay between updates to pachube.com
+
+void setup() {
+  //Initialize serial and wait for port to open:
+  Serial.begin(9600); 
+  while (!Serial) {
+    ; // wait for serial port to connect. Needed for Leonardo only
+  }
+  
+  // check for the presence of the shield:
+  if (WiFi.status() == WL_NO_SHIELD) {
+    Serial.println("WiFi shield not present"); 
+    // don't continue:
+    while(true);
+  } 
+  
+  // attempt to connect to Wifi network:
+  while ( status != WL_CONNECTED) { 
+    Serial.print("Attempting to connect to SSID: ");
+    Serial.println(ssid);
+    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:    
+    status = WiFi.begin(ssid, pass);
+
+    // wait 10 seconds for connection:
+    delay(10000);
+  } 
+  // you're connected now, so print out the status:
+  printWifiStatus();
+}
+
+
+void loop() {
+  // read the analog sensor:
+  int sensorReading = analogRead(A0);   
+
+  // if there's incoming data from the net connection.
+  // send it out the serial port.  This is for debugging
+  // purposes only:
+  while (client.available()) {
+    char c = client.read();
+    Serial.print(c);
+  }
+
+  // if there's no net connection, but there was one last time
+  // through the loop, then stop the client:
+  if (!client.connected() && lastConnected) {
+    Serial.println();
+    Serial.println("disconnecting.");
+    client.stop();
+  }
+
+  // if you're not connected, and ten seconds have passed since
+  // your last connection, then connect again and send data:
+  if(!client.connected() && (millis() - lastConnectionTime > postingInterval)) {
+    sendData(sensorReading);
+  }
+  // store the state of the connection for next time through
+  // the loop:
+  lastConnected = client.connected();
+}
+
+// this method makes a HTTP connection to the server:
+void sendData(int thisData) {
+  // if there's a successful connection:
+  if (client.connect(server, 80)) {
+    Serial.println("connecting...");
+    // send the HTTP PUT request:
+    client.print("PUT /v2/feeds/");
+    client.print(FEEDID);
+    client.println(".csv HTTP/1.1");
+    client.println("Host: api.pachube.com");
+    client.print("X-ApiKey: ");
+    client.println(APIKEY);
+    client.print("User-Agent: ");
+    client.println(USERAGENT);
+    client.print("Content-Length: ");
+
+    // calculate the length of the sensor reading in bytes:
+    // 8 bytes for "sensor1," + number of digits of the data:
+    int thisLength = 8 + getLength(thisData);
+    client.println(thisLength);
+
+    // last pieces of the HTTP PUT request:
+    client.println("Content-Type: text/csv");
+    client.println("Connection: close");
+    client.println();
+
+    // here's the actual content of the PUT request:
+    client.print("sensor1,");
+    client.println(thisData);
+  
+  } 
+  else {
+    // if you couldn't make a connection:
+    Serial.println("connection failed");
+    Serial.println();
+    Serial.println("disconnecting.");
+    client.stop();
+  }
+   // note the time that the connection was made or attempted:
+  lastConnectionTime = millis();
+}
+
+
+// This method calculates the number of digits in the
+// sensor reading.  Since each digit of the ASCII decimal
+// representation is a byte, the number of digits equals
+// the number of bytes:
+
+int getLength(int someValue) {
+  // there's at least one byte:
+  int digits = 1;
+  // continually divide the value by ten, 
+  // adding one to the digit count for each
+  // time you divide, until you're at 0:
+  int dividend = someValue /10;
+  while (dividend > 0) {
+    dividend = dividend /10;
+    digits++;
+  }
+  // return the number of digits:
+  return digits;
+}
+
+void printWifiStatus() {
+  // print the SSID of the network you're attached to:
+  Serial.print("SSID: ");
+  Serial.println(WiFi.SSID());
+
+  // print your WiFi shield's IP address:
+  IPAddress ip = WiFi.localIP();
+  Serial.print("IP Address: ");
+  Serial.println(ip);
+
+  // print the received signal strength:
+  long rssi = WiFi.RSSI();
+  Serial.print("signal strength (RSSI):");
+  Serial.print(rssi);
+  Serial.println(" dBm");
+}
+
+
+
diff --git a/libraries/WiFi/examples/WifiPachubeClientString/WifiPachubeClientString.ino b/libraries/WiFi/examples/WifiPachubeClientString/WifiPachubeClientString.ino
new file mode 100644
index 0000000..243fe83
--- /dev/null
+++ b/libraries/WiFi/examples/WifiPachubeClientString/WifiPachubeClientString.ino
@@ -0,0 +1,177 @@
+/*
+  Wifi Pachube sensor client with Strings
+ 
+ This sketch connects an analog sensor to Pachube (http://www.pachube.com)
+ using a Arduino Wifi shield.
+ 
+ This example is written for a network using WPA encryption. For 
+ WEP or WPA, change the Wifi.begin() call accordingly.
+ 
+ This example has been updated to use version 2.0 of the pachube.com API. 
+ To make it work, create a feed with a datastream, and give it the ID
+ sensor1. Or change the code below to match your feed.
+ 
+ This example uses the String library, which is part of the Arduino core from
+ version 0019.  
+ 
+ Circuit:
+ * Analog sensor attached to analog in 0
+ * Wifi shield attached to pins 10, 11, 12, 13
+ 
+ created 16 Mar 2012
+ modified 31 May 2012
+ by Tom Igoe
+ modified 8 Sept 2012
+ by Scott Fitzgerald
+ 
+ This code is in the public domain.
+ 
+ */
+
+#include <SPI.h>
+#include <WiFi.h>
+
+#define APIKEY         "YOUR API KEY GOES HERE" // replace your pachube api key here
+#define FEEDID         00000                    // replace your feed ID
+#define USERAGENT      "My Arduino Project"     // user agent is the project name
+
+char ssid[] = "yourNetwork";      //  your network SSID (name) 
+char pass[] = "secretPassword";   // your network password
+
+int status = WL_IDLE_STATUS;
+
+// initialize the library instance:
+WiFiClient client;
+
+// if you don't want to use DNS (and reduce your sketch size)
+// use the numeric IP instead of the name for the server:
+//IPAddress server(216,52,233,121);      // numeric IP for api.pachube.com
+char server[] = "api.pachube.com";   // name address for pachube API
+
+unsigned long lastConnectionTime = 0;          // last time you connected to the server, in milliseconds
+boolean lastConnected = false;                 // state of the connection last time through the main loop
+const unsigned long postingInterval = 10*1000;  //delay between updates to pachube.com
+
+void setup() {
+  //Initialize serial and wait for port to open:
+  Serial.begin(9600); 
+  while (!Serial) {
+    ; // wait for serial port to connect. Needed for Leonardo only
+  }
+  
+  // check for the presence of the shield:
+  if (WiFi.status() == WL_NO_SHIELD) {
+    Serial.println("WiFi shield not present"); 
+    // don't continue:
+    while(true);
+  } 
+  
+  // attempt to connect to Wifi network:
+  while ( status != WL_CONNECTED) { 
+    Serial.print("Attempting to connect to SSID: ");
+    Serial.println(ssid);
+    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:    
+    status = WiFi.begin(ssid, pass);
+
+    // wait 10 seconds for connection:
+    delay(10000);
+  } 
+  // you're connected now, so print out the status:
+  printWifiStatus();
+}
+
+void loop() {
+  // read the analog sensor:
+  int sensorReading = analogRead(A0);   
+  // convert the data to a String to send it:
+
+  String dataString = "sensor1,";
+  dataString += sensorReading;
+
+  // you can append multiple readings to this String if your
+  // pachube feed is set up to handle multiple values:
+  int otherSensorReading = analogRead(A1);
+  dataString += "\nsensor2,";
+  dataString += otherSensorReading;
+
+  // if there's incoming data from the net connection.
+  // send it out the serial port.  This is for debugging
+  // purposes only:
+  while (client.available()) {
+    char c = client.read();
+    Serial.print(c);
+  }
+
+  // if there's no net connection, but there was one last time
+  // through the loop, then stop the client:
+  if (!client.connected() && lastConnected) {
+    Serial.println();
+    Serial.println("disconnecting.");
+    client.stop();
+  }
+
+  // if you're not connected, and ten seconds have passed since
+  // your last connection, then connect again and send data: 
+  if(!client.connected() && (millis() - lastConnectionTime > postingInterval)) {
+    sendData(dataString);
+  }
+  // store the state of the connection for next time through
+  // the loop:
+  lastConnected = client.connected();
+}
+
+// this method makes a HTTP connection to the server:
+void sendData(String thisData) {
+  // if there's a successful connection:
+  if (client.connect(server, 80)) {
+    Serial.println("connecting...");
+    // send the HTTP PUT request:
+    client.print("PUT /v2/feeds/");
+    client.print(FEEDID);
+    client.println(".csv HTTP/1.1");
+    client.println("Host: api.pachube.com");
+    client.print("X-ApiKey: ");
+    client.println(APIKEY);
+    client.print("User-Agent: ");
+    client.println(USERAGENT);
+    client.print("Content-Length: ");
+    client.println(thisData.length());
+
+    // last pieces of the HTTP PUT request:
+    client.println("Content-Type: text/csv");
+    client.println("Connection: close");
+    client.println();
+
+    // here's the actual content of the PUT request:
+    client.println(thisData);
+  } 
+  else {
+    // if you couldn't make a connection:
+    Serial.println("connection failed");
+    Serial.println();
+    Serial.println("disconnecting.");
+    client.stop();
+  }
+  // note the time that the connection was made or attempted:
+  lastConnectionTime = millis();
+}
+
+
+void printWifiStatus() {
+  // print the SSID of the network you're attached to:
+  Serial.print("SSID: ");
+  Serial.println(WiFi.SSID());
+
+  // print your WiFi shield's IP address:
+  IPAddress ip = WiFi.localIP();
+  Serial.print("IP Address: ");
+  Serial.println(ip);
+
+  // print the received signal strength:
+  long rssi = WiFi.RSSI();
+  Serial.print("signal strength (RSSI):");
+  Serial.print(rssi);
+  Serial.println(" dBm");
+}
+
+
diff --git a/libraries/WiFi/utility/server_drv.cpp b/libraries/WiFi/utility/server_drv.cpp
index 05c3a17..ce03604 100644
--- a/libraries/WiFi/utility/server_drv.cpp
+++ b/libraries/WiFi/utility/server_drv.cpp
@@ -1,260 +1,260 @@
-//#define _DEBUG_
-
-#include "server_drv.h"
-
-#include "Arduino.h"
-#include "spi_drv.h"
-
-extern "C" {
-#include "wl_types.h"
-#include "debug.h"
-}
-
-
-// Start server TCP on port specified
-void ServerDrv::startServer(uint16_t port, uint8_t sock)
-{
-	WAIT_FOR_SLAVE_SELECT();
-    // Send Command
-    SpiDrv::sendCmd(START_SERVER_TCP_CMD, PARAM_NUMS_2);
-    SpiDrv::sendParam(port);
-    SpiDrv::sendParam(&sock, 1, LAST_PARAM);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t _data = 0;
-    uint8_t _dataLen = 0;
-    if (!SpiDrv::waitResponseCmd(START_SERVER_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
-    {
-        WARN("error waitResponse");
-    }
-    SpiDrv::spiSlaveDeselect();
-}
-
-// Start server TCP on port specified
-void ServerDrv::startClient(uint32_t ipAddress, uint16_t port, uint8_t sock)
-{
-	WAIT_FOR_SLAVE_SELECT();
-    // Send Command
-    SpiDrv::sendCmd(START_CLIENT_TCP_CMD, PARAM_NUMS_3);
-    SpiDrv::sendParam((uint8_t*)&ipAddress, sizeof(ipAddress));
-    SpiDrv::sendParam(port);
-    SpiDrv::sendParam(&sock, 1, LAST_PARAM);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t _data = 0;
-    uint8_t _dataLen = 0;
-    if (!SpiDrv::waitResponseCmd(START_CLIENT_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
-    {
-        WARN("error waitResponse");
-    }
-    SpiDrv::spiSlaveDeselect();
-}
-
-// Start server TCP on port specified
-void ServerDrv::stopClient(uint8_t sock)
-{
-	WAIT_FOR_SLAVE_SELECT();
-    // Send Command
-    SpiDrv::sendCmd(STOP_CLIENT_TCP_CMD, PARAM_NUMS_1);
-    SpiDrv::sendParam(&sock, 1, LAST_PARAM);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t _data = 0;
-    uint8_t _dataLen = 0;
-    if (!SpiDrv::waitResponseCmd(STOP_CLIENT_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
-    {
-        WARN("error waitResponse");
-    }
-    SpiDrv::spiSlaveDeselect();
-}
-
-
-uint8_t ServerDrv::getServerState(uint8_t sock)
-{
-	WAIT_FOR_SLAVE_SELECT();
-    // Send Command
-    SpiDrv::sendCmd(GET_STATE_TCP_CMD, PARAM_NUMS_1);
-    SpiDrv::sendParam(&sock, sizeof(sock), LAST_PARAM);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t _data = 0;
-    uint8_t _dataLen = 0;
-    if (!SpiDrv::waitResponseCmd(GET_STATE_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
-    {
-        WARN("error waitResponse");
-    }
-    SpiDrv::spiSlaveDeselect();
-   return _data;
-}
-
-uint8_t ServerDrv::getClientState(uint8_t sock)
-{
-	WAIT_FOR_SLAVE_SELECT();
-    // Send Command
-    SpiDrv::sendCmd(GET_CLIENT_STATE_TCP_CMD, PARAM_NUMS_1);
-    SpiDrv::sendParam(&sock, sizeof(sock), LAST_PARAM);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t _data = 0;
-    uint8_t _dataLen = 0;
-    if (!SpiDrv::waitResponseCmd(GET_CLIENT_STATE_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
-    {
-        WARN("error waitResponse");
-    }
-    SpiDrv::spiSlaveDeselect();
-   return _data;
-}
-
-uint8_t ServerDrv::availData(uint8_t sock)
-{
-	WAIT_FOR_SLAVE_SELECT();
-    // Send Command
-    SpiDrv::sendCmd(AVAIL_DATA_TCP_CMD, PARAM_NUMS_1);
-    SpiDrv::sendParam(&sock, sizeof(sock), LAST_PARAM);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t _data = 0;
-    uint8_t _dataLen = 0;
-    if (!SpiDrv::waitResponseCmd(AVAIL_DATA_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
-    {
-        WARN("error waitResponse");
-    }
-    SpiDrv::spiSlaveDeselect();
-
-    if (_dataLen!=0)
-    {
-        return (_data == 1);
-    }
-    return false;
-}
-
-bool ServerDrv::getData(uint8_t sock, uint8_t *data, uint8_t peek)
-{
-	WAIT_FOR_SLAVE_SELECT();
-    // Send Command
-    SpiDrv::sendCmd(GET_DATA_TCP_CMD, PARAM_NUMS_2);
-    SpiDrv::sendParam(&sock, sizeof(sock));
-    SpiDrv::sendParam(peek, LAST_PARAM);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t _data = 0;
-    uint8_t _dataLen = 0;
-    if (!SpiDrv::waitResponseData8(GET_DATA_TCP_CMD, &_data, &_dataLen))
-    {
-        WARN("error waitResponse");
-    }
-    SpiDrv::spiSlaveDeselect();
-    if (_dataLen!=0)
-    {
-        *data = _data;
-        return true;
-    }
-    return false;
-}
-
-bool ServerDrv::getDataBuf(uint8_t sock, uint8_t *_data, uint16_t *_dataLen)
-{
-	WAIT_FOR_SLAVE_SELECT();
-    // Send Command
-    SpiDrv::sendCmd(GET_DATABUF_TCP_CMD, PARAM_NUMS_1);
-    SpiDrv::sendBuffer(&sock, sizeof(sock), LAST_PARAM);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    if (!SpiDrv::waitResponseData16(GET_DATABUF_TCP_CMD, _data, _dataLen))
-    {
-        WARN("error waitResponse");
-    }
-    SpiDrv::spiSlaveDeselect();
-    if (*_dataLen!=0)
-    {
-        return true;
-    }
-    return false;
-}
-
-
-bool ServerDrv::sendData(uint8_t sock, const uint8_t *data, uint16_t len)
-{
-	WAIT_FOR_SLAVE_SELECT();
-    // Send Command
-    SpiDrv::sendCmd(SEND_DATA_TCP_CMD, PARAM_NUMS_2);
-    SpiDrv::sendBuffer(&sock, sizeof(sock));
-    SpiDrv::sendBuffer((uint8_t *)data, len, LAST_PARAM);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t _data = 0;
-    uint8_t _dataLen = 0;
-    if (!SpiDrv::waitResponseData8(SEND_DATA_TCP_CMD, &_data, &_dataLen))
-    {
-        WARN("error waitResponse");
-    }
-    SpiDrv::spiSlaveDeselect();
-    if (_dataLen!=0)
-    {
-        return (_data == 1);
-    }
-    return false;
-}
-
-
-uint8_t ServerDrv::checkDataSent(uint8_t sock)
-{
-	const uint16_t TIMEOUT_DATA_SENT = 25;
-    uint16_t timeout = 0;
-	uint8_t _data = 0;
-	uint8_t _dataLen = 0;
-
-	do {
-		WAIT_FOR_SLAVE_SELECT();
-		// Send Command
-		SpiDrv::sendCmd(DATA_SENT_TCP_CMD, PARAM_NUMS_1);
-		SpiDrv::sendParam(&sock, sizeof(sock), LAST_PARAM);
-
-		//Wait the reply elaboration
-		SpiDrv::waitForSlaveReady();
-
-		// Wait for reply
-		if (!SpiDrv::waitResponseCmd(DATA_SENT_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
-		{
-			WARN("error waitResponse isDataSent");
-		}
-		SpiDrv::spiSlaveDeselect();
-
-		if (_data) timeout = 0;
-		else{
-			++timeout;
-			delay(100);
-		}
-
-	}while((_data==0)&&(timeout<TIMEOUT_DATA_SENT));
-    return (timeout==TIMEOUT_DATA_SENT)?0:1;
-}
-
-ServerDrv serverDrv;
+//#define _DEBUG_
+
+#include "server_drv.h"
+
+#include "Arduino.h"
+#include "spi_drv.h"
+
+extern "C" {
+#include "wl_types.h"
+#include "debug.h"
+}
+
+
+// Start server TCP on port specified
+void ServerDrv::startServer(uint16_t port, uint8_t sock)
+{
+	WAIT_FOR_SLAVE_SELECT();
+    // Send Command
+    SpiDrv::sendCmd(START_SERVER_TCP_CMD, PARAM_NUMS_2);
+    SpiDrv::sendParam(port);
+    SpiDrv::sendParam(&sock, 1, LAST_PARAM);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t _data = 0;
+    uint8_t _dataLen = 0;
+    if (!SpiDrv::waitResponseCmd(START_SERVER_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
+    {
+        WARN("error waitResponse");
+    }
+    SpiDrv::spiSlaveDeselect();
+}
+
+// Start server TCP on port specified
+void ServerDrv::startClient(uint32_t ipAddress, uint16_t port, uint8_t sock)
+{
+	WAIT_FOR_SLAVE_SELECT();
+    // Send Command
+    SpiDrv::sendCmd(START_CLIENT_TCP_CMD, PARAM_NUMS_3);
+    SpiDrv::sendParam((uint8_t*)&ipAddress, sizeof(ipAddress));
+    SpiDrv::sendParam(port);
+    SpiDrv::sendParam(&sock, 1, LAST_PARAM);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t _data = 0;
+    uint8_t _dataLen = 0;
+    if (!SpiDrv::waitResponseCmd(START_CLIENT_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
+    {
+        WARN("error waitResponse");
+    }
+    SpiDrv::spiSlaveDeselect();
+}
+
+// Start server TCP on port specified
+void ServerDrv::stopClient(uint8_t sock)
+{
+	WAIT_FOR_SLAVE_SELECT();
+    // Send Command
+    SpiDrv::sendCmd(STOP_CLIENT_TCP_CMD, PARAM_NUMS_1);
+    SpiDrv::sendParam(&sock, 1, LAST_PARAM);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t _data = 0;
+    uint8_t _dataLen = 0;
+    if (!SpiDrv::waitResponseCmd(STOP_CLIENT_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
+    {
+        WARN("error waitResponse");
+    }
+    SpiDrv::spiSlaveDeselect();
+}
+
+
+uint8_t ServerDrv::getServerState(uint8_t sock)
+{
+	WAIT_FOR_SLAVE_SELECT();
+    // Send Command
+    SpiDrv::sendCmd(GET_STATE_TCP_CMD, PARAM_NUMS_1);
+    SpiDrv::sendParam(&sock, sizeof(sock), LAST_PARAM);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t _data = 0;
+    uint8_t _dataLen = 0;
+    if (!SpiDrv::waitResponseCmd(GET_STATE_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
+    {
+        WARN("error waitResponse");
+    }
+    SpiDrv::spiSlaveDeselect();
+   return _data;
+}
+
+uint8_t ServerDrv::getClientState(uint8_t sock)
+{
+	WAIT_FOR_SLAVE_SELECT();
+    // Send Command
+    SpiDrv::sendCmd(GET_CLIENT_STATE_TCP_CMD, PARAM_NUMS_1);
+    SpiDrv::sendParam(&sock, sizeof(sock), LAST_PARAM);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t _data = 0;
+    uint8_t _dataLen = 0;
+    if (!SpiDrv::waitResponseCmd(GET_CLIENT_STATE_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
+    {
+        WARN("error waitResponse");
+    }
+    SpiDrv::spiSlaveDeselect();
+   return _data;
+}
+
+uint8_t ServerDrv::availData(uint8_t sock)
+{
+	WAIT_FOR_SLAVE_SELECT();
+    // Send Command
+    SpiDrv::sendCmd(AVAIL_DATA_TCP_CMD, PARAM_NUMS_1);
+    SpiDrv::sendParam(&sock, sizeof(sock), LAST_PARAM);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t _data = 0;
+    uint8_t _dataLen = 0;
+    if (!SpiDrv::waitResponseCmd(AVAIL_DATA_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
+    {
+        WARN("error waitResponse");
+    }
+    SpiDrv::spiSlaveDeselect();
+
+    if (_dataLen!=0)
+    {
+        return (_data == 1);
+    }
+    return false;
+}
+
+bool ServerDrv::getData(uint8_t sock, uint8_t *data, uint8_t peek)
+{
+	WAIT_FOR_SLAVE_SELECT();
+    // Send Command
+    SpiDrv::sendCmd(GET_DATA_TCP_CMD, PARAM_NUMS_2);
+    SpiDrv::sendParam(&sock, sizeof(sock));
+    SpiDrv::sendParam(peek, LAST_PARAM);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t _data = 0;
+    uint8_t _dataLen = 0;
+    if (!SpiDrv::waitResponseData8(GET_DATA_TCP_CMD, &_data, &_dataLen))
+    {
+        WARN("error waitResponse");
+    }
+    SpiDrv::spiSlaveDeselect();
+    if (_dataLen!=0)
+    {
+        *data = _data;
+        return true;
+    }
+    return false;
+}
+
+bool ServerDrv::getDataBuf(uint8_t sock, uint8_t *_data, uint16_t *_dataLen)
+{
+	WAIT_FOR_SLAVE_SELECT();
+    // Send Command
+    SpiDrv::sendCmd(GET_DATABUF_TCP_CMD, PARAM_NUMS_1);
+    SpiDrv::sendBuffer(&sock, sizeof(sock), LAST_PARAM);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    if (!SpiDrv::waitResponseData16(GET_DATABUF_TCP_CMD, _data, _dataLen))
+    {
+        WARN("error waitResponse");
+    }
+    SpiDrv::spiSlaveDeselect();
+    if (*_dataLen!=0)
+    {
+        return true;
+    }
+    return false;
+}
+
+
+bool ServerDrv::sendData(uint8_t sock, const uint8_t *data, uint16_t len)
+{
+	WAIT_FOR_SLAVE_SELECT();
+    // Send Command
+    SpiDrv::sendCmd(SEND_DATA_TCP_CMD, PARAM_NUMS_2);
+    SpiDrv::sendBuffer(&sock, sizeof(sock));
+    SpiDrv::sendBuffer((uint8_t *)data, len, LAST_PARAM);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t _data = 0;
+    uint8_t _dataLen = 0;
+    if (!SpiDrv::waitResponseData8(SEND_DATA_TCP_CMD, &_data, &_dataLen))
+    {
+        WARN("error waitResponse");
+    }
+    SpiDrv::spiSlaveDeselect();
+    if (_dataLen!=0)
+    {
+        return (_data == 1);
+    }
+    return false;
+}
+
+
+uint8_t ServerDrv::checkDataSent(uint8_t sock)
+{
+	const uint16_t TIMEOUT_DATA_SENT = 25;
+    uint16_t timeout = 0;
+	uint8_t _data = 0;
+	uint8_t _dataLen = 0;
+
+	do {
+		WAIT_FOR_SLAVE_SELECT();
+		// Send Command
+		SpiDrv::sendCmd(DATA_SENT_TCP_CMD, PARAM_NUMS_1);
+		SpiDrv::sendParam(&sock, sizeof(sock), LAST_PARAM);
+
+		//Wait the reply elaboration
+		SpiDrv::waitForSlaveReady();
+
+		// Wait for reply
+		if (!SpiDrv::waitResponseCmd(DATA_SENT_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
+		{
+			WARN("error waitResponse isDataSent");
+		}
+		SpiDrv::spiSlaveDeselect();
+
+		if (_data) timeout = 0;
+		else{
+			++timeout;
+			delay(100);
+		}
+
+	}while((_data==0)&&(timeout<TIMEOUT_DATA_SENT));
+    return (timeout==TIMEOUT_DATA_SENT)?0:1;
+}
+
+ServerDrv serverDrv;
diff --git a/libraries/WiFi/utility/server_drv.h b/libraries/WiFi/utility/server_drv.h
index b0df703..69ba593 100644
--- a/libraries/WiFi/utility/server_drv.h
+++ b/libraries/WiFi/utility/server_drv.h
@@ -1,34 +1,34 @@
-#ifndef Server_Drv_h
-#define Server_Drv_h
-
-#include <inttypes.h>
-#include "wifi_spi.h"
-
-class ServerDrv
-{
-public:
-    // Start server TCP on port specified
-    static void startServer(uint16_t port, uint8_t sock);
-
-    static void startClient(uint32_t ipAddress, uint16_t port, uint8_t sock);
-
-    static void stopClient(uint8_t sock);
-                                                                                  
-    static uint8_t getServerState(uint8_t sock);
-
-    static uint8_t getClientState(uint8_t sock);
-
-    static bool getData(uint8_t sock, uint8_t *data, uint8_t peek = 0);
-
-    static bool getDataBuf(uint8_t sock, uint8_t *data, uint16_t *len);
-
-    static bool sendData(uint8_t sock, const uint8_t *data, uint16_t len);
-
-    static uint8_t availData(uint8_t sock);
-
-    static uint8_t checkDataSent(uint8_t sock);
-};
-
-extern ServerDrv serverDrv;
-
-#endif
+#ifndef Server_Drv_h
+#define Server_Drv_h
+
+#include <inttypes.h>
+#include "wifi_spi.h"
+
+class ServerDrv
+{
+public:
+    // Start server TCP on port specified
+    static void startServer(uint16_t port, uint8_t sock);
+
+    static void startClient(uint32_t ipAddress, uint16_t port, uint8_t sock);
+
+    static void stopClient(uint8_t sock);
+                                                                                  
+    static uint8_t getServerState(uint8_t sock);
+
+    static uint8_t getClientState(uint8_t sock);
+
+    static bool getData(uint8_t sock, uint8_t *data, uint8_t peek = 0);
+
+    static bool getDataBuf(uint8_t sock, uint8_t *data, uint16_t *len);
+
+    static bool sendData(uint8_t sock, const uint8_t *data, uint16_t len);
+
+    static uint8_t availData(uint8_t sock);
+
+    static uint8_t checkDataSent(uint8_t sock);
+};
+
+extern ServerDrv serverDrv;
+
+#endif
diff --git a/libraries/WiFi/utility/socket.c b/libraries/WiFi/utility/socket.c
index 0eddd4a..665073b 100644
--- a/libraries/WiFi/utility/socket.c
+++ b/libraries/WiFi/utility/socket.c
@@ -1,20 +1,20 @@
-/*
-*
- file		socket.c
- brief	define function of socket API 
-*
-*/
-#include <inttypes.h>
-#include "socket.h"
-
-SOCKET socket(uint8 protocol) {return 0;} // Opens a socket(TCP or UDP or IP_RAW mode)
-void close(SOCKET s) {} // Close socket
-uint8 connect(SOCKET s, uint8 * addr, uint16 port) {return 0;} // Establish TCP connection (Active connection)
-void disconnect(SOCKET s) {} // disconnect the connection
-uint8 listen(SOCKET s) { return 0;}	// Establish TCP connection (Passive connection)
-uint16 send(SOCKET s, const uint8 * buf, uint16 len) { return 0;} // Send data (TCP)
-uint16 recv(SOCKET s, uint8 * buf, uint16 len) {return 0;}	// Receive data (TCP)
-uint16 sendto(SOCKET s, const uint8 * buf, uint16 len, uint8 * addr, uint16 port) {return 0;} // Send data (UDP/IP RAW)
-uint16 recvfrom(SOCKET s, uint8 * buf, uint16 len, uint8 * addr, uint16  *port) {return 0;} // Receive data (UDP/IP RAW)
-
-uint16 igmpsend(SOCKET s, const uint8 * buf, uint16 len) {return 0;}
+/*
+*
+ file		socket.c
+ brief	define function of socket API 
+*
+*/
+#include <inttypes.h>
+#include "socket.h"
+
+SOCKET socket(uint8 protocol) {return 0;} // Opens a socket(TCP or UDP or IP_RAW mode)
+void close(SOCKET s) {} // Close socket
+uint8 connect(SOCKET s, uint8 * addr, uint16 port) {return 0;} // Establish TCP connection (Active connection)
+void disconnect(SOCKET s) {} // disconnect the connection
+uint8 listen(SOCKET s) { return 0;}	// Establish TCP connection (Passive connection)
+uint16 send(SOCKET s, const uint8 * buf, uint16 len) { return 0;} // Send data (TCP)
+uint16 recv(SOCKET s, uint8 * buf, uint16 len) {return 0;}	// Receive data (TCP)
+uint16 sendto(SOCKET s, const uint8 * buf, uint16 len, uint8 * addr, uint16 port) {return 0;} // Send data (UDP/IP RAW)
+uint16 recvfrom(SOCKET s, uint8 * buf, uint16 len, uint8 * addr, uint16  *port) {return 0;} // Receive data (UDP/IP RAW)
+
+uint16 igmpsend(SOCKET s, const uint8 * buf, uint16 len) {return 0;}
diff --git a/libraries/WiFi/utility/socket.h b/libraries/WiFi/utility/socket.h
index 8e7f6b6..9b06d00 100644
--- a/libraries/WiFi/utility/socket.h
+++ b/libraries/WiFi/utility/socket.h
@@ -1,87 +1,87 @@
-/*
-*
- file		socket.h
- brief	define function of socket API 
-*
-*/
-
-#ifndef	_SOCKET_H_
-#define	_SOCKET_H_
-
-#define TCP_SOCKET  1
-#define UDP_SOCKET  2
-#define RAW_SOCKET  3
-
-#define SOCK_NOT_AVAIL  255
-
-#include "wl_definitions.h"
-/**
- * The 8-bit signed data type.
- */
-typedef char int8;
-/**
- * The volatile 8-bit signed data type.
- */
-typedef volatile char vint8;
-/**
- * The 8-bit unsigned data type.
- */
-typedef unsigned char uint8;
-/**
- * The volatile 8-bit unsigned data type.
- */
-typedef volatile unsigned char vuint8;
-
-/**
- * The 16-bit signed data type.
- */
-typedef int int16;
-/**
- * The volatile 16-bit signed data type.
- */
-typedef volatile int vint16;
-/**
- * The 16-bit unsigned data type.
- */
-typedef unsigned int uint16;
-/**
- * The volatile 16-bit unsigned data type.
- */
-typedef volatile unsigned int vuint16;
-/**
- * The 32-bit signed data type.
- */
-typedef long int32;
-/**
- * The volatile 32-bit signed data type.
- */
-typedef volatile long vint32;
-/**
- * The 32-bit unsigned data type.
- */
-typedef unsigned long uint32;
-/**
- * The volatile 32-bit unsigned data type.
- */
-typedef volatile unsigned long vuint32;
-
-/* bsd */
-typedef uint8			u_char;		/**< 8-bit value */
-typedef uint16_t 			SOCKET;
-typedef uint16			u_short;	/**< 16-bit value */
-typedef uint16			u_int;		/**< 16-bit value */
-typedef uint32			u_long;		/**< 32-bit value */
-
-extern SOCKET socket(uint8 protocol); // Opens a socket(TCP or UDP or IP_RAW mode)
-extern void close(SOCKET s); // Close socket
-extern uint8 connect(SOCKET s, uint8 * addr, uint16 port); // Establish TCP connection (Active connection)
-extern void disconnect(SOCKET s); // disconnect the connection
-extern uint8 listen(SOCKET s);	// Establish TCP connection (Passive connection)
-extern uint16 send(SOCKET s, const uint8 * buf, uint16 len); // Send data (TCP)
-extern uint16 recv(SOCKET s, uint8 * buf, uint16 len);	// Receive data (TCP)
-extern uint16 sendto(SOCKET s, const uint8 * buf, uint16 len, uint8 * addr, uint16 port); // Send data (UDP/IP RAW)
-extern uint16 recvfrom(SOCKET s, uint8 * buf, uint16 len, uint8 * addr, uint16  *port); // Receive data (UDP/IP RAW)
-
-extern uint16 igmpsend(SOCKET s, const uint8 * buf, uint16 len);
-#endif
-/* _SOCKET_H_ */
+/*
+*
+ file		socket.h
+ brief	define function of socket API 
+*
+*/
+
+#ifndef	_SOCKET_H_
+#define	_SOCKET_H_
+
+#define TCP_SOCKET  1
+#define UDP_SOCKET  2
+#define RAW_SOCKET  3
+
+#define SOCK_NOT_AVAIL  255
+
+#include "wl_definitions.h"
+/**
+ * The 8-bit signed data type.
+ */
+typedef char int8;
+/**
+ * The volatile 8-bit signed data type.
+ */
+typedef volatile char vint8;
+/**
+ * The 8-bit unsigned data type.
+ */
+typedef unsigned char uint8;
+/**
+ * The volatile 8-bit unsigned data type.
+ */
+typedef volatile unsigned char vuint8;
+
+/**
+ * The 16-bit signed data type.
+ */
+typedef int int16;
+/**
+ * The volatile 16-bit signed data type.
+ */
+typedef volatile int vint16;
+/**
+ * The 16-bit unsigned data type.
+ */
+typedef unsigned int uint16;
+/**
+ * The volatile 16-bit unsigned data type.
+ */
+typedef volatile unsigned int vuint16;
+/**
+ * The 32-bit signed data type.
+ */
+typedef long int32;
+/**
+ * The volatile 32-bit signed data type.
+ */
+typedef volatile long vint32;
+/**
+ * The 32-bit unsigned data type.
+ */
+typedef unsigned long uint32;
+/**
+ * The volatile 32-bit unsigned data type.
+ */
+typedef volatile unsigned long vuint32;
+
+/* bsd */
+typedef uint8			u_char;		/**< 8-bit value */
+typedef uint16_t 			SOCKET;
+typedef uint16			u_short;	/**< 16-bit value */
+typedef uint16			u_int;		/**< 16-bit value */
+typedef uint32			u_long;		/**< 32-bit value */
+
+extern SOCKET socket(uint8 protocol); // Opens a socket(TCP or UDP or IP_RAW mode)
+extern void close(SOCKET s); // Close socket
+extern uint8 connect(SOCKET s, uint8 * addr, uint16 port); // Establish TCP connection (Active connection)
+extern void disconnect(SOCKET s); // disconnect the connection
+extern uint8 listen(SOCKET s);	// Establish TCP connection (Passive connection)
+extern uint16 send(SOCKET s, const uint8 * buf, uint16 len); // Send data (TCP)
+extern uint16 recv(SOCKET s, uint8 * buf, uint16 len);	// Receive data (TCP)
+extern uint16 sendto(SOCKET s, const uint8 * buf, uint16 len, uint8 * addr, uint16 port); // Send data (UDP/IP RAW)
+extern uint16 recvfrom(SOCKET s, uint8 * buf, uint16 len, uint8 * addr, uint16  *port); // Receive data (UDP/IP RAW)
+
+extern uint16 igmpsend(SOCKET s, const uint8 * buf, uint16 len);
+#endif
+/* _SOCKET_H_ */
diff --git a/libraries/WiFi/utility/spi_drv.h b/libraries/WiFi/utility/spi_drv.h
index 8cafb1b..5c2e706 100644
--- a/libraries/WiFi/utility/spi_drv.h
+++ b/libraries/WiFi/utility/spi_drv.h
@@ -1,83 +1,83 @@
-#ifndef SPI_Drv_h
-#define SPI_Drv_h
-
-#include <inttypes.h>
-#include "wifi_spi.h"
-
-#define SPI_START_CMD_DELAY 	12
-
-#define NO_LAST_PARAM   0
-#define LAST_PARAM      1
-
-#define DUMMY_DATA  0xFF
-
-#define WAIT_FOR_SLAVE_SELECT()	 \
-	SpiDrv::waitForSlaveReady(); \
-	SpiDrv::spiSlaveSelect();
-
-
-
-class SpiDrv
-{
-private:
-	//static bool waitSlaveReady();
-	static void waitForSlaveSign();
-	static void getParam(uint8_t* param);
-public:
-
-    static void begin();
-
-    static void end();
-    
-    static void spiDriverInit();
-        
-    static void spiSlaveSelect();
-    
-    static void spiSlaveDeselect();
-    
-    static char spiTransfer(volatile char data);
-
-    static void waitForSlaveReady();
-
-    //static int waitSpiChar(char waitChar, char* readChar);
-
-    static int waitSpiChar(unsigned char waitChar);
-    
-    static int readAndCheckChar(char checkChar, char* readChar);
-
-    static char readChar();
-
-    static int waitResponseParams(uint8_t cmd, uint8_t numParam, tParam* params);
-    
-    static int waitResponseCmd(uint8_t cmd, uint8_t numParam, uint8_t* param, uint8_t* param_len);
-
-    static int waitResponseData8(uint8_t cmd, uint8_t* param, uint8_t* param_len);
-     
-    static int waitResponseData16(uint8_t cmd, uint8_t* param, uint16_t* param_len);
- /*
-    static int waitResponse(uint8_t cmd, tParam* params, uint8_t* numParamRead, uint8_t maxNumParams);
-    
-    static int waitResponse(uint8_t cmd, uint8_t numParam, uint8_t* param, uint16_t* param_len);
-*/
-    static int waitResponse(uint8_t cmd, uint8_t* numParamRead, uint8_t** params, uint8_t maxNumParams);
-
-    static void sendParam(uint8_t* param, uint8_t param_len, uint8_t lastParam = NO_LAST_PARAM);
-
-    static void sendParamLen8(uint8_t param_len);
-
-    static void sendParamLen16(uint16_t param_len);
-
-    static uint8_t readParamLen8(uint8_t* param_len = NULL);
-
-    static uint16_t readParamLen16(uint16_t* param_len = NULL);
-
-    static void sendBuffer(uint8_t* param, uint16_t param_len, uint8_t lastParam = NO_LAST_PARAM);
-
-    static void sendParam(uint16_t param, uint8_t lastParam = NO_LAST_PARAM);
-    
-    static void sendCmd(uint8_t cmd, uint8_t numParam);
-};                                                                 
-
-extern SpiDrv spiDrv;
-
-#endif
+#ifndef SPI_Drv_h
+#define SPI_Drv_h
+
+#include <inttypes.h>
+#include "wifi_spi.h"
+
+#define SPI_START_CMD_DELAY 	12
+
+#define NO_LAST_PARAM   0
+#define LAST_PARAM      1
+
+#define DUMMY_DATA  0xFF
+
+#define WAIT_FOR_SLAVE_SELECT()	 \
+	SpiDrv::waitForSlaveReady(); \
+	SpiDrv::spiSlaveSelect();
+
+
+
+class SpiDrv
+{
+private:
+	//static bool waitSlaveReady();
+	static void waitForSlaveSign();
+	static void getParam(uint8_t* param);
+public:
+
+    static void begin();
+
+    static void end();
+    
+    static void spiDriverInit();
+        
+    static void spiSlaveSelect();
+    
+    static void spiSlaveDeselect();
+    
+    static char spiTransfer(volatile char data);
+
+    static void waitForSlaveReady();
+
+    //static int waitSpiChar(char waitChar, char* readChar);
+
+    static int waitSpiChar(unsigned char waitChar);
+    
+    static int readAndCheckChar(char checkChar, char* readChar);
+
+    static char readChar();
+
+    static int waitResponseParams(uint8_t cmd, uint8_t numParam, tParam* params);
+    
+    static int waitResponseCmd(uint8_t cmd, uint8_t numParam, uint8_t* param, uint8_t* param_len);
+
+    static int waitResponseData8(uint8_t cmd, uint8_t* param, uint8_t* param_len);
+     
+    static int waitResponseData16(uint8_t cmd, uint8_t* param, uint16_t* param_len);
+ /*
+    static int waitResponse(uint8_t cmd, tParam* params, uint8_t* numParamRead, uint8_t maxNumParams);
+    
+    static int waitResponse(uint8_t cmd, uint8_t numParam, uint8_t* param, uint16_t* param_len);
+*/
+    static int waitResponse(uint8_t cmd, uint8_t* numParamRead, uint8_t** params, uint8_t maxNumParams);
+
+    static void sendParam(uint8_t* param, uint8_t param_len, uint8_t lastParam = NO_LAST_PARAM);
+
+    static void sendParamLen8(uint8_t param_len);
+
+    static void sendParamLen16(uint16_t param_len);
+
+    static uint8_t readParamLen8(uint8_t* param_len = NULL);
+
+    static uint16_t readParamLen16(uint16_t* param_len = NULL);
+
+    static void sendBuffer(uint8_t* param, uint16_t param_len, uint8_t lastParam = NO_LAST_PARAM);
+
+    static void sendParam(uint16_t param, uint8_t lastParam = NO_LAST_PARAM);
+    
+    static void sendCmd(uint8_t cmd, uint8_t numParam);
+};                                                                 
+
+extern SpiDrv spiDrv;
+
+#endif
diff --git a/libraries/WiFi/utility/wifi_drv.cpp b/libraries/WiFi/utility/wifi_drv.cpp
index 01023d7..1ca1696 100644
--- a/libraries/WiFi/utility/wifi_drv.cpp
+++ b/libraries/WiFi/utility/wifi_drv.cpp
@@ -1,491 +1,491 @@
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-
-#include "Arduino.h"
-#include "spi_drv.h"
-#include "wifi_drv.h"
-
-#define _DEBUG_
-
-extern "C" {
-#include "wifi_spi.h"
-#include "wl_types.h"
-#include "debug.h"
-}
-
-// Array of data to cache the information related to the networks discovered
-char 	WiFiDrv::_networkSsid[][WL_SSID_MAX_LENGTH] = {{"1"},{"2"},{"3"},{"4"},{"5"}};
-int32_t WiFiDrv::_networkRssi[WL_NETWORKS_LIST_MAXNUM] = { 0 };
-uint8_t WiFiDrv::_networkEncr[WL_NETWORKS_LIST_MAXNUM] = { 0 };
-
-// Cached values of retrieved data
-char 	WiFiDrv::_ssid[] = {0};
-uint8_t	WiFiDrv::_bssid[] = {0};
-uint8_t WiFiDrv::_mac[] = {0};
-uint8_t WiFiDrv::_localIp[] = {0};
-uint8_t WiFiDrv::_subnetMask[] = {0};
-uint8_t WiFiDrv::_gatewayIp[] = {0};
-// Firmware version
-char    WiFiDrv::fwVersion[] = {0};
-
-
-// Private Methods
-
-void WiFiDrv::getNetworkData(uint8_t *ip, uint8_t *mask, uint8_t *gwip)
-{
-    tParam params[PARAM_NUMS_3] = { {0, (char*)ip}, {0, (char*)mask}, {0, (char*)gwip}};
-
-    WAIT_FOR_SLAVE_SELECT();
-
-    // Send Command
-    SpiDrv::sendCmd(GET_IPADDR_CMD, PARAM_NUMS_1);
-
-    uint8_t _dummy = DUMMY_DATA;
-    SpiDrv::sendParam(&_dummy, sizeof(_dummy), LAST_PARAM);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    SpiDrv::waitResponseParams(GET_IPADDR_CMD, PARAM_NUMS_3, params);
-
-    SpiDrv::spiSlaveDeselect();
-}
-
-// Public Methods
-
-
-void WiFiDrv::wifiDriverInit()
-{
-    SpiDrv::begin();
-}
-
-int8_t WiFiDrv::wifiSetNetwork(char* ssid, uint8_t ssid_len)
-{
-	WAIT_FOR_SLAVE_SELECT();
-    // Send Command
-    SpiDrv::sendCmd(SET_NET_CMD, PARAM_NUMS_1);
-    SpiDrv::sendParam((uint8_t*)ssid, ssid_len, LAST_PARAM);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t _data = 0;
-    uint8_t _dataLen = 0;
-    if (!SpiDrv::waitResponseCmd(SET_NET_CMD, PARAM_NUMS_1, &_data, &_dataLen))
-    {
-        WARN("error waitResponse");
-        _data = WL_FAILURE;
-    }
-    SpiDrv::spiSlaveDeselect();
-
-    return(_data == WIFI_SPI_ACK) ? WL_SUCCESS : WL_FAILURE;
-}
-
-int8_t WiFiDrv::wifiSetPassphrase(char* ssid, uint8_t ssid_len, const char *passphrase, const uint8_t len)
-{
-	WAIT_FOR_SLAVE_SELECT();
-    // Send Command
-    SpiDrv::sendCmd(SET_PASSPHRASE_CMD, PARAM_NUMS_2);
-    SpiDrv::sendParam((uint8_t*)ssid, ssid_len, NO_LAST_PARAM);
-    SpiDrv::sendParam((uint8_t*)passphrase, len, LAST_PARAM);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t _data = 0;
-    uint8_t _dataLen = 0;
-    if (!SpiDrv::waitResponseCmd(SET_PASSPHRASE_CMD, PARAM_NUMS_1, &_data, &_dataLen))
-    {
-        WARN("error waitResponse");
-        _data = WL_FAILURE;
-    }
-    SpiDrv::spiSlaveDeselect();
-    return _data;
-}
-
-
-int8_t WiFiDrv::wifiSetKey(char* ssid, uint8_t ssid_len, uint8_t key_idx, const void *key, const uint8_t len)
-{
-	WAIT_FOR_SLAVE_SELECT();
-    // Send Command
-    SpiDrv::sendCmd(SET_KEY_CMD, PARAM_NUMS_3);
-    SpiDrv::sendParam((uint8_t*)ssid, ssid_len, NO_LAST_PARAM);
-    SpiDrv::sendParam(&key_idx, KEY_IDX_LEN, NO_LAST_PARAM);
-    SpiDrv::sendParam((uint8_t*)key, len, LAST_PARAM);
-    
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t _data = 0;
-    uint8_t _dataLen = 0;
-    if (!SpiDrv::waitResponseCmd(SET_KEY_CMD, PARAM_NUMS_1, &_data, &_dataLen))
-    {
-        WARN("error waitResponse");
-        _data = WL_FAILURE;
-    }
-    SpiDrv::spiSlaveDeselect();
-    return _data;
-}
-                        
-int8_t WiFiDrv::disconnect()
-{
-	WAIT_FOR_SLAVE_SELECT();
-    // Send Command
-    SpiDrv::sendCmd(DISCONNECT_CMD, PARAM_NUMS_1);
-
-    uint8_t _dummy = DUMMY_DATA;
-    SpiDrv::sendParam(&_dummy, 1, LAST_PARAM);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t _data = 0;
-    uint8_t _dataLen = 0;
-    int8_t result = SpiDrv::waitResponseCmd(DISCONNECT_CMD, PARAM_NUMS_1, &_data, &_dataLen);
-
-    SpiDrv::spiSlaveDeselect();
-
-    return result;
-}
-
-uint8_t WiFiDrv::getConnectionStatus()
-{
-	WAIT_FOR_SLAVE_SELECT();
-
-    // Send Command
-    SpiDrv::sendCmd(GET_CONN_STATUS_CMD, PARAM_NUMS_0);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t _data = -1;
-    uint8_t _dataLen = 0;
-    SpiDrv::waitResponseCmd(GET_CONN_STATUS_CMD, PARAM_NUMS_1, &_data, &_dataLen);
-
-    SpiDrv::spiSlaveDeselect();
-
-    return _data;
-}
-
-uint8_t* WiFiDrv::getMacAddress()
-{
-	WAIT_FOR_SLAVE_SELECT();
-
-    // Send Command
-    SpiDrv::sendCmd(GET_MACADDR_CMD, PARAM_NUMS_1);
-
-    uint8_t _dummy = DUMMY_DATA;
-    SpiDrv::sendParam(&_dummy, 1, LAST_PARAM);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t _dataLen = 0;
-    SpiDrv::waitResponseCmd(GET_MACADDR_CMD, PARAM_NUMS_1, _mac, &_dataLen);
-
-    SpiDrv::spiSlaveDeselect();
-
-    return _mac;
-}
-
-void WiFiDrv::getIpAddress(IPAddress& ip)
-{
-	getNetworkData(_localIp, _subnetMask, _gatewayIp);
-	ip = _localIp;
-}
-
- void WiFiDrv::getSubnetMask(IPAddress& mask)
- {
-	getNetworkData(_localIp, _subnetMask, _gatewayIp);
-	mask = _subnetMask;
- }
-
- void WiFiDrv::getGatewayIP(IPAddress& ip)
- {
-	getNetworkData(_localIp, _subnetMask, _gatewayIp);
-	ip = _gatewayIp;
- }
-
-char* WiFiDrv::getCurrentSSID()
-{
-	WAIT_FOR_SLAVE_SELECT();
-
-    // Send Command
-    SpiDrv::sendCmd(GET_CURR_SSID_CMD, PARAM_NUMS_1);
-
-    uint8_t _dummy = DUMMY_DATA;
-    SpiDrv::sendParam(&_dummy, 1, LAST_PARAM);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t _dataLen = 0;
-    SpiDrv::waitResponseCmd(GET_CURR_SSID_CMD, PARAM_NUMS_1, (uint8_t*)_ssid, &_dataLen);
-
-    SpiDrv::spiSlaveDeselect();
-
-    return _ssid;
-}
-
-uint8_t* WiFiDrv::getCurrentBSSID()
-{
-	WAIT_FOR_SLAVE_SELECT();
-
-    // Send Command
-    SpiDrv::sendCmd(GET_CURR_BSSID_CMD, PARAM_NUMS_1);
-
-    uint8_t _dummy = DUMMY_DATA;
-    SpiDrv::sendParam(&_dummy, 1, LAST_PARAM);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t _dataLen = 0;
-    SpiDrv::waitResponseCmd(GET_CURR_BSSID_CMD, PARAM_NUMS_1, _bssid, &_dataLen);
-
-    SpiDrv::spiSlaveDeselect();
-
-    return _bssid;
-}
-
-int32_t WiFiDrv::getCurrentRSSI()
-{
-	WAIT_FOR_SLAVE_SELECT();
-
-    // Send Command
-    SpiDrv::sendCmd(GET_CURR_RSSI_CMD, PARAM_NUMS_1);
-
-    uint8_t _dummy = DUMMY_DATA;
-    SpiDrv::sendParam(&_dummy, 1, LAST_PARAM);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t _dataLen = 0;
-    int32_t rssi = 0;
-    SpiDrv::waitResponseCmd(GET_CURR_RSSI_CMD, PARAM_NUMS_1, (uint8_t*)&rssi, &_dataLen);
-
-    SpiDrv::spiSlaveDeselect();
-
-    return rssi;
-}
-
-uint8_t WiFiDrv::getCurrentEncryptionType()
-{
-	WAIT_FOR_SLAVE_SELECT();
-
-    // Send Command
-    SpiDrv::sendCmd(GET_CURR_ENCT_CMD, PARAM_NUMS_1);
-
-    uint8_t _dummy = DUMMY_DATA;
-    SpiDrv::sendParam(&_dummy, 1, LAST_PARAM);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t dataLen = 0;
-    uint8_t encType = 0;
-    SpiDrv::waitResponseCmd(GET_CURR_ENCT_CMD, PARAM_NUMS_1, (uint8_t*)&encType, &dataLen);
-
-    SpiDrv::spiSlaveDeselect();
-
-    return encType;
-}
-
-int8_t WiFiDrv::startScanNetworks()
-{
-	WAIT_FOR_SLAVE_SELECT();
-
-    // Send Command
-    SpiDrv::sendCmd(START_SCAN_NETWORKS, PARAM_NUMS_0);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t _data = 0;
-    uint8_t _dataLen = 0;
-
-    if (!SpiDrv::waitResponseCmd(START_SCAN_NETWORKS, PARAM_NUMS_1, &_data, &_dataLen))
-     {
-         WARN("error waitResponse");
-         _data = WL_FAILURE;
-     }
-
-    SpiDrv::spiSlaveDeselect();
-
-    return (_data == WL_FAILURE)? _data : WL_SUCCESS;
-}
-
-
-uint8_t WiFiDrv::getScanNetworks()
-{
-	WAIT_FOR_SLAVE_SELECT();
-
-    // Send Command
-    SpiDrv::sendCmd(SCAN_NETWORKS, PARAM_NUMS_0);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t ssidListNum = 0;
-    SpiDrv::waitResponse(SCAN_NETWORKS, &ssidListNum, (uint8_t**)_networkSsid, WL_NETWORKS_LIST_MAXNUM);
-
-    SpiDrv::spiSlaveDeselect();
-
-    return ssidListNum;
-}
-
-char* WiFiDrv::getSSIDNetoworks(uint8_t networkItem)
-{
-	if (networkItem >= WL_NETWORKS_LIST_MAXNUM)
-		return NULL;
-
-	return _networkSsid[networkItem];
-}
-
-uint8_t WiFiDrv::getEncTypeNetowrks(uint8_t networkItem)
-{
-	if (networkItem >= WL_NETWORKS_LIST_MAXNUM)
-		return NULL;
-
-	WAIT_FOR_SLAVE_SELECT();
-
-    // Send Command
-    SpiDrv::sendCmd(GET_IDX_ENCT_CMD, PARAM_NUMS_1);
-
-    SpiDrv::sendParam(&networkItem, 1, LAST_PARAM);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t dataLen = 0;
-    uint8_t encType = 0;
-    SpiDrv::waitResponseCmd(GET_IDX_ENCT_CMD, PARAM_NUMS_1, (uint8_t*)&encType, &dataLen);
-
-    SpiDrv::spiSlaveDeselect();
-
-    return encType;
-}
-
-int32_t WiFiDrv::getRSSINetoworks(uint8_t networkItem)
-{
-	if (networkItem >= WL_NETWORKS_LIST_MAXNUM)
-		return NULL;
-	int32_t	networkRssi = 0;
-
-	WAIT_FOR_SLAVE_SELECT();
-
-    // Send Command
-    SpiDrv::sendCmd(GET_IDX_RSSI_CMD, PARAM_NUMS_1);
-
-    SpiDrv::sendParam(&networkItem, 1, LAST_PARAM);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t dataLen = 0;
-    SpiDrv::waitResponseCmd(GET_IDX_RSSI_CMD, PARAM_NUMS_1, (uint8_t*)&networkRssi, &dataLen);
-
-    SpiDrv::spiSlaveDeselect();
-
-	return networkRssi;
-}
-
-uint8_t WiFiDrv::reqHostByName(const char* aHostname)
-{
-	WAIT_FOR_SLAVE_SELECT();
-
-    // Send Command
-    SpiDrv::sendCmd(REQ_HOST_BY_NAME_CMD, PARAM_NUMS_1);
-    SpiDrv::sendParam((uint8_t*)aHostname, strlen(aHostname), LAST_PARAM);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t _data = 0;
-    uint8_t _dataLen = 0;
-    uint8_t result = SpiDrv::waitResponseCmd(REQ_HOST_BY_NAME_CMD, PARAM_NUMS_1, &_data, &_dataLen);
-
-    SpiDrv::spiSlaveDeselect();
-
-    return result;
-}
-
-int WiFiDrv::getHostByName(IPAddress& aResult)
-{
-	uint8_t  _ipAddr[WL_IPV4_LENGTH];
-	IPAddress dummy(0xFF,0xFF,0xFF,0xFF);
-	int result = 0;
-
-	WAIT_FOR_SLAVE_SELECT();
-    // Send Command
-    SpiDrv::sendCmd(GET_HOST_BY_NAME_CMD, PARAM_NUMS_0);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t _dataLen = 0;
-    if (!SpiDrv::waitResponseCmd(GET_HOST_BY_NAME_CMD, PARAM_NUMS_1, _ipAddr, &_dataLen))
-    {
-        WARN("error waitResponse");
-    }else{
-    	aResult = _ipAddr;
-    	result = (aResult != dummy);
-    }
-    SpiDrv::spiSlaveDeselect();
-    return result;
-}
-
-int WiFiDrv::getHostByName(const char* aHostname, IPAddress& aResult)
-{
-	uint8_t retry = 10;
-	if (reqHostByName(aHostname))
-	{
-		while(!getHostByName(aResult) && --retry > 0)
-		{
-			delay(1000);
-		}
-	}else{
-		return 0;
-	}
-	return (retry>0);
-}
-
-char*  WiFiDrv::getFwVersion()
-{
-	WAIT_FOR_SLAVE_SELECT();
-    // Send Command
-    SpiDrv::sendCmd(GET_FW_VERSION_CMD, PARAM_NUMS_0);
-
-    //Wait the reply elaboration
-    SpiDrv::waitForSlaveReady();
-
-    // Wait for reply
-    uint8_t _dataLen = 0;
-    if (!SpiDrv::waitResponseCmd(GET_FW_VERSION_CMD, PARAM_NUMS_1, (uint8_t*)fwVersion, &_dataLen))
-    {
-        WARN("error waitResponse");
-    }
-    SpiDrv::spiSlaveDeselect();
-    return fwVersion;
-}
-
-WiFiDrv wiFiDrv;
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+
+#include "Arduino.h"
+#include "spi_drv.h"
+#include "wifi_drv.h"
+
+#define _DEBUG_
+
+extern "C" {
+#include "wifi_spi.h"
+#include "wl_types.h"
+#include "debug.h"
+}
+
+// Array of data to cache the information related to the networks discovered
+char 	WiFiDrv::_networkSsid[][WL_SSID_MAX_LENGTH] = {{"1"},{"2"},{"3"},{"4"},{"5"}};
+int32_t WiFiDrv::_networkRssi[WL_NETWORKS_LIST_MAXNUM] = { 0 };
+uint8_t WiFiDrv::_networkEncr[WL_NETWORKS_LIST_MAXNUM] = { 0 };
+
+// Cached values of retrieved data
+char 	WiFiDrv::_ssid[] = {0};
+uint8_t	WiFiDrv::_bssid[] = {0};
+uint8_t WiFiDrv::_mac[] = {0};
+uint8_t WiFiDrv::_localIp[] = {0};
+uint8_t WiFiDrv::_subnetMask[] = {0};
+uint8_t WiFiDrv::_gatewayIp[] = {0};
+// Firmware version
+char    WiFiDrv::fwVersion[] = {0};
+
+
+// Private Methods
+
+void WiFiDrv::getNetworkData(uint8_t *ip, uint8_t *mask, uint8_t *gwip)
+{
+    tParam params[PARAM_NUMS_3] = { {0, (char*)ip}, {0, (char*)mask}, {0, (char*)gwip}};
+
+    WAIT_FOR_SLAVE_SELECT();
+
+    // Send Command
+    SpiDrv::sendCmd(GET_IPADDR_CMD, PARAM_NUMS_1);
+
+    uint8_t _dummy = DUMMY_DATA;
+    SpiDrv::sendParam(&_dummy, sizeof(_dummy), LAST_PARAM);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    SpiDrv::waitResponseParams(GET_IPADDR_CMD, PARAM_NUMS_3, params);
+
+    SpiDrv::spiSlaveDeselect();
+}
+
+// Public Methods
+
+
+void WiFiDrv::wifiDriverInit()
+{
+    SpiDrv::begin();
+}
+
+int8_t WiFiDrv::wifiSetNetwork(char* ssid, uint8_t ssid_len)
+{
+	WAIT_FOR_SLAVE_SELECT();
+    // Send Command
+    SpiDrv::sendCmd(SET_NET_CMD, PARAM_NUMS_1);
+    SpiDrv::sendParam((uint8_t*)ssid, ssid_len, LAST_PARAM);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t _data = 0;
+    uint8_t _dataLen = 0;
+    if (!SpiDrv::waitResponseCmd(SET_NET_CMD, PARAM_NUMS_1, &_data, &_dataLen))
+    {
+        WARN("error waitResponse");
+        _data = WL_FAILURE;
+    }
+    SpiDrv::spiSlaveDeselect();
+
+    return(_data == WIFI_SPI_ACK) ? WL_SUCCESS : WL_FAILURE;
+}
+
+int8_t WiFiDrv::wifiSetPassphrase(char* ssid, uint8_t ssid_len, const char *passphrase, const uint8_t len)
+{
+	WAIT_FOR_SLAVE_SELECT();
+    // Send Command
+    SpiDrv::sendCmd(SET_PASSPHRASE_CMD, PARAM_NUMS_2);
+    SpiDrv::sendParam((uint8_t*)ssid, ssid_len, NO_LAST_PARAM);
+    SpiDrv::sendParam((uint8_t*)passphrase, len, LAST_PARAM);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t _data = 0;
+    uint8_t _dataLen = 0;
+    if (!SpiDrv::waitResponseCmd(SET_PASSPHRASE_CMD, PARAM_NUMS_1, &_data, &_dataLen))
+    {
+        WARN("error waitResponse");
+        _data = WL_FAILURE;
+    }
+    SpiDrv::spiSlaveDeselect();
+    return _data;
+}
+
+
+int8_t WiFiDrv::wifiSetKey(char* ssid, uint8_t ssid_len, uint8_t key_idx, const void *key, const uint8_t len)
+{
+	WAIT_FOR_SLAVE_SELECT();
+    // Send Command
+    SpiDrv::sendCmd(SET_KEY_CMD, PARAM_NUMS_3);
+    SpiDrv::sendParam((uint8_t*)ssid, ssid_len, NO_LAST_PARAM);
+    SpiDrv::sendParam(&key_idx, KEY_IDX_LEN, NO_LAST_PARAM);
+    SpiDrv::sendParam((uint8_t*)key, len, LAST_PARAM);
+    
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t _data = 0;
+    uint8_t _dataLen = 0;
+    if (!SpiDrv::waitResponseCmd(SET_KEY_CMD, PARAM_NUMS_1, &_data, &_dataLen))
+    {
+        WARN("error waitResponse");
+        _data = WL_FAILURE;
+    }
+    SpiDrv::spiSlaveDeselect();
+    return _data;
+}
+                        
+int8_t WiFiDrv::disconnect()
+{
+	WAIT_FOR_SLAVE_SELECT();
+    // Send Command
+    SpiDrv::sendCmd(DISCONNECT_CMD, PARAM_NUMS_1);
+
+    uint8_t _dummy = DUMMY_DATA;
+    SpiDrv::sendParam(&_dummy, 1, LAST_PARAM);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t _data = 0;
+    uint8_t _dataLen = 0;
+    int8_t result = SpiDrv::waitResponseCmd(DISCONNECT_CMD, PARAM_NUMS_1, &_data, &_dataLen);
+
+    SpiDrv::spiSlaveDeselect();
+
+    return result;
+}
+
+uint8_t WiFiDrv::getConnectionStatus()
+{
+	WAIT_FOR_SLAVE_SELECT();
+
+    // Send Command
+    SpiDrv::sendCmd(GET_CONN_STATUS_CMD, PARAM_NUMS_0);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t _data = -1;
+    uint8_t _dataLen = 0;
+    SpiDrv::waitResponseCmd(GET_CONN_STATUS_CMD, PARAM_NUMS_1, &_data, &_dataLen);
+
+    SpiDrv::spiSlaveDeselect();
+
+    return _data;
+}
+
+uint8_t* WiFiDrv::getMacAddress()
+{
+	WAIT_FOR_SLAVE_SELECT();
+
+    // Send Command
+    SpiDrv::sendCmd(GET_MACADDR_CMD, PARAM_NUMS_1);
+
+    uint8_t _dummy = DUMMY_DATA;
+    SpiDrv::sendParam(&_dummy, 1, LAST_PARAM);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t _dataLen = 0;
+    SpiDrv::waitResponseCmd(GET_MACADDR_CMD, PARAM_NUMS_1, _mac, &_dataLen);
+
+    SpiDrv::spiSlaveDeselect();
+
+    return _mac;
+}
+
+void WiFiDrv::getIpAddress(IPAddress& ip)
+{
+	getNetworkData(_localIp, _subnetMask, _gatewayIp);
+	ip = _localIp;
+}
+
+ void WiFiDrv::getSubnetMask(IPAddress& mask)
+ {
+	getNetworkData(_localIp, _subnetMask, _gatewayIp);
+	mask = _subnetMask;
+ }
+
+ void WiFiDrv::getGatewayIP(IPAddress& ip)
+ {
+	getNetworkData(_localIp, _subnetMask, _gatewayIp);
+	ip = _gatewayIp;
+ }
+
+char* WiFiDrv::getCurrentSSID()
+{
+	WAIT_FOR_SLAVE_SELECT();
+
+    // Send Command
+    SpiDrv::sendCmd(GET_CURR_SSID_CMD, PARAM_NUMS_1);
+
+    uint8_t _dummy = DUMMY_DATA;
+    SpiDrv::sendParam(&_dummy, 1, LAST_PARAM);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t _dataLen = 0;
+    SpiDrv::waitResponseCmd(GET_CURR_SSID_CMD, PARAM_NUMS_1, (uint8_t*)_ssid, &_dataLen);
+
+    SpiDrv::spiSlaveDeselect();
+
+    return _ssid;
+}
+
+uint8_t* WiFiDrv::getCurrentBSSID()
+{
+	WAIT_FOR_SLAVE_SELECT();
+
+    // Send Command
+    SpiDrv::sendCmd(GET_CURR_BSSID_CMD, PARAM_NUMS_1);
+
+    uint8_t _dummy = DUMMY_DATA;
+    SpiDrv::sendParam(&_dummy, 1, LAST_PARAM);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t _dataLen = 0;
+    SpiDrv::waitResponseCmd(GET_CURR_BSSID_CMD, PARAM_NUMS_1, _bssid, &_dataLen);
+
+    SpiDrv::spiSlaveDeselect();
+
+    return _bssid;
+}
+
+int32_t WiFiDrv::getCurrentRSSI()
+{
+	WAIT_FOR_SLAVE_SELECT();
+
+    // Send Command
+    SpiDrv::sendCmd(GET_CURR_RSSI_CMD, PARAM_NUMS_1);
+
+    uint8_t _dummy = DUMMY_DATA;
+    SpiDrv::sendParam(&_dummy, 1, LAST_PARAM);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t _dataLen = 0;
+    int32_t rssi = 0;
+    SpiDrv::waitResponseCmd(GET_CURR_RSSI_CMD, PARAM_NUMS_1, (uint8_t*)&rssi, &_dataLen);
+
+    SpiDrv::spiSlaveDeselect();
+
+    return rssi;
+}
+
+uint8_t WiFiDrv::getCurrentEncryptionType()
+{
+	WAIT_FOR_SLAVE_SELECT();
+
+    // Send Command
+    SpiDrv::sendCmd(GET_CURR_ENCT_CMD, PARAM_NUMS_1);
+
+    uint8_t _dummy = DUMMY_DATA;
+    SpiDrv::sendParam(&_dummy, 1, LAST_PARAM);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t dataLen = 0;
+    uint8_t encType = 0;
+    SpiDrv::waitResponseCmd(GET_CURR_ENCT_CMD, PARAM_NUMS_1, (uint8_t*)&encType, &dataLen);
+
+    SpiDrv::spiSlaveDeselect();
+
+    return encType;
+}
+
+int8_t WiFiDrv::startScanNetworks()
+{
+	WAIT_FOR_SLAVE_SELECT();
+
+    // Send Command
+    SpiDrv::sendCmd(START_SCAN_NETWORKS, PARAM_NUMS_0);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t _data = 0;
+    uint8_t _dataLen = 0;
+
+    if (!SpiDrv::waitResponseCmd(START_SCAN_NETWORKS, PARAM_NUMS_1, &_data, &_dataLen))
+     {
+         WARN("error waitResponse");
+         _data = WL_FAILURE;
+     }
+
+    SpiDrv::spiSlaveDeselect();
+
+    return (_data == WL_FAILURE)? _data : WL_SUCCESS;
+}
+
+
+uint8_t WiFiDrv::getScanNetworks()
+{
+	WAIT_FOR_SLAVE_SELECT();
+
+    // Send Command
+    SpiDrv::sendCmd(SCAN_NETWORKS, PARAM_NUMS_0);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t ssidListNum = 0;
+    SpiDrv::waitResponse(SCAN_NETWORKS, &ssidListNum, (uint8_t**)_networkSsid, WL_NETWORKS_LIST_MAXNUM);
+
+    SpiDrv::spiSlaveDeselect();
+
+    return ssidListNum;
+}
+
+char* WiFiDrv::getSSIDNetoworks(uint8_t networkItem)
+{
+	if (networkItem >= WL_NETWORKS_LIST_MAXNUM)
+		return NULL;
+
+	return _networkSsid[networkItem];
+}
+
+uint8_t WiFiDrv::getEncTypeNetowrks(uint8_t networkItem)
+{
+	if (networkItem >= WL_NETWORKS_LIST_MAXNUM)
+		return NULL;
+
+	WAIT_FOR_SLAVE_SELECT();
+
+    // Send Command
+    SpiDrv::sendCmd(GET_IDX_ENCT_CMD, PARAM_NUMS_1);
+
+    SpiDrv::sendParam(&networkItem, 1, LAST_PARAM);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t dataLen = 0;
+    uint8_t encType = 0;
+    SpiDrv::waitResponseCmd(GET_IDX_ENCT_CMD, PARAM_NUMS_1, (uint8_t*)&encType, &dataLen);
+
+    SpiDrv::spiSlaveDeselect();
+
+    return encType;
+}
+
+int32_t WiFiDrv::getRSSINetoworks(uint8_t networkItem)
+{
+	if (networkItem >= WL_NETWORKS_LIST_MAXNUM)
+		return NULL;
+	int32_t	networkRssi = 0;
+
+	WAIT_FOR_SLAVE_SELECT();
+
+    // Send Command
+    SpiDrv::sendCmd(GET_IDX_RSSI_CMD, PARAM_NUMS_1);
+
+    SpiDrv::sendParam(&networkItem, 1, LAST_PARAM);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t dataLen = 0;
+    SpiDrv::waitResponseCmd(GET_IDX_RSSI_CMD, PARAM_NUMS_1, (uint8_t*)&networkRssi, &dataLen);
+
+    SpiDrv::spiSlaveDeselect();
+
+	return networkRssi;
+}
+
+uint8_t WiFiDrv::reqHostByName(const char* aHostname)
+{
+	WAIT_FOR_SLAVE_SELECT();
+
+    // Send Command
+    SpiDrv::sendCmd(REQ_HOST_BY_NAME_CMD, PARAM_NUMS_1);
+    SpiDrv::sendParam((uint8_t*)aHostname, strlen(aHostname), LAST_PARAM);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t _data = 0;
+    uint8_t _dataLen = 0;
+    uint8_t result = SpiDrv::waitResponseCmd(REQ_HOST_BY_NAME_CMD, PARAM_NUMS_1, &_data, &_dataLen);
+
+    SpiDrv::spiSlaveDeselect();
+
+    return result;
+}
+
+int WiFiDrv::getHostByName(IPAddress& aResult)
+{
+	uint8_t  _ipAddr[WL_IPV4_LENGTH];
+	IPAddress dummy(0xFF,0xFF,0xFF,0xFF);
+	int result = 0;
+
+	WAIT_FOR_SLAVE_SELECT();
+    // Send Command
+    SpiDrv::sendCmd(GET_HOST_BY_NAME_CMD, PARAM_NUMS_0);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t _dataLen = 0;
+    if (!SpiDrv::waitResponseCmd(GET_HOST_BY_NAME_CMD, PARAM_NUMS_1, _ipAddr, &_dataLen))
+    {
+        WARN("error waitResponse");
+    }else{
+    	aResult = _ipAddr;
+    	result = (aResult != dummy);
+    }
+    SpiDrv::spiSlaveDeselect();
+    return result;
+}
+
+int WiFiDrv::getHostByName(const char* aHostname, IPAddress& aResult)
+{
+	uint8_t retry = 10;
+	if (reqHostByName(aHostname))
+	{
+		while(!getHostByName(aResult) && --retry > 0)
+		{
+			delay(1000);
+		}
+	}else{
+		return 0;
+	}
+	return (retry>0);
+}
+
+char*  WiFiDrv::getFwVersion()
+{
+	WAIT_FOR_SLAVE_SELECT();
+    // Send Command
+    SpiDrv::sendCmd(GET_FW_VERSION_CMD, PARAM_NUMS_0);
+
+    //Wait the reply elaboration
+    SpiDrv::waitForSlaveReady();
+
+    // Wait for reply
+    uint8_t _dataLen = 0;
+    if (!SpiDrv::waitResponseCmd(GET_FW_VERSION_CMD, PARAM_NUMS_1, (uint8_t*)fwVersion, &_dataLen))
+    {
+        WARN("error waitResponse");
+    }
+    SpiDrv::spiSlaveDeselect();
+    return fwVersion;
+}
+
+WiFiDrv wiFiDrv;
diff --git a/libraries/WiFi/utility/wifi_drv.h b/libraries/WiFi/utility/wifi_drv.h
index 8aeb8ae..c4f04db 100644
--- a/libraries/WiFi/utility/wifi_drv.h
+++ b/libraries/WiFi/utility/wifi_drv.h
@@ -1,219 +1,219 @@
-#ifndef WiFi_Drv_h
-#define WiFi_Drv_h
-
-#include <inttypes.h>
-#include "wifi_spi.h"
-#include "IPAddress.h"
-
-// Key index length
-#define KEY_IDX_LEN     1
-// 5 secs of delay to have the connection established
-#define WL_DELAY_START_CONNECTION 5000
-// firmware version string length
-#define WL_FW_VER_LENGTH 6
-
-class WiFiDrv
-{
-private:
-	// settings of requested network
-	static char 	_networkSsid[WL_NETWORKS_LIST_MAXNUM][WL_SSID_MAX_LENGTH];
-	static int32_t 	_networkRssi[WL_NETWORKS_LIST_MAXNUM];
-	static uint8_t 	_networkEncr[WL_NETWORKS_LIST_MAXNUM];
-
-	// firmware version string in the format a.b.c
-	static char 	fwVersion[WL_FW_VER_LENGTH];
-
-	// settings of current selected network
-	static char 	_ssid[WL_SSID_MAX_LENGTH];
-	static uint8_t 	_bssid[WL_MAC_ADDR_LENGTH];
-	static uint8_t 	_mac[WL_MAC_ADDR_LENGTH];
-	static uint8_t  _localIp[WL_IPV4_LENGTH];
-	static uint8_t  _subnetMask[WL_IPV4_LENGTH];
-	static uint8_t  _gatewayIp[WL_IPV4_LENGTH];
-
-	/*
-	 * Get network Data information
-	 */
-    static void getNetworkData(uint8_t *ip, uint8_t *mask, uint8_t *gwip);
-
-    static uint8_t reqHostByName(const char* aHostname);
-
-    static int getHostByName(IPAddress& aResult);
-
-public:
-
-    /*
-     * Driver initialization
-     */
-    static void wifiDriverInit();
-
-    /*
-     * Set the desired network which the connection manager should try to
-     * connect to.
-     *
-     * The ssid of the desired network should be specified.
-     *
-     * param ssid: The ssid of the desired network.
-     * param ssid_len: Lenght of ssid string.
-     * return: WL_SUCCESS or WL_FAILURE
-	 */
-    static int8_t wifiSetNetwork(char* ssid, uint8_t ssid_len);
-
-    /* Start Wifi connection with passphrase
-     * the most secure supported mode will be automatically selected
-     *
-     * param ssid: Pointer to the SSID string.
-     * param ssid_len: Lenght of ssid string.
-     * param passphrase: Passphrase. Valid characters in a passphrase
-     *        must be between ASCII 32-126 (decimal).
-     * param len: Lenght of passphrase string.
-     * return: WL_SUCCESS or WL_FAILURE
-     */
-    static int8_t wifiSetPassphrase(char* ssid, uint8_t ssid_len, const char *passphrase, const uint8_t len);
-
-    /* Start Wifi connection with WEP encryption.
-     * Configure a key into the device. The key type (WEP-40, WEP-104)
-     * is determined by the size of the key (5 bytes for WEP-40, 13 bytes for WEP-104).
-     *
-     * param ssid: Pointer to the SSID string.
-     * param ssid_len: Lenght of ssid string.
-     * param key_idx: The key index to set. Valid values are 0-3.
-     * param key: Key input buffer.
-     * param len: Lenght of key string.
-     * return: WL_SUCCESS or WL_FAILURE
-     */
-    static int8_t wifiSetKey(char* ssid, uint8_t ssid_len, uint8_t key_idx, const void *key, const uint8_t len);
-
-    /*
-     * Disconnect from the network
-     *
-     * return: WL_SUCCESS or WL_FAILURE
-     */
-    static int8_t disconnect();
-
-    /*
-     * Disconnect from the network
-     *
-     * return: one value of wl_status_t enum
-     */
-    static uint8_t getConnectionStatus();
-
-    /*
-     * Get the interface MAC address.
-     *
-     * return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
-     */
-    static uint8_t* getMacAddress();
-
-    /*
-     * Get the interface IP address.
-     *
-     * return: copy the ip address value in IPAddress object
-     */
-    static void getIpAddress(IPAddress& ip);
-
-    /*
-     * Get the interface subnet mask address.
-     *
-     * return: copy the subnet mask address value in IPAddress object
-     */
-    static void getSubnetMask(IPAddress& mask);
-
-    /*
-     * Get the gateway ip address.
-     *
-     * return: copy the gateway ip address value in IPAddress object
-     */
-    static void getGatewayIP(IPAddress& ip);
-
-    /*
-     * Return the current SSID associated with the network
-     *
-     * return: ssid string
-     */
-    static char* getCurrentSSID();
-
-    /*
-     * Return the current BSSID associated with the network.
-     * It is the MAC address of the Access Point
-     *
-     * return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
-     */
-    static uint8_t* getCurrentBSSID();
-
-    /*
-     * Return the current RSSI /Received Signal Strength in dBm)
-     * associated with the network
-     *
-     * return: signed value
-     */
-    static int32_t getCurrentRSSI();
-
-    /*
-     * Return the Encryption Type associated with the network
-     *
-     * return: one value of wl_enc_type enum
-     */
-    static uint8_t getCurrentEncryptionType();
-
-    /*
-     * Start scan WiFi networks available
-     *
-     * return: Number of discovered networks
-     */
-    static int8_t startScanNetworks();
-
-    /*
-     * Get the networks available
-     *
-     * return: Number of discovered networks
-     */
-    static uint8_t getScanNetworks();
-
-    /*
-     * Return the SSID discovered during the network scan.
-     *
-     * param networkItem: specify from which network item want to get the information
-	 *
-     * return: ssid string of the specified item on the networks scanned list
-     */
-    static char* getSSIDNetoworks(uint8_t networkItem);
-
-    /*
-     * Return the RSSI of the networks discovered during the scanNetworks
-     *
-     * param networkItem: specify from which network item want to get the information
-	 *
-     * return: signed value of RSSI of the specified item on the networks scanned list
-     */
-    static int32_t getRSSINetoworks(uint8_t networkItem);
-
-    /*
-     * Return the encryption type of the networks discovered during the scanNetworks
-     *
-     * param networkItem: specify from which network item want to get the information
-	 *
-     * return: encryption type (enum wl_enc_type) of the specified item on the networks scanned list
-     */
-    static uint8_t getEncTypeNetowrks(uint8_t networkItem);
-
-    /*
-     * Resolve the given hostname to an IP address.
-     * param aHostname: Name to be resolved
-     * param aResult: IPAddress structure to store the returned IP address
-     * result: 1 if aIPAddrString was successfully converted to an IP address,
-     *          else error code
-     */
-    static int getHostByName(const char* aHostname, IPAddress& aResult);
-
-    /*
-     * Get the firmware version
-     * result: version as string with this format a.b.c
-     */
-    static char* getFwVersion();
-
-};
-
-extern WiFiDrv wiFiDrv;
-
-#endif
+#ifndef WiFi_Drv_h
+#define WiFi_Drv_h
+
+#include <inttypes.h>
+#include "wifi_spi.h"
+#include "IPAddress.h"
+
+// Key index length
+#define KEY_IDX_LEN     1
+// 5 secs of delay to have the connection established
+#define WL_DELAY_START_CONNECTION 5000
+// firmware version string length
+#define WL_FW_VER_LENGTH 6
+
+class WiFiDrv
+{
+private:
+	// settings of requested network
+	static char 	_networkSsid[WL_NETWORKS_LIST_MAXNUM][WL_SSID_MAX_LENGTH];
+	static int32_t 	_networkRssi[WL_NETWORKS_LIST_MAXNUM];
+	static uint8_t 	_networkEncr[WL_NETWORKS_LIST_MAXNUM];
+
+	// firmware version string in the format a.b.c
+	static char 	fwVersion[WL_FW_VER_LENGTH];
+
+	// settings of current selected network
+	static char 	_ssid[WL_SSID_MAX_LENGTH];
+	static uint8_t 	_bssid[WL_MAC_ADDR_LENGTH];
+	static uint8_t 	_mac[WL_MAC_ADDR_LENGTH];
+	static uint8_t  _localIp[WL_IPV4_LENGTH];
+	static uint8_t  _subnetMask[WL_IPV4_LENGTH];
+	static uint8_t  _gatewayIp[WL_IPV4_LENGTH];
+
+	/*
+	 * Get network Data information
+	 */
+    static void getNetworkData(uint8_t *ip, uint8_t *mask, uint8_t *gwip);
+
+    static uint8_t reqHostByName(const char* aHostname);
+
+    static int getHostByName(IPAddress& aResult);
+
+public:
+
+    /*
+     * Driver initialization
+     */
+    static void wifiDriverInit();
+
+    /*
+     * Set the desired network which the connection manager should try to
+     * connect to.
+     *
+     * The ssid of the desired network should be specified.
+     *
+     * param ssid: The ssid of the desired network.
+     * param ssid_len: Lenght of ssid string.
+     * return: WL_SUCCESS or WL_FAILURE
+	 */
+    static int8_t wifiSetNetwork(char* ssid, uint8_t ssid_len);
+
+    /* Start Wifi connection with passphrase
+     * the most secure supported mode will be automatically selected
+     *
+     * param ssid: Pointer to the SSID string.
+     * param ssid_len: Lenght of ssid string.
+     * param passphrase: Passphrase. Valid characters in a passphrase
+     *        must be between ASCII 32-126 (decimal).
+     * param len: Lenght of passphrase string.
+     * return: WL_SUCCESS or WL_FAILURE
+     */
+    static int8_t wifiSetPassphrase(char* ssid, uint8_t ssid_len, const char *passphrase, const uint8_t len);
+
+    /* Start Wifi connection with WEP encryption.
+     * Configure a key into the device. The key type (WEP-40, WEP-104)
+     * is determined by the size of the key (5 bytes for WEP-40, 13 bytes for WEP-104).
+     *
+     * param ssid: Pointer to the SSID string.
+     * param ssid_len: Lenght of ssid string.
+     * param key_idx: The key index to set. Valid values are 0-3.
+     * param key: Key input buffer.
+     * param len: Lenght of key string.
+     * return: WL_SUCCESS or WL_FAILURE
+     */
+    static int8_t wifiSetKey(char* ssid, uint8_t ssid_len, uint8_t key_idx, const void *key, const uint8_t len);
+
+    /*
+     * Disconnect from the network
+     *
+     * return: WL_SUCCESS or WL_FAILURE
+     */
+    static int8_t disconnect();
+
+    /*
+     * Disconnect from the network
+     *
+     * return: one value of wl_status_t enum
+     */
+    static uint8_t getConnectionStatus();
+
+    /*
+     * Get the interface MAC address.
+     *
+     * return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
+     */
+    static uint8_t* getMacAddress();
+
+    /*
+     * Get the interface IP address.
+     *
+     * return: copy the ip address value in IPAddress object
+     */
+    static void getIpAddress(IPAddress& ip);
+
+    /*
+     * Get the interface subnet mask address.
+     *
+     * return: copy the subnet mask address value in IPAddress object
+     */
+    static void getSubnetMask(IPAddress& mask);
+
+    /*
+     * Get the gateway ip address.
+     *
+     * return: copy the gateway ip address value in IPAddress object
+     */
+    static void getGatewayIP(IPAddress& ip);
+
+    /*
+     * Return the current SSID associated with the network
+     *
+     * return: ssid string
+     */
+    static char* getCurrentSSID();
+
+    /*
+     * Return the current BSSID associated with the network.
+     * It is the MAC address of the Access Point
+     *
+     * return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
+     */
+    static uint8_t* getCurrentBSSID();
+
+    /*
+     * Return the current RSSI /Received Signal Strength in dBm)
+     * associated with the network
+     *
+     * return: signed value
+     */
+    static int32_t getCurrentRSSI();
+
+    /*
+     * Return the Encryption Type associated with the network
+     *
+     * return: one value of wl_enc_type enum
+     */
+    static uint8_t getCurrentEncryptionType();
+
+    /*
+     * Start scan WiFi networks available
+     *
+     * return: Number of discovered networks
+     */
+    static int8_t startScanNetworks();
+
+    /*
+     * Get the networks available
+     *
+     * return: Number of discovered networks
+     */
+    static uint8_t getScanNetworks();
+
+    /*
+     * Return the SSID discovered during the network scan.
+     *
+     * param networkItem: specify from which network item want to get the information
+	 *
+     * return: ssid string of the specified item on the networks scanned list
+     */
+    static char* getSSIDNetoworks(uint8_t networkItem);
+
+    /*
+     * Return the RSSI of the networks discovered during the scanNetworks
+     *
+     * param networkItem: specify from which network item want to get the information
+	 *
+     * return: signed value of RSSI of the specified item on the networks scanned list
+     */
+    static int32_t getRSSINetoworks(uint8_t networkItem);
+
+    /*
+     * Return the encryption type of the networks discovered during the scanNetworks
+     *
+     * param networkItem: specify from which network item want to get the information
+	 *
+     * return: encryption type (enum wl_enc_type) of the specified item on the networks scanned list
+     */
+    static uint8_t getEncTypeNetowrks(uint8_t networkItem);
+
+    /*
+     * Resolve the given hostname to an IP address.
+     * param aHostname: Name to be resolved
+     * param aResult: IPAddress structure to store the returned IP address
+     * result: 1 if aIPAddrString was successfully converted to an IP address,
+     *          else error code
+     */
+    static int getHostByName(const char* aHostname, IPAddress& aResult);
+
+    /*
+     * Get the firmware version
+     * result: version as string with this format a.b.c
+     */
+    static char* getFwVersion();
+
+};
+
+extern WiFiDrv wiFiDrv;
+
+#endif
diff --git a/libraries/WiFi/utility/wifi_spi.h b/libraries/WiFi/utility/wifi_spi.h
index adf8bef..bf479e2 100644
--- a/libraries/WiFi/utility/wifi_spi.h
+++ b/libraries/WiFi/utility/wifi_spi.h
@@ -1,144 +1,144 @@
-#ifndef WiFi_Spi_h
-#define WiFi_Spi_h
-
-#include "wl_definitions.h"
-
-#define CMD_FLAG        0
-#define REPLY_FLAG      1<<7
-#define DATA_FLAG 		0x40
-
-#define WIFI_SPI_ACK        1
-#define WIFI_SPI_ERR        0xFF
-
-#define TIMEOUT_CHAR    1000
-
-//#define	MAX_SOCK_NUM		4	/**< Maxmium number of socket  */
-#define NO_SOCKET_AVAIL     255
-
-#define START_CMD   0xE0
-#define END_CMD     0xEE
-#define ERR_CMD   	0xEF
-  
-enum {
-	SET_NET_CMD 		= 0x10,
-	SET_PASSPHRASE_CMD	= 0x11,
-	SET_KEY_CMD	        = 0x12,
-	TEST_CMD	        = 0x13,
-
-	GET_CONN_STATUS_CMD	= 0x20,
-	GET_IPADDR_CMD		= 0x21,
-	GET_MACADDR_CMD		= 0x22,
-	GET_CURR_SSID_CMD	= 0x23,
-	GET_CURR_BSSID_CMD	= 0x24,
-	GET_CURR_RSSI_CMD	= 0x25,
-	GET_CURR_ENCT_CMD	= 0x26,
-	SCAN_NETWORKS		= 0x27,
-	START_SERVER_TCP_CMD= 0x28,
-	GET_STATE_TCP_CMD   = 0x29,
-	DATA_SENT_TCP_CMD	= 0x2A,
-    AVAIL_DATA_TCP_CMD	= 0x2B,
-    GET_DATA_TCP_CMD	= 0x2C,
-    START_CLIENT_TCP_CMD= 0x2D,
-    STOP_CLIENT_TCP_CMD = 0x2E,
-    GET_CLIENT_STATE_TCP_CMD= 0x2F,
-    DISCONNECT_CMD		= 0x30,
-	GET_IDX_SSID_CMD	= 0x31,
-	GET_IDX_RSSI_CMD	= 0x32,
-	GET_IDX_ENCT_CMD	= 0x33,
-	REQ_HOST_BY_NAME_CMD= 0x34,
-	GET_HOST_BY_NAME_CMD= 0x35,
-	START_SCAN_NETWORKS	= 0x36,
-	GET_FW_VERSION_CMD	= 0x37,
-
-    // All command with DATA_FLAG 0x40 send a 16bit Len
-
-	SEND_DATA_TCP_CMD		= 0x44,
-    GET_DATABUF_TCP_CMD		= 0x45,
-};
-
-
-enum wl_tcp_state {
-  CLOSED      = 0,
-  LISTEN      = 1,
-  SYN_SENT    = 2,
-  SYN_RCVD    = 3,
-  ESTABLISHED = 4,
-  FIN_WAIT_1  = 5,
-  FIN_WAIT_2  = 6,
-  CLOSE_WAIT  = 7,
-  CLOSING     = 8,
-  LAST_ACK    = 9,
-  TIME_WAIT   = 10
-};
-
-
-enum numParams{
-    PARAM_NUMS_0,
-    PARAM_NUMS_1,
-    PARAM_NUMS_2,
-    PARAM_NUMS_3,
-    PARAM_NUMS_4,
-    PARAM_NUMS_5,
-    MAX_PARAM_NUMS
-};
-
-#define MAX_PARAMS MAX_PARAM_NUMS-1
-#define PARAM_LEN_SIZE 1
-
-typedef struct  __attribute__((__packed__))
-{
-	uint8_t     paramLen;
-	char*	    param;
-}tParam;
-
-typedef struct  __attribute__((__packed__))
-{
-	uint16_t     dataLen;
-	char*	     data;
-}tDataParam;
-
-
-typedef struct  __attribute__((__packed__))
-{
-	unsigned char	cmd;
-	unsigned char	tcmd;
-	unsigned char	nParam;
-	tParam	params[MAX_PARAMS];
-}tSpiMsg;
-
-typedef struct  __attribute__((__packed__))
-{
-	unsigned char	cmd;
-	unsigned char	tcmd;
-	unsigned char	nParam;
-	tDataParam		params[MAX_PARAMS];
-}tSpiMsgData;
-
-
-typedef struct  __attribute__((__packed__))
-{
-	unsigned char	cmd;
-	unsigned char	tcmd;
-	//unsigned char	totLen;
-	unsigned char	nParam;
-}tSpiHdr;
-
-typedef struct  __attribute__((__packed__))
-{
-	uint8_t     paramLen;
-	uint32_t	param;
-}tLongParam;
-
-typedef struct  __attribute__((__packed__))
-{
-	uint8_t     paramLen;
-	uint16_t	param;
-}tIntParam;
-
-typedef struct  __attribute__((__packed__))
-{
-	uint8_t     paramLen;
-	uint8_t	param;
-}tByteParam;
-
-#endif
+#ifndef WiFi_Spi_h
+#define WiFi_Spi_h
+
+#include "wl_definitions.h"
+
+#define CMD_FLAG        0
+#define REPLY_FLAG      1<<7
+#define DATA_FLAG 		0x40
+
+#define WIFI_SPI_ACK        1
+#define WIFI_SPI_ERR        0xFF
+
+#define TIMEOUT_CHAR    1000
+
+//#define	MAX_SOCK_NUM		4	/**< Maxmium number of socket  */
+#define NO_SOCKET_AVAIL     255
+
+#define START_CMD   0xE0
+#define END_CMD     0xEE
+#define ERR_CMD   	0xEF
+  
+enum {
+	SET_NET_CMD 		= 0x10,
+	SET_PASSPHRASE_CMD	= 0x11,
+	SET_KEY_CMD	        = 0x12,
+	TEST_CMD	        = 0x13,
+
+	GET_CONN_STATUS_CMD	= 0x20,
+	GET_IPADDR_CMD		= 0x21,
+	GET_MACADDR_CMD		= 0x22,
+	GET_CURR_SSID_CMD	= 0x23,
+	GET_CURR_BSSID_CMD	= 0x24,
+	GET_CURR_RSSI_CMD	= 0x25,
+	GET_CURR_ENCT_CMD	= 0x26,
+	SCAN_NETWORKS		= 0x27,
+	START_SERVER_TCP_CMD= 0x28,
+	GET_STATE_TCP_CMD   = 0x29,
+	DATA_SENT_TCP_CMD	= 0x2A,
+    AVAIL_DATA_TCP_CMD	= 0x2B,
+    GET_DATA_TCP_CMD	= 0x2C,
+    START_CLIENT_TCP_CMD= 0x2D,
+    STOP_CLIENT_TCP_CMD = 0x2E,
+    GET_CLIENT_STATE_TCP_CMD= 0x2F,
+    DISCONNECT_CMD		= 0x30,
+	GET_IDX_SSID_CMD	= 0x31,
+	GET_IDX_RSSI_CMD	= 0x32,
+	GET_IDX_ENCT_CMD	= 0x33,
+	REQ_HOST_BY_NAME_CMD= 0x34,
+	GET_HOST_BY_NAME_CMD= 0x35,
+	START_SCAN_NETWORKS	= 0x36,
+	GET_FW_VERSION_CMD	= 0x37,
+
+    // All command with DATA_FLAG 0x40 send a 16bit Len
+
+	SEND_DATA_TCP_CMD		= 0x44,
+    GET_DATABUF_TCP_CMD		= 0x45,
+};
+
+
+enum wl_tcp_state {
+  CLOSED      = 0,
+  LISTEN      = 1,
+  SYN_SENT    = 2,
+  SYN_RCVD    = 3,
+  ESTABLISHED = 4,
+  FIN_WAIT_1  = 5,
+  FIN_WAIT_2  = 6,
+  CLOSE_WAIT  = 7,
+  CLOSING     = 8,
+  LAST_ACK    = 9,
+  TIME_WAIT   = 10
+};
+
+
+enum numParams{
+    PARAM_NUMS_0,
+    PARAM_NUMS_1,
+    PARAM_NUMS_2,
+    PARAM_NUMS_3,
+    PARAM_NUMS_4,
+    PARAM_NUMS_5,
+    MAX_PARAM_NUMS
+};
+
+#define MAX_PARAMS MAX_PARAM_NUMS-1
+#define PARAM_LEN_SIZE 1
+
+typedef struct  __attribute__((__packed__))
+{
+	uint8_t     paramLen;
+	char*	    param;
+}tParam;
+
+typedef struct  __attribute__((__packed__))
+{
+	uint16_t     dataLen;
+	char*	     data;
+}tDataParam;
+
+
+typedef struct  __attribute__((__packed__))
+{
+	unsigned char	cmd;
+	unsigned char	tcmd;
+	unsigned char	nParam;
+	tParam	params[MAX_PARAMS];
+}tSpiMsg;
+
+typedef struct  __attribute__((__packed__))
+{
+	unsigned char	cmd;
+	unsigned char	tcmd;
+	unsigned char	nParam;
+	tDataParam		params[MAX_PARAMS];
+}tSpiMsgData;
+
+
+typedef struct  __attribute__((__packed__))
+{
+	unsigned char	cmd;
+	unsigned char	tcmd;
+	//unsigned char	totLen;
+	unsigned char	nParam;
+}tSpiHdr;
+
+typedef struct  __attribute__((__packed__))
+{
+	uint8_t     paramLen;
+	uint32_t	param;
+}tLongParam;
+
+typedef struct  __attribute__((__packed__))
+{
+	uint8_t     paramLen;
+	uint16_t	param;
+}tIntParam;
+
+typedef struct  __attribute__((__packed__))
+{
+	uint8_t     paramLen;
+	uint8_t	param;
+}tByteParam;
+
+#endif
diff --git a/libraries/WiFi/utility/wl_types.h b/libraries/WiFi/utility/wl_types.h
index 5eed7ee..82b309d 100644
--- a/libraries/WiFi/utility/wl_types.h
+++ b/libraries/WiFi/utility/wl_types.h
@@ -1,31 +1,31 @@
-/*
- * wl_types.h
- *
- *  Created on: Jul 30, 2010
- *      Author: dlafauci
- */
-
-
-#ifndef	_WL_TYPES_H_
-#define	_WL_TYPES_H_
-
-#include <inttypes.h>
-
-typedef enum {
-        WL_FAILURE = -1,
-        WL_SUCCESS = 1,
-} wl_error_code_t;
-
-/* Authentication modes */
-enum wl_auth_mode {
-        AUTH_MODE_INVALID,
-        AUTH_MODE_AUTO,
-        AUTH_MODE_OPEN_SYSTEM,
-        AUTH_MODE_SHARED_KEY,
-        AUTH_MODE_WPA,
-        AUTH_MODE_WPA2,
-        AUTH_MODE_WPA_PSK,
-        AUTH_MODE_WPA2_PSK
-};
-
-#endif //_WL_TYPES_H_
+/*
+ * wl_types.h
+ *
+ *  Created on: Jul 30, 2010
+ *      Author: dlafauci
+ */
+
+
+#ifndef	_WL_TYPES_H_
+#define	_WL_TYPES_H_
+
+#include <inttypes.h>
+
+typedef enum {
+        WL_FAILURE = -1,
+        WL_SUCCESS = 1,
+} wl_error_code_t;
+
+/* Authentication modes */
+enum wl_auth_mode {
+        AUTH_MODE_INVALID,
+        AUTH_MODE_AUTO,
+        AUTH_MODE_OPEN_SYSTEM,
+        AUTH_MODE_SHARED_KEY,
+        AUTH_MODE_WPA,
+        AUTH_MODE_WPA2,
+        AUTH_MODE_WPA_PSK,
+        AUTH_MODE_WPA2_PSK
+};
+
+#endif //_WL_TYPES_H_
diff --git a/libraries/Wire/Wire.cpp b/libraries/Wire/Wire.cpp
old mode 100755
new mode 100644
diff --git a/libraries/Wire/Wire.h b/libraries/Wire/Wire.h
old mode 100755
new mode 100644
diff --git a/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino b/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino
old mode 100755
new mode 100644
diff --git a/libraries/Wire/utility/twi.h b/libraries/Wire/utility/twi.h
old mode 100755
new mode 100644



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]