Closed eddylawsurgere closed 1 year ago
Thanks for filing @eddylawsurgere, let me consult with @dipannita08 on this ask and get back to you.
Based on feedback from Dipannita, there's already a desired property update callback in the adapter for when writable desired properties are successfully sent from device to cloud. From the perspective of the bridge whether it's configuration updates or any other writable properties, it would still only be a property update, so an additional callback wouldn't be required. there's already a desired property update callback in the adapter for when writable desired properties are successfully sent from device to cloud. From the perspective of the bridge whether it's configuration updates or any other writable properties, it would still only be a property update, so an additional callback may not be needed.
If I understand your request correctly, you are looking for a way to be notified when device to cloud properties are written successfully, in order to make a decision from the adapter to start telemetry. If this is the case you can do the following:
Also remember (more info in pnpadapter_api.h) that property and command callbacks can come in from the cloud to the device immediately after the client handle is created and the adapter should be ready to handle these, after successful client registration with IoT hub and before the flow of telemetry from device to cloud (StartComponent)
Please feel free to correct me if I misunderstood your concern.
Let me give example. The desired properties got 2 writable properties and stored in cloud. It looks like this: "desired" : { "setTemperature" : 21, "setHumidity" : 50 }
When a device initially connects to IoT Central/Hub, the cloud sends the above desired properties as JSON to the device. This is case 1.
Here is case 2: If we change a writable property like "setTemperature" = 25 and click Save button on IoT Central Command page, the cloud only sends the property changed as JSON like: "desired" : { "setTemperature" : 25 }
Is there a feature (callback function) for case 1 to know that the whole desired properties have sent from cloud to the device?
Thanks
In case 1, you will receive a cloud to device property update callback on the function you register from the adapter in "PnpComponentHandleSetPropertyUpdateCallback" with relevant information to deduce which property was updated.
I found the function "PnpAdapterManager_PnpBridgeStateTelemetryCallback" in pbpadapter_manager.c. When I ran the pnpbridge app, tt's called back with a log message "Info: PnpBridge_PnpBridgeStateTelemetryCallback called, result=0, telemetry=PnpBridge configuration complete". It seems what I want. Does this function exists in pnpadapter_api?
Thanks
Thank you for your interest in the IoT Plug and Play bridge, unfortunately due to new innovations in Azure IoT and changes in product strategy we have come to the decision to deprecate the IoT Plug and Play bridge. Thank you to the community for your support on this journey. The repo is planned to be archived as a read-only repository on November 30th 2023. Thank you to everyone who contributed bug fixes and new adapters for connecting devices with IoT Plug and Play. You can find the latest IoT innovations at https://techcommunity.microsoft.com/t5/internet-of-things-blog/bg-p/IoTBlog. Please note that any use of archived repositories introduces more risks from a security standpoint and should be done with caution.
Is your feature request related to a problem? Please describe. I need a callback function in adapter when a device is power up and gets configuration from IoT hub/central. The configuration is all writable properties (desired property in device twin). Then the device automatically starts its sensor after configuring.
Describe the solution you'd like When I ran the sample Environmental Sensor, there's a message "Info: PnpBridge_PnpBridgeStateTelemetryCallback called, result=0, telemetry=PnpBridge configuration complete" in the log. It looks like to notify the configuration complete. If it can generate a callback function in adapter, that should work.
For example, there is a callback function code line in function "EnvironmentSensor_CreatePnpComponent" in file environmental_sensor_pnpbridge.c: _PnpComponentHandleSetPropertyUpdateCallback(BridgeComponentHandle, EnvironmentSensorProcessPropertyUpdate); Can we have a callback function like that for "Configuration Complete"?
Additional context Here is the log: