i just managed to change SDCARD version so far that it takes a time string from command line:
#!/bin/bash
this script sends output of smartcitizens time server or system date to ttyACM:
servertime=$(wget -q -O- http://data.smartcitizen.me/datetime)
this is the format smartcitizen likes the date:
systemtime=$(date +%Y,%-m,%-d,%-H,%-M,%-S#)
echo " servertime: $servertime"
echo "setting systemtime: $systemtime"
echo $systemtime | sed -e ‘s/UTC://g’ > /dev/ttyACM1
`
to do so i manipulated the loop() to listen on serial port:
`
if ( terminal_mode )
{
// read a line
while (Serial.available()) {
delay(3); //delay to allow buffer to fill
if (Serial.available() >0) {
char c = Serial.read(); //gets one byte from serial buffer
readLine += c; //makes the string readString
}
}
// this is what we get from: http://data.smartcitizen.me/datetime
// UTC:2014,7,3,20,41,27#
// if line is not empty:
if ( readLine != "" )
{
// simulate the part of sckWIFItime without requesting the server:
Serial.println(sckTOMtime(readLine));
ok = sckRTCadjust(sckTOMtime(readLine));
if ( ok )
{
Serial.println("set time ok");
}
}
readLine = "";
}
`
and added my sckTOMtime() that does the same as sckWIFItime() from ServerUpdate but without querying the timeserver:
`
char* sckTOMtime(String serverTime) {
boolean ok=false;
uint8_t count = 0;
//if (sckFindInResponse(“UTC:”, 2000))
char newChar;
byte offset = 0;
byte tomCounter = 0;
while (offset < TIME_BUFFER_SIZE) {
// read next char
newChar = serverTime.charAt(tomCounter);
//Serial.print(“nC:”);
//Serial.println(newChar, DEC);
tomCounter++;
if (newChar == '#') {
ok = true;
buffer[offset] = '\\x00';
break;
}
else if (newChar != -1) {
if (newChar==',')
{
if (count<2) buffer[offset]='-';
else if (count>2) buffer[offset]=':';
else buffer[offset]=' ';
count++;
}
else buffer[offset] = newChar;
offset++;
}
}
if (!ok)
{
buffer[0] = ‘#’;
buffer[1] = 0x00;
}
return buffer;
}
`
if i call my setTime.sh script i can set the time on arduino without being connected to the internet. the output looks like this:
`
…
Temperature: 2620.80 C RAW
Humidity: 2908.00 % RAW
Light: 14.20 lx
Battery: 100.00 %
Solar Panel: 0.00 V
Carbon Monxide: 0.00 kOhm
Nitrogen Dioxide: 0.00 kOhm
Noise: 0.00 mV
UTC: 2014-07-05 01:01:00
2014-7-5 1:1:18
set time ok
Temperature: 2621.60 C RAW
Humidity: 2901.60 % RAW
Light: 14.20 lx
Battery: 100.00 %
Solar Panel: 0.00 V
Carbon Monxide: 4.49 kOhm
Nitrogen Dioxide: 0.00 kOhm
Noise: 2.35 mV
UTC: 2014-07-05 01:02:17
…
`