mirror of
https://github.com/meshcore-dev/meshcore.js.git
synced 2026-04-20 22:13:49 +00:00
set device time on connect
This commit is contained in:
parent
5c6b2e1e04
commit
4925d7fa4f
1 changed files with 12 additions and 0 deletions
|
|
@ -10,6 +10,9 @@ connection.on("connected", async () => {
|
|||
// we are now connected
|
||||
console.log(`Connected to: [${connection.host}:${connection.port}]`);
|
||||
|
||||
// set device time
|
||||
await setDeviceTime();
|
||||
|
||||
// send flood advert when connected
|
||||
await connection.sendFloodAdvert();
|
||||
|
||||
|
|
@ -31,6 +34,15 @@ 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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue