Azure / azure-iot-sdk-c

A C99 SDK for connecting devices to Microsoft Azure IoT services
https://azure.github.io/azure-iot-sdk-c
Other
588 stars 739 forks source link

[public-preview]Reported property failed with a 400 status code (same issue) #1420

Closed uriel-kluk closed 4 years ago

uriel-kluk commented 4 years ago

1147

Created my template and stub my code with CodeGen but getting the 400 error when sending the reported properties.

Commands, Telemetry and Desired properties are working

Info: Successfully created DigitalTwin device with connectionString=<****>, deviceHandle=<0x2001b820>
Info: DigitalTwin Interface : Changing interface state on interface DeviceInformation_1ny from DT_INTERFACE_STATE_UNINITIALIZED to DT_INTERFACE_STATE_CREATED
Info: DEVICEINFORMATION_1NY_INTERFACE: Created DIGITALTWIN_INTERFACE_CLIENT_HANDLE successfully for interfaceId=<urn:azureiot:DeviceManagement:DeviceInformation:1>, interfaceInstanceName=<DeviceInformation_1ny>, handle=<0x20024af8>
Info: DigitalTwin Interface : Changing interface state on interface Scanner_5a from DT_INTERFACE_STATE_UNINITIALIZED to DT_INTERFACE_STATE_CREATED
Info: SCANNER_5A_INTERFACE: Created DIGITALTWIN_INTERFACE_CLIENT_HANDLE successfully for interfaceId=<urn:traxsmart:blerelay:1>, interfaceInstanceName=<Scanner_5a>, handle=<0x20026660>
Info: DigitalTwin Interface : Changing interface state on interface DeviceInformation_1ny from DT_INTERFACE_STATE_CREATED to DT_INTERFACE_STATE_BOUND_TO_CLIENT_HANDLE
Info: DigitalTwin Interface : Changing interface state on interface Scanner_5a from DT_INTERFACE_STATE_CREATED to DT_INTERFACE_STATE_BOUND_TO_CLIENT_HANDLE
Info: Successfully queued registration message
Info: DigitalTwin Client Core: Processing register DigitalTwin interfaces callback.  confirmationResult=IOTHUB_CLIENT_CONFIRMATION_OK
Info: DigitalTwin Client Core: Interfaces successfully registered.  Register for device method and twin callbacks if needed
Info: DigitalTwin Interface : Changing interface state on interface DeviceInformation_1ny from DT_INTERFACE_STATE_BOUND_TO_CLIENT_HANDLE to DT_INTERFACE_STATE_REGISTERED
Info: DeviceInformation_2xuInterface_InterfaceRegisteredCallback with status=<DIGITALTWIN_CLIENT_OK>, userContext=<0x20002f58>
Info: DEVICEINFORMATION_1NY_INTERFACE: Interface successfully registered.
Info: DigitalTwin Interface : Changing interface state on interface Scanner_5a from DT_INTERFACE_STATE_BOUND_TO_CLIENT_HANDLE to DT_INTERFACE_STATE_REGISTERED
Info: Scanner_5aInterface_InterfaceRegisteredCallback with status=<DIGITALTWIN_CLIENT_OK>, userContext=<0x20002f64>
Info: SCANNER_5A_INTERFACE: Interface successfully registered.
Info: Interface registration callback invoked, interfaces have been successfully registered
Info: DigitalTwin interfaces successfully registered
{"$iotin:DeviceInformation_1ny": { "manufacturer": { "value": "Mesh Systems" } } }
Info: DEVICE_INFO: Queued async report read only property for manufacturer
{"$iotin:DeviceInformation_1ny": { "model": { "value": "txs_sd_catm1" } } }
Info: DEVICE_INFO: Queued async report read only property for model
{"$iotin:DeviceInformation_1ny": { "swVersion": { "value": "1.84, 0x21C93A02, vC-MF-B8" } } }
Info: DEVICE_INFO: Queued async report read only property for swVersion
{"$iotin:DeviceInformation_1ny": { "osName": { "value": "FreeRTOS" } } }
Info: DEVICE_INFO: Queued async report read only property for osName
{"$iotin:DeviceInformation_1ny": { "processorArchitecture": { "value": "32-bit" } } }
Info: DEVICE_INFO: Queued async report read only property for processorArchitecture
{"$iotin:DeviceInformation_1ny": { "processorManufacturer": { "value": "STMicroelectronics" } } }
Info: DEVICE_INFO: Queued async report read only property for processorManufacturer
{"$iotin:DeviceInformation_1ny": { "totalStorage": { "value": 0 } } }
Info: DEVICE_INFO: Queued async report read only property for totalStorage
{"$iotin:DeviceInformation_1ny": { "totalMemory": { "value": 0 } } }
Info: DEVICE_INFO: Queued async report read only property for totalMemory
Info: DEVICE_INFO: Queuing of all properties to be reported has succeeded
Info: DigitalTwin Client Core: Processing callback for reported state update.  status=400, userContextCallback=0x2001bcb8
Error: Time:Thu Feb  6 21:54:11 2020 File:C:/_Src/Ophelia_FW_Exterior_MCU/Mesh_FwLib_STM32CubeExpansion_Cloud_AZURE/Middlewares/Third_Party/azure-iot-sdk-c/digitaltwin_client/src/dt_client_core.c Func:ReportedDTStateUpdate_Callback Line:603 Reported property failed with a 400 status code
Error: Time:Thu Feb  6 21:54:11 2020 File:C:/_Src/Ophelia_FW_Exterior_MCU/Mesh_FwLib_STM32CubeExpansion_Cloud_AZURE/Middlewares/Third_Party/azure-iot-sdk-c/digitaltwin_client/src/dt_client_core.c Func:ReportedDTStateUpdate_Callback Line:604 This typically but not always means the JSON the application sent was invalid.
Info: DigitalTwin Interface: Invoking reported property update for component name=DeviceInformation_1ny, reportedStatus=DIGITALTWIN_CLIENT_ERROR, userContextCallback=0x8099a48
Info: DigitalTwin failed to report writable property for <DeviceInformation_2ex> <manufacturer>
Info: DEVICEINFORMATION_1NY_INTERFACE: Updating property=<manufacturer> failed, error=<DIGITALTWIN_CLIENT_ERROR>
Info: DigitalTwin Interface: Invoking reported property update returned
Info: DigitalTwin Client Core: Processing callback for reported state update.  status=400, userContextCallback=0x2001cc00
Error: Time:Thu Feb  6 21:54:11 2020 File:C:/_Src/Ophelia_FW_Exterior_MCU/Mesh_FwLib_STM32CubeExpansion_Cloud_AZURE/Middlewares/Third_Party/azure-iot-sdk-c/digitaltwin_client/src/dt_client_core.c Func:ReportedDTStateUpdate_Callback Line:603 Reported property failed with a 400 status code
Error: Time:Thu Feb  6 21:54:11 2020 File:C:/_Src/Ophelia_FW_Exterior_MCU/Mesh_FwLib_STM32CubeExpansion_Cloud_AZURE/Middlewares/Third_Party/azure-iot-sdk-c/digitaltwin_client/src/dt_client_core.c Func:ReportedDTStateUpdate_Callback Line:604 This typically but not always means the JSON the application sent was invalid.
Info: DigitalTwin Interface: Invoking reported property update for component name=DeviceInformation_1ny, reportedStatus=DIGITALTWIN_CLIENT_ERROR, userContextCallback=0x8099adc
Info: DigitalTwin failed to report writable property for <DeviceInformation_2ex> <model>
Info: DEVICEINFORMATION_1NY_INTERFACE: Updating property=<model> failed, error=<DIGITALTWIN_CLIENT_ERROR>
Info: DigitalTwin Interface: Invoking reported property update returned
Info: DigitalTwin Client Core: Processing callback for reported state update.  status=400, userContextCallback=0x2001caf8
Error: Time:Thu Feb  6 21:54:11 2020 File:C:/_Src/Ophelia_FW_Exterior_MCU/Mesh_FwLib_STM32CubeExpansion_Cloud_AZURE/Middlewares/Third_Party/azure-iot-sdk-c/digitaltwin_client/src/dt_client_core.c Func:ReportedDTStateUpdate_Callback Line:603 Reported property failed with a 400 status code
Error: Time:Thu Feb  6 21:54:11 2020 File:C:/_Src/Ophelia_FW_Exterior_MCU/Mesh_FwLib_STM32CubeExpansion_Cloud_AZURE/Middlewares/Third_Party/azure-iot-sdk-c/digitaltwin_client/src/dt_client_core.c Func:ReportedDTStateUpdate_Callback Line:604 This typically but not always means the JSON the application sent was invalid.
Info: DigitalTwin Interface: Invoking reported property update for component name=DeviceInformation_1ny, reportedStatus=DIGITALTWIN_CLIENT_ERROR, userContextCallback=0x8099ae4
Info: DigitalTwin failed to report writable property for <DeviceInformation_2ex> <swVersion>
Info: DEVICEINFORMATION_1NY_INTERFACE: Updating property=<swVersion> failed, error=<DIGITALTWIN_CLIENT_ERROR>
Info: DigitalTwin Interface: Invoking reported property update returned
Info: DigitalTwin Client Core: Processing callback for reported state update.  status=400, userContextCallback=0x2001cb30
Error: Time:Thu Feb  6 21:54:11 2020 File:C:/_Src/Ophelia_FW_Exterior_MCU/Mesh_FwLib_STM32CubeExpansion_Cloud_AZURE/Middlewares/Third_Party/azure-iot-sdk-c/digitaltwin_client/src/dt_client_core.c Func:ReportedDTStateUpdate_Callback Line:603 Reported property failed with a 400 status code
Error: Time:Thu Feb  6 21:54:11 2020 File:C:/_Src/Ophelia_FW_Exterior_MCU/Mesh_FwLib_STM32CubeExpansion_Cloud_AZURE/Middlewares/Third_Party/azure-iot-sdk-c/digitaltwin_client/src/dt_client_core.c Func:ReportedDTStateUpdate_Callback Line:604 This typically but not always means the JSON the application sent was invalid.
Info: DigitalTwin Interface: Invoking reported property update for component name=DeviceInformation_1ny, reportedStatus=DIGITALTWIN_CLIENT_ERROR, userContextCallback=0x8099b40
Info: DigitalTwin failed to report writable property for <DeviceInformation_2ex> <osName>
Info: DEVICEINFORMATION_1NY_INTERFACE: Updating property=<osName> failed, error=<DIGITALTWIN_CLIENT_ERROR>
Info: DigitalTwin Interface: Invoking reported property update returned
Info: DigitalTwin Client Core: Processing callback for reported state update.  status=400, userContextCallback=0x2001cdb0
Error: Time:Thu Feb  6 21:54:11 2020 File:C:/_Src/Ophelia_FW_Exterior_MCU/Mesh_FwLib_STM32CubeExpansion_Cloud_AZURE/Middlewares/Third_Party/azure-iot-sdk-c/digitaltwin_client/src/dt_client_core.c Func:ReportedDTStateUpdate_Callback Line:603 Reported property failed with a 400 status code
Error: Time:Thu Feb  6 21:54:11 2020 File:C:/_Src/Ophelia_FW_Exterior_MCU/Mesh_FwLib_STM32CubeExpansion_Cloud_AZURE/Middlewares/Third_Party/azure-iot-sdk-c/digitaltwin_client/src/dt_client_core.c Func:ReportedDTStateUpdate_Callback Line:604 This typically but not always means the JSON the application sent was invalid.
Info: DigitalTwin Interface: Invoking reported property update for component name=DeviceInformation_1ny, reportedStatus=DIGITALTWIN_CLIENT_ERROR, userContextCallback=0x8099b54
Info: DigitalTwin failed to report writable property for <DeviceInformation_2ex> <processorArchitecture>
Info: DEVICEINFORMATION_1NY_INTERFACE: Updating property=<processorArchitecture> failed, error=<DIGITALTWIN_CLIENT_ERROR>
Info: DigitalTwin Interface: Invoking reported property update returned
Info: DigitalTwin Client Core: Processing callback for reported state update.  status=400, userContextCallback=0x2001ccd8
Error: Time:Thu Feb  6 21:54:11 2020 File:C:/_Src/Ophelia_FW_Exterior_MCU/Mesh_FwLib_STM32CubeExpansion_Cloud_AZURE/Middlewares/Third_Party/azure-iot-sdk-c/digitaltwin_client/src/dt_client_core.c Func:ReportedDTStateUpdate_Callback Line:603 Reported property failed with a 400 status code
Error: Time:Thu Feb  6 21:54:11 2020 File:C:/_Src/Ophelia_FW_Exterior_MCU/Mesh_FwLib_STM32CubeExpansion_Cloud_AZURE/Middlewares/Third_Party/azure-iot-sdk-c/digitaltwin_client/src/dt_client_core.c Func:ReportedDTStateUpdate_Callback Line:604 This typically but not always means the JSON the application sent was invalid.
Info: DigitalTwin Interface: Invoking reported property update for component name=DeviceInformation_1ny, reportedStatus=DIGITALTWIN_CLIENT_ERROR, userContextCallback=0x8099b78
Info: DigitalTwin failed to report writable property for <DeviceInformation_2ex> <processorManufacturer>
Info: DEVICEINFORMATION_1NY_INTERFACE: Updating property=<processorManufacturer> failed, error=<DIGITALTWIN_CLIENT_ERROR>
ShanmathiP commented 4 years ago

Hi, azure-iot-sdk-c - https://github.com/Azure/azure-iot-sdk-c/tree/1.3.8 digital client code - https://github.com/Azure/azure-iot-sdk-c/tree/76393ea9e407bb5ea9a181f223f5b37f510a1acc/digitaltwin_client

I have also faced the same issue for "Properties", using the auto generated code stub. Any clue regarding this would be helpful.

uriel-kluk commented 4 years ago

Microsoft support helped me to discover the issue. Kudos to @Ishu. The branch public_preview_pnphandles the callbacks for the twin differently from what the CodeGen expects. I updated my project using the public_preview branch and now the reported properties work fine.

I strongly suggest deprecating the public_preview_pnp branch. or at least add a big message in the documentation. For developers, if you attended the PnP workshops, we started with the wrong branch switch over :)

jspaith commented 4 years ago

Indeed thanks @ishu for help on this one.

@uriel-kluk - could you let me know where you heard to use public-preview-pnp, either in docs or from presenters? The public-preview branch is one we strongly recommend customers use for most development. public-preview-pnp is our advance working branch which is still good (it runs against gates for checkins) but is out ahead and in particular will break things for code-gen.

uriel-kluk commented 4 years ago

Hi @jspaith

On April 8, 2019 we got invited to participate in the PnP Private preview. We worked on a FreeRTOS and mBed TLS so we couldn't use the vkpkg solution. I don't want to blame anyone and it is possible that we misinterpret the instructions from private to public preview

But these were our original links.: I am only sharing to ensure other developers don't start from the public_preview_pnp branch. This issue can be closed :)

Thanks so much for taking the time to chat with us last week. I wanted to follow-up with the links to try our PnP Private Preview. We will have a Public Preview in the upcoming months.

I will make sure you get access to the following: https://github.com/Azure/Azure-IoT-PnP-Preview

To access Private Preview on Central visit: https://aka.ms/iotc-demo

Central documentation can be found here: https://github.com/Azure/Azure-IoT-PnP-Preview/tree/master/Central

Please let me know if you have any questions or feedback!

jspaith commented 4 years ago

@uriel-kluk - appreciate you not wanting to blame anyone :) - I don't want to, either.

I've opened https://github.com/Azure/azure-iot-sdk-c/issues/1447 to track making our docs clearer.

Thanks for followup here.

John

az-iot-builder-01 commented 4 years ago

@ShanmathiP, @uriel-kluk, @jspaith, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey