Hi,
I just can't get this to work. My sketch seems to hang when I call this. Here is my code:
#include <Bridge.h>
#include <YunClient.h>
#include <FileIO.h>
YunClient Radio;
byte radioIP[] = { 192, 168, 0, 32 };
#define radioPort 4000
String readString;
String YunIP;
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("Started....");
// Bridge startup
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
Bridge.begin();
// File I/O startup
while (!FileSystem.begin());
digitalWrite(13, HIGH);
// get the latest IP address of the Yun
File dataFile = FileSystem.open("/graham/ip.txt", FILE_READ);
if (dataFile) {
while (dataFile.available()) {
readString = dataFile.readString();
YunIP = readString;
}
dataFile.close();
Serial.println(YunIP);
// convert IP's to byte arrays
YunIP.getBytes(radioIP, 4);
}
int ret = Radio.connect(radioIP,radioPort);
Serial.println(ret);
Serial.println("Listening...");
}
void loop() {
delay(50);
}
The serial monitor:
Started....
192.168.0.32
If I remove the getBytes() call I get:
Started....
192.168.0.320
Listening...
Any ideas??