Friday, April 22, 2016

YellowJacket Arduino with WiShield Wifi (Part 18)

Improvements of the WiShield Library — 
The WiShield Library (GregEigsti et al., WiShield_user_contrib) has many versions on GitHub since the original Library was contributed by AsyncLabs (2009). It takes some effort to sort through the various user contributions to determine if the code changes affect what a developer needs for their app. Some improvements to the WiShield Library that seem useful include: adding DHCP/DNS rather than having to use fixed ip addresses, UDP was reported to have been improved, and, a 32-byte precalculated security key reduces Wifi init time from about 30 seconds to about 6 seconds. DEBUGU was added which implemented printx/printlnx functions for sending char strings to the sketch for printing debug information on Serial Monitor. In addition, the 6-7 digit limit of accuracy for the dtostrf function was added to include a function of using long integer values for representing float numbers.
Adding DHCP/DNS
Ref: https://github.com/asynclabs/WiShield_user_contrib (Named Version 1.2 for clarity)
WiShield V1.2 was downloaded and tested to determine if UDP had been improved over WiShield V3 (see Part 4 of this series for a discussion about Version 3). V1.2 includes DNS and additional UDP code. V1.2 required code fixes typical of pre-Arduino_V1.6.5. Once those fixes were made, library Example sketches WiServerDNS_V12_01 and WiFiScan_V12_01 were compiled and run on YJ57 connected through the USB FTDI programmer port.
The WiServerDNS_V12_01 sketch successfully used the following code which used DNS in the GETrequest to request the current LAX weather from w1.weather.gov:
/*****************************************************************************/
// Using DNS to return weather data
uint8 ip[] = {23, 67, 242, 42}; // IP Address for w1.weather.gov (2016-02-25)
// Returned:
//    DNS ADDR RECEIVED: 65.202.58.9
//    DNS ADDR RECEIVED: 65.202.58.54

char destURL[]                 = {"w1.weather.gov"};
char destGet[]                 = {"/data/METAR/KLAX.1.txt"};

// A request that gets the latest METAR weather data for LAX
//GETrequest getWeather(ip, 80, "w1.weather.gov", "/data/METAR/KLAX.1.txt");
GETrequest getWeather(ip, 80, destURL, destGet);
// ...
/*****************************************************************************/
WiFiScan_V12_01 sketch returned the rssi: values for ssid:’s that were identified as the app ran.
The following Data Logger sketches also run successfully with WiShield V1.2 installed:
  • ds1307_RTC – real time clock app
  • ADX_dumpFram_01 – FRAM memory report
  • SPI_SD_FRAM_Wifi_test – Checks SPI switching with several devices connected
  • RD_RamDiskToSdFat – File TEST.CSV was written to FRAM memory
  • ADX_dumpFram_01 was rerun to view FRAM memory after TEST.CSV write
WiShield V1.3 with DNS
Ref: github.com/CapnBry/WiShield_user_contrib (Named Version 1.3 for clarity)
WiShield V1.3 was downloaded and tested to determine if UDP had been improved over WiShield V3. V1.3 includes DNS and additional UDP code. V1.3 required code fixes typical of pre-Arduino_V1.6.5. Once those fixes were made, sketches WiServerDNS_V13_01 and WiFiScan_V13_01 were compiled and run on YJ57 connected through the USB FTDI programmer port.
V1.3 has many changes to V1.2 that need to be assessed if they make any value added improvements.
A 32-byte precalculated security key was generated and tested in WiServerDNS_V13_02 and WiFiScan_V13_02. The init time was significantly reduced.
“– Merges all the WEP / WPA into one variable, called security_data.
This saves on code space and the user can only use one at a time
anyway
— Adds WPA / WPA2 Precalc as a security type.
This is a 32 byte precalculated key so the g2100 doesn’t have to do it on
every boot. Reduces startup time from 35 seconds to 6 seconds.”
WiShield V1.4 with DNS, port to IDE 1.6.7
Ref: https://github.com/hamityanik/WiShield_user_contrib (2016-01-05, Named Version 1.4 for clarity)
The best part about this version is that it compiles without errors on Arduino Uno IDE 1.6.5. This version was added to the local Arduino/Libraries as WiShield_V14 and has become the current WiShield development library. In this V1.4, the previous requirement to edit uip-conf.h to set the “UIP_UDP_ENABLED 0/1” was moved to apps-cont.h and is set as part of selecting “#define APP_UDPAPP”. “boolean” definition needs to be commented out (//typedef uint8_t boolean;) in witypes.h to fix conflicts between BOOL and boolean. Also, other edits for JSON in previous parts of this series were made:
In strings.h, add:
“const char PROGMEM contentTypeJson[] = {“Content-Type: application/json; charset=utf-8″};”
, and in WiServerIO.h/.cpp
“extern const char PROGMEM contentTypeJson[];”
“int fType = 0;”
“void setContentType(int value){ fType = value; }”
also need to be made.
Versions 1.3 and 1.4, can use the 32-byte precalculated security key, rather than previous WPA/WEP keys. The user must calculate the security key and modify Arduino sketches to use the new key. See Examples: SocketApp.ino for details about how to create the security key and how to use it in a sketch.
WiServerDNS_V12_01 sketch (portion above) was successfully compiled with the local network ip’s and 32-byte precalculated security key and run on YJ57 connected through the USB FTDI programmer port.
Other versions of WiShield_user_contrib which might be useful:
WiShield_Cameronr_user_contrib-master 2011-08-26
Ref: github.com/cameronr/WiShield_user_contrib
WiShield_SamCleaver_user_contrib-master 2012-10-30
Ref: github.com/SamCleaver/WiShield_user_contrib
Future parts to this series will contain code examples for using the Version 1.4 WiShield code. Feel free to download Version 1.4, generate a Security Key, and get some demo examples working. That will help find bugs in variable definitions and inconsistencies that might exist.

(Apr 22, 2016)

No comments:

Post a Comment