Home icon indicating copy to clipboard operation
Home copied to clipboard

Direct Method doesn't work for PnP Device with components

Open romankiss opened this issue 3 years ago • 3 comments

Library/API/IoT binding

nanoFramework.Azure.Devices.Client

Visual Studio version

VS2022 Version 17.3.6

.NET nanoFramework extension version

2022.2.0.44

Target name(s)

M5StickCPlus

Firmware version

1.8.0.643

Device capabilities

No response

Description

Source file: nanoFramework.Azure.Devices/nanoFramework.Azure.Devices.Client/DeviceClient.cs

  1. DirectMethodTopic (line 447+) is working well for default (root) component direct method, but for other ones will never invoke its delegate, in other words there is no match for methodName contains a star character, for instance, thermostat1*getMaxMinReport, therefore this part must be fixed replacing by underscore ('_') character and delegate name should be used as thermostat1_getMaxMinReport.

  2. DirectMethodTopic Return Call (line 468) doesn't handle a long-running command ( https://learn.microsoft.com/en-us/azure/iot-central/core/howto-use-commands#long-running-commands) where a response back return 202 code, such as Accepted to indicate, that the result is pending. For this case the delegate will return either the res=null or res="" and based on this, the topic should be in the line 468 looks like the following: $"$iothub/methods/res/202/?$rid={rid:X}". Note, that the payload should be shows a text, that the command is in pending process.

Thanks Roman

How to reproduce

No response

Expected behaviour

No response

Screenshots

No response

Sample project or code

No response

Aditional information

No response

romankiss avatar Oct 19 '22 21:10 romankiss

Thanks for the sumission.

On case 1: you basically ask to replace in the coming "Topic" the character * by _ so it can be used in the methog name. correct? If it's about this, please do not hesitate to provide a PR.

On case 2: correct, there is no support for long running. nanoFramework is nano, so there are couple of elements that we decided not to implement for simplification. If that's business critical for you, feel free to propose a PR to add this capability.

Ellerbach avatar Oct 20 '22 12:10 Ellerbach

@romankiss can you please point me to the Azure docs where the naming handling is explained? (the 1st part about replacing the * with _)

josesimoes avatar Nov 23 '22 02:11 josesimoes

Hi @josesimoes , the naming handling for direct method invoked on the component in the PnP device is described in the IoT Plug and Play device developer guide and IoT Plug and Play conventions.

romankiss avatar Nov 23 '22 11:11 romankiss