如何使用 iot-service-client java 获取 DeviceScope

How to fetch DeviceScope using iot-service-client java

我正在尝试获取 deviceTwin 的 deviceScope。但是,在 DeviceTwinDevice 中没有返回 deviceScope。

String iotHubConnectionString  = "xxx";

DeviceTwin twinClient = DeviceTwin.createFromConnectionString(iotHubConnectionString);

SqlQuery sqlQuery = SqlQuery.createSqlQuery("*",SqlQuery.FromType.DEVICES,"capabilities.iotEdge=false",null);
Query twinQuery = twinClient.queryTwin(sqlQuery.getQuery());
            
DeviceTwinDevice d = twinClient.getNextDeviceTwin(twinQuery);

感谢https://github.com/Azure/azure-iot-sdk-java/issues/1157。必须使用 registerManager