Hi Guys ... cause i had a lot of trouble with the shield .. i have a few infos .. well perhaps i can save a guy some time ...
first of all i got often "AUTH-ERR" and Disconnects from the shield .. since i attached an external-antenna i got a quite stable wifi connection... the internal antenna doesnt work for me... looks like the other components are producing to much noise .. (rf-receiver, lcdbackpack .. sensorics)
on more point ... i got a working solution .. well atleast for me .. to get the RTC-Time of the WiFly ..
cause the RTC-Value would need a 64Bit Integer for processing .. i split it into 2 32bit floats .. so a one-second precision should ... bla bla ...
it works .. its not perfekt ...
Code: Select allfloat strToFloat(String str){
float result = 0;
for(int i=0; i < str.length(); i++){
if (isdigit (str[i])) {
result = result * 10 + str[i] - '0';
}
else {
break;
}
}
return result;
}
....
Code: Select allbool sync_time()
{
bool aRes = false;
#ifdef WLAN
sWLAN.SpiDev.print("time");
sWLAN.SpiDev.println();
delay(5000);
sWLAN.SpiDev.print("show t t");
sWLAN.SpiDev.println();
int ix;
char timestr[1024];
timestr[0] = '\0';
int ic = 0;
int tom = 0;
while (true)
{
ix = sWLAN.SpiDev.read();
if (ix >= 0)
{
Serial.print((char)ix);
timestr[ic] = (char)ix;
ic++;
timestr[ic] = '\0';
tom = 0;
} else {
delay(10);
tom++;
if (tom > 200) {
break;
}
}
}
if (ic > 10)
{
String aTimes = String(timestr);
int rtcidx = aTimes.indexOf("RTC=");
if (rtcidx > 0)
{
aTimes = aTimes.substring(rtcidx+4);
aTimes = aTimes.substring(0,aTimes.indexOf(" "));
// Precision-Splitting 64bit -> 32bit tricksing
String srtc1 = aTimes.substring(0,4);
srtc1 = srtc1 + "000000000";
String srtc2 = aTimes.substring(4,4+9);
double rtc1 = strToFloat(srtc1);
double rtc2 = strToFloat(srtc2);
double dayidx1 = (rtc1 / 86400000);
double dayidx2 = (rtc2 / 86400000);
double dayidx = (dayidx1 + dayidx2) - 49708.22629268139;
// Delphi Stamp to UnixStamp
int idayidx = (int)dayidx;
long UnixStamp = ((idayidx - 25569) * 86400) + (int)(86400 * (dayidx - idayidx)) - 7200;
char msg[200];
setTime(UnixStamp); // time.h
digitalClockDisplay(); // see time samples
aRes = true;
}
}
#endif
return aRes;
}
well sWLAN is my own WiFly-Class .. its a simple WiFly-Http-client Lib supporting retrys and working timeouts ... well just a buggy bunch of code *lol*
.. so far gn8 dorty