Skip to content

Instantly share code, notes, and snippets.

@hatsunea
Created July 3, 2022 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hatsunea/adc069ba171c86a0db721d517fd5b170 to your computer and use it in GitHub Desktop.
Save hatsunea/adc069ba171c86a0db721d517fd5b170 to your computer and use it in GitHub Desktop.
// DSP接続
Console.WriteLine($" > Connecting....");
var azureCert = new X509Certificate(Resource.GetBytes(Resource.BinaryResources.BaltimoreCyberTrustRoot));
var provisioning = ProvisioningDeviceClient.Create(HostName, Idscope, DeviceId, SharedAccessKey, azureCert);
var myDevice = provisioning.Register(null, new CancellationTokenSource(30000).Token);
// Azure IoT Central 接続
Client = new DeviceClient(myDevice.AssignedHub, DeviceId, SharedAccessKey, azureCert: azureCert);
while (true)
{
try
{
if (Client.Open()) break;
}
catch
{
Console.CursorTop--; Console.WriteLine($" > Connect Faild");
Thread.Sleep(1000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment