我有一个 IoT 板,它托管一个应用程序,它报告了一组属性。然后我在该板上加载了一个新应用程序。现在双属性更新失败并出现 400 错误。以下是上一个应用程序的现有属性:
{
"deviceId": "xxxxxx",
"etag": "AAAAAAAAABI=",
"deviceEtag": "ODkzNzc0Mjcx",
"status": "enabled",
"statusUpdateTime": "0001-01-01T00:00:00",
"connectionState": "Connected",
"lastActivityTime": "2019-07-25T14:49:57.9764857",
"cloudToDeviceMessageCount": 0,
"authenticationType": "sas",
"x509Thumbprint": {
"primaryThumbprint": null,
"secondaryThumbprint": null
},
"version": 34,
"properties": {
"desired": {
"pmt_mqttMon_sec": 120,
"sup_badBootLimit": 5,
"sup_badBootTimeout_sec": 1200,
"sup_enabled": 1,
"pmt_enabled": 1,
"pub_enabled": 1,
"pub_mqttMaxLen": 2500,
"pub_maxWriteFails": 3,
"ping_period": 60,
"ping_state": 3,
"storage_enabled": 1,
"sys_pollPeriod_sec": 60,
"sys_type": "2",
"sys_numBatt": 0,
"gen_manualControl": 0,
"sys_rectStopChargeSoc_pct": "",
"sys_genStartSoc_pct": 62.5,
"sys_genStartVoltage_V": 44.5,
"sys_rectFloatHigh_V": 57.7,
"sys_rectFloatLow_V": 53.7,
"sys_modbusBaudRate": "19200",
"rlogger_level": 1,
"$metadata": {
"$lastUpdated": "2019-07-24T23:31:35.4433452Z",
"$lastUpdatedVersion": 18,
"pmt_mqttMon_sec": {
"$lastUpdated": "2019-07-24T23:22:14.8853676Z",
"$lastUpdatedVersion": 17
},
"sup_badBootLimit": {
"$lastUpdated": "2019-07-24T23:22:14.8853676Z",
"$lastUpdatedVersion": 17
},
"sup_badBootTimeout_sec": {
"$lastUpdated": "2019-07-24T23:22:14.8853676Z",
"$lastUpdatedVersion": 17
},
"sup_enabled": {
"$lastUpdated": "2019-07-24T23:22:14.8853676Z",
"$lastUpdatedVersion": 17
},
"pmt_enabled": {
"$lastUpdated": "2019-07-24T23:22:14.8853676Z",
"$lastUpdatedVersion": 17
},
"pub_enabled": {
"$lastUpdated": "2019-07-24T23:22:14.8853676Z",
"$lastUpdatedVersion": 17
},
"pub_mqttMaxLen": {
"$lastUpdated": "2019-07-24T23:22:14.8853676Z",
"$lastUpdatedVersion": 17
},
"pub_maxWriteFails": {
"$lastUpdated": "2019-07-24T23:22:14.8853676Z",
"$lastUpdatedVersion": 17
},
"ping_period": {
"$lastUpdated": "2019-07-24T23:22:14.8853676Z",
"$lastUpdatedVersion": 17
},
"ping_state": {
"$lastUpdated": "2019-07-24T23:22:14.8853676Z",
"$lastUpdatedVersion": 17
},
"storage_enabled": {
"$lastUpdated": "2019-07-24T23:22:14.8853676Z",
"$lastUpdatedVersion": 17
},
"sys_pollPeriod_sec": {
"$lastUpdated": "2019-07-24T23:22:14.8853676Z",
"$lastUpdatedVersion": 17
},
"sys_type": {
"$lastUpdated": "2019-07-24T23:22:14.8853676Z",
"$lastUpdatedVersion": 17
},
"sys_numBatt": {
"$lastUpdated": "2019-07-24T23:22:14.8853676Z",
"$lastUpdatedVersion": 17
},
"gen_manualControl": {
"$lastUpdated": "2019-07-24T23:22:14.8853676Z",
"$lastUpdatedVersion": 17
},
"sys_rectStopChargeSoc_pct": {
"$lastUpdated": "2019-07-24T23:22:14.8853676Z",
"$lastUpdatedVersion": 17
},
"sys_genStartSoc_pct": {
"$lastUpdated": "2019-07-24T23:22:14.8853676Z",
"$lastUpdatedVersion": 17
},
"sys_genStartVoltage_V": {
"$lastUpdated": "2019-07-24T23:22:14.8853676Z",
"$lastUpdatedVersion": 17
},
"sys_rectFloatHigh_V": {
"$lastUpdated": "2019-07-24T23:22:14.8853676Z",
"$lastUpdatedVersion": 17
},
"sys_rectFloatLow_V": {
"$lastUpdated": "2019-07-24T23:22:14.8853676Z",
"$lastUpdatedVersion": 17
},
"sys_modbusBaudRate": {
"$lastUpdated": "2019-07-24T23:31:35.4433452Z",
"$lastUpdatedVersion": 18
},
"rlogger_level": {
"$lastUpdated": "2019-07-24T23:22:14.8853676Z",
"$lastUpdatedVersion": 17
}
},
"$version": 18
},
"reported": {
"sup_badBootLimit": 5,
"sup_badBootTimeout_sec": 1200,
"sup_enabled": 1,
"rlogger_level": 1,
"storage_enabled": 1,
"pmt_enabled": 1,
"pmt_mqttMon_sec": 180,
"pub_enabled": 1,
"pub_mqttMaxLen": 2500,
"pub_maxWriteFails": 3,
"ping_period": 60,
"ping_state": 3,
"sys_pollPeriod_sec": 60,
"sys_type": 0,
"sys_numBatt": 0,
"gen_type": 1,
"gen_manualControl": 0,
"sys_rectStopChargeSoc_pct": 85,
"sys_genStartSoc_pct": 62.5,
"sys_genStartVoltage_V": 44.5,
"sys_rectFloatHigh_V": 57.7,
"sys_rectFloatLow_V": 53.7,
"sys_modbusBaudRate": 9600,
"sys_devices": "[{\"class\":\"ncu\",\"devId\":0,\"mbid\":1,\"ipAddr\":\"\",\"regOff\":0}]",
"": "[{\"class\":\"ncu\",\"devId\":0,\"mbid\":1,\"ipAddr\":\"\",\"regOff\":0}]",
"$metadata": {
"$lastUpdated": "2019-04-25T00:13:19.9436642Z",
"sup_badBootLimit": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"sup_badBootTimeout_sec": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"sup_enabled": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"rlogger_level": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"storage_enabled": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"pmt_enabled": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"pmt_mqttMon_sec": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"pub_enabled": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"pub_mqttMaxLen": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"pub_maxWriteFails": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"ping_period": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"ping_state": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"sys_pollPeriod_sec": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"sys_type": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"sys_numBatt": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"gen_type": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"gen_manualControl": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"sys_rectStopChargeSoc_pct": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"sys_genStartSoc_pct": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"sys_genStartVoltage_V": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"sys_rectFloatHigh_V": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"sys_rectFloatLow_V": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"sys_modbusBaudRate": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"sys_devices": {
"$lastUpdated": "2019-04-24T23:15:31.2402457Z"
},
"": {
"$lastUpdated": "2019-04-25T00:13:19.9436642Z"
}
},
"$version": 16
}
},
"capabilities": {
"iotEdge": false
}
}
然后设备尝试通过此 JSON 更新报告的值:
{
"sup_badBootLimit": 5,
"sup_badBootReset_s": 1200,
"sup_enabled": 1,
"rlogger_level": 1,
"storage_enabled": 1,
"pmt_enabled": 1,
"pmt_mqttMon_sec": 120,
"pub_enabled": 1,
"pub_mqttMaxLen": 2500,
"pub_maxWriteFails": 3,
"ping_period": 60,
"ping_state": 3,
"sys_modbusBaudRate": 19200,
"sys_readSensors": 0,
"sys_pollPeriod_sec": 60,
"sys_type": 2,
"sys_devices": "[{\"class\":\"gridmeter\",\"deviceId\":0,\"modbusId\":6,\"ipAddress\":\"\",\"regOff\":0},{\"class\":\"gridmeter\",\"deviceId\":1,\"modbusId\":5,\"ipAddress\":\"\",\"regOff\":0},{\"class\":\"sun2k\",\"deviceId\":0,\"modbusId\":7,\"ipAddress\":\"\",\"regOff\":0}]",
"sys_limit_power_padding_W": 100,
"controller_loop_sec": 10
}
但这会因错误代码而失败400
,根据某些评论,这表明属性名称无效。当我在没有现有双记录的新设备上加载应用程序时,一切正常。
想到几个问题:
- 如何在不注销和重新注册设备的情况下完全清除双记录?在节点 SDK 中,我只看到更新所需属性的方法。
- 我可以通过将其值设置为 null 来从所需的集合中删除一个属性。但是,如果新的设备端应用程序不知道之前的应用程序使用了哪些属性,它如何删除这些属性呢?有没有办法清除所有报告的属性?
- 出于某种原因,其中一个报告的属性似乎有一个空字符串作为键(我认为这应该是一个无效的键)。我想知道这是否导致了问题。