Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added time() and sleep() functions #28

Merged
merged 2 commits into from
Jul 25, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions WiFlyHQ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,42 @@ uint32_t WiFly::getBaud()
return getopt(WIFLY_GET_BAUD);
}

/**
* This command puts the module to sleep. You can wake
* the module by sending characters over the UART or by
* using the wake timer (supplied in seconds).
*/
boolean WiFly::sleep(uint16_t seconds)
{
if (seconds != NULL) {
if(!setopt(PSTR("set sys wake"), seconds)) {
return false;
}
}
if (!startCommand()) {
return false;
}
send_P(PSTR("sleep\r"));
inCommandMode = false;
return true;
}

/**
* 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;
}
send_P(PSTR("time\r"));
finishCommand();
return true;
}

char *WiFly::getTime(char *buf, int size)
{
return getopt(WIFLY_GET_TIME, buf, size);
Expand Down
5 changes: 4 additions & 1 deletion WiFlyHQ.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ class WiFly : public Stream {
boolean disableUdpAutoPair();

boolean setIOFunc(const uint8_t func);


boolean sleep(uint16_t seconds = NULL);

boolean time();
char *getTime(char *buf, int size);
uint32_t getUptime();
uint8_t getTimezone();
Expand Down