Secure IoT command sending (NodeJS Client). There are many ways to secure and authenticate a networking communication, but not all solutions will run on a microcontroller, where processing power and memory is a scarce resource.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

41 lines
874 B

const secureSend = require('./secureSendClient.js');
const options = {
hmacKey: 'supersecure',
hashByteLength: 32,
randDataLength: 100,
port: 777,
ip: '192.168.0.6',
onConnect: () => {
console.log('Connected');
}
}
const cmds = {
getGateState:{
cmd: 0,
responses: [0x00, 0x01, 0x02] /* 0: Closed 1: Open 2: Middle */
},
switchGate: {
cmd: 1,
responses: [0x00] /* 0: Cmd received */
},
switchLight: {
cmd: 2,
responses: [0x00, 0x01] /* 0: now closed 1: now Open */
}
};
secureSend(options, cmds.switchGate)
.then(res => {
console.log('The response ->');
console.log(res);
})
.catch(err => {
console.log('Catched Error ->');
console.log(err);
});
setTimeout(()=>{},6000);