Created
July 3, 2022 07:48
-
-
Save hatsunea/adc069ba171c86a0db721d517fd5b170 to your computer and use it in GitHub Desktop.
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
// 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