async function sendTelemetry() {
    if (connected) {
        const telemetry = {
            temp: (20 + (Math.random() * 100)).toFixed(2),
            humidity: (Math.random() * 100).toFixed(2)
        };

        const message = new Message(JSON.stringify(telemetry));

        await new Promise(async (resolve,reject) => {
            await client.sendEvent(message, (err) => {
                if (err) {
                    return reject(err);
                }
                else {
                    console.log(`Completed telemetry send ${JSON.stringify(telemetry)}`);
                    return resolve();
                }
            });
        });
    }
}
// sends telemetry on a set frequency
sends telemetry on a set frequency
sends telemetry on a set frequency
async function sendTelemetry() {
    if (connected) {
        const telemetry = {
            temp: (20 + (Math.random() * 100)).toFixed(2),
            humidity: (Math.random() * 100).toFixed(2)
        };
        const message = new Message(JSON.stringify(telemetry));
        await new Promise(async (resolve,reject) => {
            await client.sendEvent(message, (err) => {
                if (err) {
                    return reject(err);
                }
                else {
                    console.log(`Completed telemetry send ${JSON.stringify(telemetry)}`);
                    return resolve();
                }
            });
        });
    }
}
async function sendTelemetry ( ) { if ( connected ) { const telemetry = { temp : ( 20 + ( Math . random ( ) * 100 ) ) . toFixed ( 2 ) , humidity : ( Math . random ( ) * 100 ) . toFixed ( 2 ) } ; const message = new Message ( JSON . stringify ( telemetry ) ) ; await new Promise ( async ( resolve , reject ) => { await client . sendEvent ( message , ( err ) => { if ( err ) { return reject ( err ) ; } else { console . log ( ` ${ JSON . stringify ( telemetry ) } ` ) ; return resolve ( ) ; } } ) ; } ) ; } }
sends telemetry on a set frequency
sends telemetry on a set frequency