Pages: [1]   Go Down
Author Topic: Original Wifi Shield - major problems  (Read 1250 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 Hi,

I'm new to Arduino with Wifi Shield but I'm having the following problems:
1.) I'm using SSIDs with 32 chars and WPA2 keys with 63 chars: Arduino WiFi Shield is not ready for that
a.) ScanNetworks prints wrong SSIDs because no zero string termination is done (some buffer definitions are 1 byte too short)
b.) Therefore I guess I can't connect to my WLAN (another bug in comparison)
Patches can be find below in the next 2 posts.

2.) Therefore I tried to update the firmware from version from 23.10.2012 to 24.12.2012. Download was successful but I always get WiFi shield not present (link LED=green, error LED=red)
Tried also a selfmade custom AVRStudio6 build, downloaded it successfully but with same behavior ("WiFi shield not present"), (link LED=green, error LED=red).
Version 23.10.2012 firmware only L9 LED light shortly, no other LEDs are on.

# Windows:
# DNLD Module (DNLD=Download?)
dfu-programmer-0.5.5.exe at32uc3a1256 erase
dfu-programmer-0.5.5.exe at32uc3a1256 flash --suppress-bootloader-mem wifi_dnld.hex
dfu-programmer-0.5.5.exe at32uc3a1256 start
# WiFi Shield
dfu-programmer-0.5.5.exe at32uc3a1256 erase
dfu-programmer-0.5.5.exe at32uc3a1256 flash --suppress-bootloader-mem wifiHD.hex
dfu-programmer-0.5.5.exe at32uc3a1256 start

Some solutions I've already found for newbies:
1.) You need either external power supply or an USB Y-connector with 2 connected ports for more power
2.) I sometimes get WiFi shield not present: seems to be a startup problem that WiFi shield isn't ready:
changed code to:
  // check for the presence of the shield:
  while (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    delay(100);
  }

Any ideas how to get own build to work?

Also some hints for newbies:
http://arduino.cc/en/Guide/Windows
1.) Select Right COM Port (Tools -> Serial Port)
2.) Select Board Type (Tools -> Board)
3.) Disable Bluetooth (Menu slowdown)!!!
4.) Provide enough power to the board with 2 connector USB cable!!!

wiesl
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Patches can be find below in the next 2 posts.

Patch part 1:
Code:
diff --git a/firmware/wifiHD/src/ard_spi.c b/firmware/wifiHD/src/ard_spi.c
index a5ef895..fcc7794 100644
--- a/firmware/wifiHD/src/ard_spi.c
+++ b/firmware/wifiHD/src/ard_spi.c
@@ -413,7 +413,7 @@ int set_net_cmd_cb(int numParam, char* buf, void* ctx) {
  wl_err_t err = WL_FAILURE;
  tParam* param = (tParam*) buf;
 
- if (param->paramLen < WL_SSID_MAX_LENGTH) {
+ if (param->paramLen <= WL_SSID_MAX_LENGTH) {
  memcpy(ssid.ssid, &param->param, param->paramLen);
  ssid.len = param->paramLen;
  ssid.ssid[ssid.len] = 0;
@@ -444,7 +444,7 @@ int set_key_cmd_cb(int numParam, char* buf, void* ctx) {
     // SSID
     memset(&ssid, 0, sizeof ssid);
 
- if (params->paramLen < WL_SSID_MAX_LENGTH) {
+ if (params->paramLen <= WL_SSID_MAX_LENGTH) {
  memcpy(ssid.ssid, &params->param, params->paramLen);
  ssid.len = params->paramLen;
  INFO_SPI("%s\n", ssid.ssid);
@@ -506,7 +506,7 @@ int set_passphrase_cmd_cb(int numParam, char* buf, void* ctx) {
     net.enc_type = ENC_TYPE_AUTO;
 
     // SSID
- if (params->paramLen < WL_SSID_MAX_LENGTH) {
+ if (params->paramLen <= WL_SSID_MAX_LENGTH) {
  memcpy(net.ssid.ssid, &params->param, params->paramLen);
  net.ssid.len = params->paramLen;
  INFO_SPI("%s %d\n", net.ssid.ssid, net.ssid.len);
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Patches can be find below in the next 2 posts.

Patch part 2:
Code:
diff --git a/libraries/WiFi/WiFi.cpp b/libraries/WiFi/WiFi.cpp
index c0cb001..72e0b1b 100755
--- a/libraries/WiFi/WiFi.cpp
+++ b/libraries/WiFi/WiFi.cpp
@@ -173,17 +173,17 @@ int8_t WiFiClass::scanNetworks()
 
 char* WiFiClass::SSID(uint8_t networkItem)
 {
- return WiFiDrv::getSSIDNetoworks(networkItem);
+ return WiFiDrv::getSSIDNetworks(networkItem);
 }
 
 int32_t WiFiClass::RSSI(uint8_t networkItem)
 {
- return WiFiDrv::getRSSINetoworks(networkItem);
+ return WiFiDrv::getRSSINetworks(networkItem);
 }
 
 uint8_t WiFiClass::encryptionType(uint8_t networkItem)
 {
-    return WiFiDrv::getEncTypeNetowrks(networkItem);
+    return WiFiDrv::getEncTypeNetworks(networkItem);
 }
 
 uint8_t WiFiClass::status()
diff --git a/libraries/WiFi/utility/spi_drv.cpp b/libraries/WiFi/utility/spi_drv.cpp
index 12a320b..77a9c78 100644
--- a/libraries/WiFi/utility/spi_drv.cpp
+++ b/libraries/WiFi/utility/spi_drv.cpp
@@ -347,10 +347,10 @@ int SpiDrv::waitResponse(uint8_t cmd, uint8_t* numParamRead, uint8_t** params, u
     char _data = 0;
     int i =0, ii = 0;
 
-    char    *index[WL_SSID_MAX_LENGTH];
+    char    *index[WL_SSID_MAX_LENGTH + 1];
 
     for (i = 0 ; i < WL_NETWORKS_LIST_MAXNUM ; i++)
-            index[i] = (char *)params + WL_SSID_MAX_LENGTH*i;
+            index[i] = (char *)params + (WL_SSID_MAX_LENGTH + 1)*i;
 
     IF_CHECK_START_CMD(_data)
     {
diff --git a/libraries/WiFi/utility/wifi_drv.cpp b/libraries/WiFi/utility/wifi_drv.cpp
index 1ca1696..0d949fc 100644
--- a/libraries/WiFi/utility/wifi_drv.cpp
+++ b/libraries/WiFi/utility/wifi_drv.cpp
@@ -15,7 +15,7 @@ extern "C" {
 }
 
 // Array of data to cache the information related to the networks discovered
-char WiFiDrv::_networkSsid[][WL_SSID_MAX_LENGTH] = {{"1"},{"2"},{"3"},{"4"},{"5"}};
+char WiFiDrv::_networkSsid[][WL_SSID_MAX_LENGTH + 1] = {{"1"},{"2"},{"3"},{"4"},{"5"}};
 int32_t WiFiDrv::_networkRssi[WL_NETWORKS_LIST_MAXNUM] = { 0 };
 uint8_t WiFiDrv::_networkEncr[WL_NETWORKS_LIST_MAXNUM] = { 0 };
 
@@ -192,6 +192,7 @@ uint8_t* WiFiDrv::getMacAddress()
     SpiDrv::waitResponseCmd(GET_MACADDR_CMD, PARAM_NUMS_1, _mac, &_dataLen);
 
     SpiDrv::spiSlaveDeselect();
+    _mac[_dataLen] = 0;
 
     return _mac;
 }
@@ -232,6 +233,7 @@ char* WiFiDrv::getCurrentSSID()
     SpiDrv::waitResponseCmd(GET_CURR_SSID_CMD, PARAM_NUMS_1, (uint8_t*)_ssid, &_dataLen);
 
     SpiDrv::spiSlaveDeselect();
+    _ssid[_dataLen] = 0;
 
     return _ssid;
 }
@@ -254,6 +256,7 @@ uint8_t* WiFiDrv::getCurrentBSSID()
     SpiDrv::waitResponseCmd(GET_CURR_BSSID_CMD, PARAM_NUMS_1, _bssid, &_dataLen);
 
     SpiDrv::spiSlaveDeselect();
+    _bssid[_dataLen] = 0;
 
     return _bssid;
 }
@@ -349,7 +352,7 @@ uint8_t WiFiDrv::getScanNetworks()
     return ssidListNum;
 }
 
-char* WiFiDrv::getSSIDNetoworks(uint8_t networkItem)
+char* WiFiDrv::getSSIDNetworks(uint8_t networkItem)
 {
  if (networkItem >= WL_NETWORKS_LIST_MAXNUM)
  return NULL;
@@ -357,7 +360,7 @@ char* WiFiDrv::getSSIDNetoworks(uint8_t networkItem)
  return _networkSsid[networkItem];
 }
 
-uint8_t WiFiDrv::getEncTypeNetowrks(uint8_t networkItem)
+uint8_t WiFiDrv::getEncTypeNetworks(uint8_t networkItem)
 {
  if (networkItem >= WL_NETWORKS_LIST_MAXNUM)
  return NULL;
@@ -382,7 +385,7 @@ uint8_t WiFiDrv::getEncTypeNetowrks(uint8_t networkItem)
     return encType;
 }
 
-int32_t WiFiDrv::getRSSINetoworks(uint8_t networkItem)
+int32_t WiFiDrv::getRSSINetworks(uint8_t networkItem)
 {
  if (networkItem >= WL_NETWORKS_LIST_MAXNUM)
  return NULL;
@@ -485,6 +488,7 @@ char*  WiFiDrv::getFwVersion()
         WARN("error waitResponse");
     }
     SpiDrv::spiSlaveDeselect();
+    fwVersion[_dataLen] = 0;
     return fwVersion;
 }
 
diff --git a/libraries/WiFi/utility/wifi_drv.h b/libraries/WiFi/utility/wifi_drv.h
index c4f04db..cb574cb 100644
--- a/libraries/WiFi/utility/wifi_drv.h
+++ b/libraries/WiFi/utility/wifi_drv.h
@@ -16,20 +16,20 @@ class WiFiDrv
 {
 private:
  // settings of requested network
- static char _networkSsid[WL_NETWORKS_LIST_MAXNUM][WL_SSID_MAX_LENGTH];
+ static char _networkSsid[WL_NETWORKS_LIST_MAXNUM][WL_SSID_MAX_LENGTH + 1];
  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];
+ static char fwVersion[WL_FW_VER_LENGTH + 1];
 
  // 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];
+ static char _ssid[WL_SSID_MAX_LENGTH + 1];
+ static uint8_t _bssid[WL_MAC_ADDR_LENGTH + 1];
+ static uint8_t _mac[WL_MAC_ADDR_LENGTH + 1];
+ static uint8_t  _localIp[WL_IPV4_LENGTH + 1];
+ static uint8_t  _subnetMask[WL_IPV4_LENGTH + 1];
+ static uint8_t  _gatewayIp[WL_IPV4_LENGTH + 1];
 
  /*
  * Get network Data information
@@ -177,7 +177,7 @@ public:
  *
      * return: ssid string of the specified item on the networks scanned list
      */
-    static char* getSSIDNetoworks(uint8_t networkItem);
+    static char* getSSIDNetworks(uint8_t networkItem);
 
     /*
      * Return the RSSI of the networks discovered during the scanNetworks
@@ -186,7 +186,7 @@ public:
  *
      * return: signed value of RSSI of the specified item on the networks scanned list
      */
-    static int32_t getRSSINetoworks(uint8_t networkItem);
+    static int32_t getRSSINetworks(uint8_t networkItem);
 
     /*
      * Return the encryption type of the networks discovered during the scanNetworks
@@ -195,7 +195,7 @@ public:
  *
      * return: encryption type (enum wl_enc_type) of the specified item on the networks scanned list
      */
-    static uint8_t getEncTypeNetowrks(uint8_t networkItem);
+    static uint8_t getEncTypeNetworks(uint8_t networkItem);
 
     /*
      * Resolve the given hostname to an IP address.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I'm new to Arduino with Wifi Shield but I'm having the following problems:
1.) I'm using SSIDs with 32 chars and WPA2 keys with 63 chars: Arduino WiFi Shield is not ready for that
a.) ScanNetworks prints wrong SSIDs because no zero string termination is done (some buffer definitions are 1 byte too short)
b.) Therefore I guess I can't connect to my WLAN (another bug in comparison)

Some debug output without patch, with the patch it is as expected:
Scanning available networks...
** Scan Networks **
number of available networks:4
0) Rjzx3hyGWAAAAAAAAAAAAAAAAAAAAAAANjzx3hyGWAAAAAAAAAAAAAAAAAAAAAAARjzx3hyGWAAAAAAAAAAAAAAAAAAAAAAARjzx3hyGWAAAAAAAAAAAAAAAAAAAAAAA    Signal: -39 dBm    Encryption: WPA2
1) Njzx3hyGWAAAAAAAAAAAAAAAAAAAAAAARjzx3hyGWAAAAAAAAAAAAAAAAAAAAAAARjzx3hyGWAAAAAAAAAAAAAAAAAAAAAAA    Signal: -50 dBm    Encryption: WPA2
2) Rjzx3hyGWAAAAAAAAAAAAAAAAAAAAAAARjzx3hyGWAAAAAAAAAAAAAAAAAAAAAAA    Signal: -80 dBm    Encryption: WPA2
3) Rjzx3hyGWAAAAAAAAAAAAAAAAAAAAAAA    Signal: -91 dBm    Encryption: WPA2

Nevertheless I can't connect to any of the SSIDs because of length bugs in the firmware (see above).

Any ideas?

Thnx.

Wiesl
Logged

Pages: [1]   Go Up
Jump to: