Skip to content

Commit

Permalink
Merge pull request #182 from spark/feature/set-time-from-cloud
Browse files Browse the repository at this point in the history
Sync time from Spark Cloud
  • Loading branch information
Zachary Crockett committed May 2, 2014
2 parents 65cb627 + e3134ef commit 5995b04
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions inc/spark_utilities.h
Expand Up @@ -107,6 +107,7 @@ class SparkClass {
static int connect(void);
static int disconnect(void);
static String deviceID(void);
static void syncTime(void);
};

extern RGBClass RGB;
Expand Down
12 changes: 7 additions & 5 deletions src/spark_utilities.cpp
Expand Up @@ -264,6 +264,11 @@ bool SparkClass::subscribe(String eventName, EventHandler handler, String device
return subscribe(eventName.c_str(), handler, deviceID.c_str());
}

void SparkClass::syncTime(void)
{
spark_protocol.send_time_request();
}

void SparkClass::sleep(Spark_Sleep_TypeDef sleepMode, long seconds)
{
#if defined (SPARK_RTC_ENABLE)
Expand Down Expand Up @@ -502,6 +507,7 @@ void Spark_Protocol_Init(void)
callbacks.save_firmware_chunk = Spark_Save_Firmware_Chunk;
callbacks.signal = Spark_Signal;
callbacks.millis = millis;
callbacks.set_time = Time.setTime;

SparkDescriptor descriptor;
descriptor.num_functions = numUserFunctions;
Expand Down Expand Up @@ -534,6 +540,7 @@ int Spark_Handshake(void)
spark_protocol.reset_updating();
int err = spark_protocol.handshake();
Multicast_Presence_Announcement();
spark_protocol.send_time_request();
return err;
}

Expand Down Expand Up @@ -609,11 +616,6 @@ void Spark_Signal(bool on)
}
}

void Spark_SetTime(unsigned long dateTime)
{
Time.setTime(dateTime);
}

int Internet_Test(void)
{
long testSocket;
Expand Down

0 comments on commit 5995b04

Please sign in to comment.