So, recently I have been trying to use the Roving Networks RN-XV (https://www.sparkfun.com/products/10822) and the XBee Shield (SparkFun XBee Shield - WRL-12847 - SparkFun Electronics) and the WiflyHQ library to create an ad-hoc network. The purpose is to use it for telemetry on a quadcopter.
But, This doesn't seem to work. The adhoc network is not created (I can't see it with a macbook). And it takes a while to setup the serial connection to the RN-XV (as seen by it flashing three times after a long delay). This makes me think that there is some type of watchdog timer in wifly.begin() that forces it to return after it retries a few times. Do you have any ideas on how to get it to work? Anyone used this combination before? Example code would be great.
This is my code:
#include <Arduino.h>
#include <WiFlyHQ.h>
WiFly wifly;
void setup()
{
pinMode(13, OUTPUT);
Serial.begin(9600);
wifly.begin(&Serial, NULL);
delay(1000);
wifly.setIpProtocol(WIFLY_PROTOCOL_UDP);
//Serial.println("Done Setup");
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//Serial.println("Attempting to Setup ADHOC Network...");
wifly.createAdhocNetwork("wifly", 10);
delay(4000);
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(250);
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(250);
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(250);
}
void loop()
{
if (wifly.available() > 0)
{
if(wifly.read() == 'b')
{
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
}
}