-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix reconnect/reset connection API (#2305)
Fix reconnect/reset connection API (#2291) and swagger update.
- Loading branch information
1 parent
e8b60aa
commit 3f8a26e
Showing
10 changed files
with
109 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// ------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License (MIT). See License.txt in the repo root for license information. | ||
// ------------------------------------------------------------ | ||
|
||
using CommandLine; | ||
using InvokeDeviceMethod; | ||
using Microsoft.Azure.Devices; | ||
using System.Net; | ||
using System.Text.Json; | ||
|
||
Parameters? parameters = null; | ||
ParserResult<Parameters> result = Parser.Default.ParseArguments<Parameters>(args) | ||
.WithParsed(parsedParams => parameters = parsedParams) | ||
.WithNotParsed(errors => Environment.Exit(1)); | ||
|
||
// This sample accepts the service connection string as a parameter, if present. | ||
Parameters.ValidateConnectionStrings(parameters?.IoTHubOwnerConnectionString, parameters?.EdgeHubConnectionString, | ||
out var deviceId, out var moduleId); | ||
|
||
// Create a ServiceClient to communicate with service-facing endpoint on your hub. | ||
using var serviceClient = ServiceClient.CreateFromConnectionString(parameters!.IoTHubOwnerConnectionString); | ||
|
||
Console.WriteLine("Active connections:"); | ||
var methodInvocation = new CloudToDeviceMethod("GetActiveConnections_V2") | ||
{ | ||
ResponseTimeout = TimeSpan.FromSeconds(30), | ||
}; | ||
var response = await serviceClient.InvokeDeviceMethodAsync(deviceId, moduleId, | ||
methodInvocation).ConfigureAwait(false); | ||
var connections = JsonSerializer.Serialize(JsonSerializer.Deserialize<JsonElement>(response.GetPayloadAsJson()), Parameters.Indented); | ||
Console.WriteLine(connections); | ||
|
||
Console.WriteLine("Resetting all connections..."); | ||
methodInvocation = new CloudToDeviceMethod("ResetAllConnections_V2") | ||
{ | ||
ResponseTimeout = TimeSpan.FromSeconds(30), | ||
}; | ||
response = await serviceClient.InvokeDeviceMethodAsync(deviceId, moduleId, | ||
methodInvocation).ConfigureAwait(false); | ||
Console.WriteLine(response.Status); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="..\Parameters.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Azure.Devices" Version="1.39.1" /> | ||
<PackageReference Include="CommandLineParser" Version="2.9.1" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters