Azure / azure-iot-remote-monitoring

Azure IoT Remote Monitoring preconfigured solution
Other
249 stars 219 forks source link

Custom Device Provisioning #75

Closed networkfusion closed 8 years ago

networkfusion commented 8 years ago

I have created a device using netmf and I am trying to provision the device (i.e. change the status from pending in the devices list)

I am sending the following json string contained within the message body (copied and pasted from device explorer which is monitoring the event hub) although 'Event Id' is actually contained within message.ApplicationProperties["EventId"] not Json

Data:[
    {
        "ObjectType":"DeviceInfo",
        "IsSimulatedDevice":false,
        "Commands":[{"Name":"PingDevice","Parameters":null}],
        "DeviceProperties":
        {
            "Manufacturer":"135",
            "ModelNumber":"9",
            "DeviceID":"362188148",
            "DeviceState":"normal",
            "FirmwareVersion":"4.3.7.10"
        },
        "Version":"1.0.0.27394"
    }
]
Properties:
    'EventId': '601282515'

however the device status stays as pending.

Am I missing anything?

It would also help if there was some documentation about the provisioning parameters including sample message bodies and which parameters are mandatory...

networkfusion commented 8 years ago

It turns out the problem is:

"Version":"1.0.0.27394"

this should have been

"Version":"1.0"

To be honest, this should really be called

"SchemaVersion":"1.0"

as it is related to the data and could be construed as being the firmware version et al.

My points on documenting in the previous comments are still valid though!

jamesweb-ms commented 8 years ago

See https://github.com/Azure/azure-iot-remote-monitoring/blob/master/EventProcessor/EventProcessor.WebJob/Processors/DeviceAdministrationProcessor.cs#L149

You can add support for more versions here. The version allows you to decide how to deserialize the message.

jamesweb-ms commented 8 years ago

As a side note, you could also add device types here too. This would allow support for different device types with different sensors.

networkfusion commented 8 years ago

@jamesweb-ms I am not sure I understand... only 'ObjectType' 'DeviceId' and 'Version' seemed to be fixed attributes and therefore mandatory?! I am not sure what you would want/need to change the schema version as most variables are dynamic... any examples? I also thought the sensor telemetry part was dynamic...

My plan at the moment is to have many devices attached to remote monitoring. Each device will have a single sensor attached but they maybe one of 12 different types of sensor. The sensors will send their telemetry using a schema yet to be decided but would be similar to the format OMJson or SensorThings. for the device management I am open to any schema that works well enough which remotemonitoring seems to do.

Badiboy commented 8 years ago

I just left it here. Additionally to version "1.0" "HubEnabledState": "true" should be added to "DeviceProperties" This brought my device to "Running" from "Pending". Original post + first reply were not enough.