iot-plug-and-play-bridge icon indicating copy to clipboard operation
iot-plug-and-play-bridge copied to clipboard

Getting Property Updates to work with Serial Device

Open djaus2 opened this issue 4 years ago • 0 comments

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

djaus2 avatar Sep 07 '21 04:09 djaus2