My code is able now to write a series of commands to the WiFly shield in the following order:
- $$$ (with no carrige return)(this command enters command mode)
- set wlan ssid BTHub3-Q9Z8
- set wlan phrase df2387da92
- join BTHub3-Q9Z8
- show rssi
It seams to bring back a number for the signal strength (RSSI) but it isn't very consistent and its very slow to respond when I move the shield relative to my wifi router. My code:
#include "WiFly.h" // We use this for the preinstantiated SpiSerial object.
//#include "WiFlySerial.h"
int pos = 0;
int crap = 0;
int rssi_read = 0;
int rssi_val = 0;
long i = 0;
void setup() {
Serial.begin(9600);
Serial.println("SPI UART on WiFly Shield terminal tool");
Serial.println("--------------------------------------");
Serial.println();
Serial.println("This is a tool to help you troubleshoot problems with the WiFly shield.");
Serial.println("For consistent results unplug & replug power to your Arduino and WiFly shield.");
Serial.println("(Ensure the serial monitor is not open when you remove power.)");
Serial.println();
Serial.println("Attempting to connect to SPI UART...");
SpiSerial.begin();
Serial.println("Connected to SPI UART.");
Serial.println();
Serial.println(" * Use $$$ (with no line ending) to enter WiFly command mode. ("CMD")");
Serial.println(" * Then send each command followed by a carriage return.");
Serial.println();
Serial.println("Waiting for input.");
Serial.println();
}
void loop(){
Serial.println("loop");
//void command(){
delay (1000);
SpiSerial.print("$$$"); //enters WiFly's command mode, should return CMD
delay (1000);
Serial.print(SpiSerial.read(), BYTE);
SpiSerial.println("set wlan ssid BTHub3-Q9Z8");
//delay (2000);
Serial.print(SpiSerial.read(), BYTE);
SpiSerial.println("set wlan phrase df2387da92");
//delay (200);
Serial.print(SpiSerial.read(), BYTE);
SpiSerial.println("join BTHub3-Q9Z8");
delay(2000);
Serial.print(SpiSerial.read(), BYTE);
delay(2000);
Serial.print(SpiSerial.read(), BYTE);
delay(2000);
SpiSerial.println("show rssi");
Serial.print(SpiSerial.read(), BYTE);
for(;;){
SpiSerial.println("show rssi");
Serial.print(SpiSerial.read(), BYTE);
}