mirror of
https://github.com/meshcore-dev/meshcore.js.git
synced 2026-04-20 22:13:49 +00:00
update examples to sync device time
This commit is contained in:
parent
e10db3d56c
commit
e45527fd9a
2 changed files with 5 additions and 11 deletions
|
|
@ -12,8 +12,8 @@ connection.on("connected", async () => {
|
|||
// we are now connected
|
||||
console.log("Connected");
|
||||
|
||||
// set device time
|
||||
await setDeviceTime();
|
||||
// update clock on meshcore device
|
||||
await connection.syncDeviceTime();
|
||||
|
||||
// send flood advert when connected
|
||||
await connection.sendFloodAdvert();
|
||||
|
|
@ -36,15 +36,6 @@ connection.on(Constants.PushCodes.MsgWaiting, async () => {
|
|||
}
|
||||
});
|
||||
|
||||
async function setDeviceTime() {
|
||||
try {
|
||||
// update time on meshcore device
|
||||
await connection.setDeviceTime(Math.floor(Date.now() / 1000));
|
||||
} catch(e) {
|
||||
// ignore sync error
|
||||
}
|
||||
}
|
||||
|
||||
async function onContactMessageReceived(message) {
|
||||
|
||||
console.log("Received contact message", message);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ connection.on("connected", async () => {
|
|||
// we are now connected
|
||||
console.log("Connected");
|
||||
|
||||
// update clock on meshcore device
|
||||
await connection.syncDeviceTime();
|
||||
|
||||
// send flood advert when connected
|
||||
await connection.sendFloodAdvert();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue