Library method unclear

Im working with this wiflyHQ library from harlequin on github: GitHub - harlequin-tech/WiFlyHQ: WiFly RN-XV Arduino Library

Im looking to use the wifi module’s rtc library function and I see these 3 methods:

 * This command sets the real-time clock by synchronizing
 * with the time server specified with the time server
 * (set time) parameters. This command sends a UDP time
 * server request packet.
boolean WiFly::time()
    if (!startCommand()) {
        return false;
    return true;

char *WiFly::getTime(char *buf, int size)
    return getopt(WIFLY_GET_TIME, buf, size);

uint32_t WiFly::getRTC()
    return getopt(WIFLY_GET_RTC);

I see the first one is a boolean return type, I guess it would be used to test if the module has synced with a server. The second is a char and the third is an int. So Im wondering which would give me the time and how.

Im guessing the second one would take a char buffer pointer to send the time data to along with its int size. Im not that experienced with pointers or buffers, but I guess I need to declare something like this in code:

char dataBufferToReceive[30];          //for the time
int dataSize;    //for the size

But how do I call it:

    char something = wifly.getTime(dataBufferToReceive,sizeof(dataBufferToReceive));

doesnt work but I dont know how to interpret this signature in order to call it properly.

Time is going to take more than one character to represent. You need to create a buffer, a character array, big enough to fit everything it's going to try to put in there. Then pass a pointer to the first spot by using the array name without any brackets.

So like char buff[64]?

How do I determine what it will put in there? Probably a timestamp which could be about 10-20 characters long?

What makes you think that a WiFly will be sync'ed to a server or even know the time (it has no need to do that!) Start by looking at the lib and seeing what startCommand() is and and then look in the Wifly doc to see what "time" does.


I found this:

I’m currently using a ds1307 rtc with a TimeAlarms library to fire my sampling alarm.

I figured I could replace that with the wifly rtc.

Hi guys,

I still havent been able to figure how to call that library method correctly:

char *WiFly::getTime(char *buf, int size)
    return getopt(WIFLY_GET_TIME, buf, size);

from my code. So far I have:

char dataBufferToReceive[30];  //for the time
int dataSize = 256;  //for the size

and later on in the setup():

    char something = wifly.getTime(dataBufferToReceive,sizeof(dataBufferToReceive));

but I get this compile error:

WiflyHQTimeAlarmTest.ino:35:83: error: invalid conversion from 'char*' to 'char' [-fpermissive]

Try …

char *result = wifly.getTime(dataBufferToReceive,sizeof(dataBufferToReceive));

If the function works OK, result will point to the same string as dataBufferToReceive.

If the function has a problem, result will be the string “”.

Thanks! That worked.