Azure / iot-plug-and-play-bridge

IoT Plug and Play bridge
Other
60 stars 28 forks source link

Getting Property Updates to work with Serial Device #75

Closed djaus2 closed 1 year ago

djaus2 commented 3 years ago

Two issues as discussed in More issues with the Arduino Serial example #74 (1) Can only push string properties back from Azure IoT Explorer .. Updated for string, int and bool (2) At one point a null component is always used which means it can't be found and so update doesn't happen. But the component is supplied when that function is called so use it.

re (1)

In \iot-plug-and-play-bridge\pnpbridge\src\adapters\src\serial_pnp\serial_pnp.c

Change

const char * PropertyValueString = json_value_get_string(PropertyValue);

To:

    char* PropertyValueString = NULL;
    const char* propertyValueString;
    if (json_value_get_type(PropertyValue) == JSONString)
    {
  ...
    }
    else if (json_value_get_type(PropertyValue) == JSONNumber)
    {
  ...
    }
    else if (json_value_get_type(PropertyValue) == JSONBoolean)
    {
   ...
    }

Re: (2) In \iot-plug-and-play-bridge\pnpbridge\src\pnpbridge\common\pnp_protocol.c

In VisitDesiredObject( )

This call always fails with NULL. Need a Component:

pnpPropertyCallback(NULL, name, value, version, userContextCallback);

(i) Line 238 Change NULL to component:

pnpPropertyCallback(component , name, value, version, userContextCallback);

Then get the component from the componentsInModel parameter passed to the function

(ii) Insert after line 218

const char* component = componentsInModel[i];

Property updates from Az IoT Explorer now work with the Arduino Sample.

====================

Nb: Also this Pull Request updates .gitignore so as to preclude cmake generated.files

usivagna commented 1 year ago

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.