SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By roadfun
#126357
I just received a WiFly with code version string is WiFly Ver 2.21, 07-11-2010. I'm using it with a Arduino Duo. The router is WPA2PSK and the SSID has spaces in the name. The passphrase has no spaces.

Run SpiUartTerminal and enter CMD mode. Use these commands:
set wlan phrase thepassphrase
set wlan ssid the$ssid
---
join <- fails "Auto-Assoc the ssid chan=0 mode=NONE FAILED" (the messageshows the real SSID with a space)

join the$ssid <- fails with the same error as above but it doesn't do the space subsitute and instead shows the $ in the ssid name

join the ssid <- fails and says ERR:Bad Addr (obviously doesn't like me including the space in the name

Now if I do a "scan" command and tell it to join the number associated with the$ssid everything is gravy. For example
join # 4 <- succeeds "Auto-Assoc the ssid chan=7 mode=WPA2 SCAN OK"
and it goes on to show a correctly allocated IP address and so on and the happy green light on the WiFly flashes.

I've tried reboot commands and "factory RESET" commands to no avail. I have also (in fact what I tried first) entered the credentials into WiFly_Autoconnect_Terminal and when I run this sketch I get the initial println and then nothing (no failure message nor a success message) and the two light blink indicating it is not properly associated. In the Credentials.h file I've tried entering the SSID with the space and with a $ instead of the space. Neither works. I'm not sure whether the $ is required.

I do note the scan output is a bit variable. Sometimes it will only return one SSID and sometimes it will return a half dozen. Sometimes the ones it does return are relatively distant and it won't list the SSID of my own router. But personally I don't think this is a real issue.

At this point I'm at a loss on how to proceed. Has anyone gotten this thing to join a WPA network with a space in the SSID? If so can you sure exactly how you're doing it?
By roadfun
#126390
After more experiments I've discovered:
1. My original SSID had two spaces and was pretty long. I was never able to join this using name via the command line or the library. I could join the access point by doing the "scan" command and then "join # x" replacing x with the line number of the access point listed in the scan. Based on the next item I believe the SSID length may be a problem with the chip. But I didn't feel like hacking away to find exactly how long was OK.
2. So, I shortened the SSID name and left one space in it. As soon as I did this I could join from the command line without having to do a scan. I just did a set of the SSID (replacing the space with a $) and a set of the phrase (WPA) then a "join" command with no arguments. This works every time.
3. However, I could not join the networking using the library. See my reply on this thread viewtopic.php?f=32&t=25216&p=126384#p126384. In order to join my network I had to set the passphrase and SSID myself and then call the library's join method with a empty string.
By roadfun
#126500
Reading through the library code I discovered why a SSID with a space in it won't work. Rather than setting the SSID using "set wlan ssid ssid_name" followed by a "join" it instead uses "join ssid_name". Unfortunately the chip doesn't work with this scheme. I.e. if you use the command ($ substituting for a space)
join ssid$name
you'll get an error back from the chip. If you do a set command on the name (with a $ for space) and then send "join" with no arguments the chip works fine. Presumably this would work in the library so I'm going to hack my copy and see.
By roadfun
#126503
OK, I hacked the library and modified the WiFlyDevice.cpp::join(ssid) method and it does indeed work (i.e. it can join an SSID with a space in the SSID name if you manually substitute a $ character for the space character in ssid in Credentials.h and as documented in the Roving manual). Note this change should work even without a space in the SSID name but I have not tested it. Posting this in case it helps someone else. I suppose if this sort of change were going in the official library it might be best to programmatically substitute $ for spaces.
Code: Select all
// Ron Guest -- begin change to support space in SSID
  // First we set the SSID (putting the SSID on the join command doesn't work
  Serial.println("Setting SSID using Ron method");
  sendCommand("set wlan ssid ",true);
  sendCommand(ssid);
  if (sendCommand("join", false, "Associated!")) {
    // TODO: Extract information from complete response?
    // TODO: Change this to still work when server mode not active
    waitForResponse("Listen on ");
    skipRemainderOfResponse();
    return true;
  }
// Ron Guest -- end change. Uncomment the below block and delete this one to restore original code

  /*sendCommand("join ", true);
  // TODO: Actually detect failure to associate
  // TODO: Handle connecting to Adhoc device
  if (sendCommand(ssid, false, "Associated!")) {
    // TODO: Extract information from complete response?
    // TODO: Change this to still work when server mode not active
    waitForResponse("Listen on ");
    skipRemainderOfResponse();
    return true;
  }*/
  return false;