update examples to sync device time

This commit is contained in:
liamcottle 2025-04-08 14:39:12 +12:00
parent e10db3d56c
commit e45527fd9a
2 changed files with 5 additions and 11 deletions

View file

@ -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);

View file

@ -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();