gpt4 book ai didi

node.js - 如何在azure中使用node js获取/查找设备/ Controller 的固件版本?

转载 作者:太空宇宙 更新时间:2023-11-03 23:21:46 25 4
gpt4 key购买 nike

如何在azure中使用node js获取/查找设备/ Controller 的固件版本?

The device is actually added in IoT Hub on Azure. I'm using node.js framework to fetch the firmware version.

下面我添加了我的设备。设备按预期工作。我只想/获取固件版本。 Please click here to see the image

最佳答案

答案是

//*N++ update table
var macId = GetDeviceId();
updateFirmwareVersion(macId);


//*N+start update firmware version
function updateFirmwareVersion(deviceId){
registry.getTwin(deviceId, function(err, twin){
if (err) {
console.log('Could not query twins: ' + err.constructor.name + ': ' + err.message);
} else {
console.log((JSON.stringify(twin.properties.reported.AzureFwVersion)) + "\n");
var azureFwVersion = twin.properties.reported.AzureFwVersion;
var s = azureFwVersion.lastIndexOf(".");

var res = azureFwVersion.substring(s+1, azureFwVersion.length);
var firmwareV = Number(res).toString(16).toUpperCase() + '00';

//SQL starts
new sql.Request()
.query("UPDATE MY_Table SET firmware = '" + firmwareV + "'").then(function (recordset) {
}).catch(function (err) {
console.log('update table for firmware' + err);
});

}
});
}
//*N+end update firmware version

详情请引用以下链接 https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-node-node-firmware-update#trigger-a-remote-firmware-update-on-the-device-using-a-direct-method

关于node.js - 如何在azure中使用node js获取/查找设备/ Controller 的固件版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48824604/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com