cleaned up
This commit is contained in:
Родитель
d5e9a84a00
Коммит
a0362b0f0e
|
@ -186,7 +186,6 @@ ClientBin/
|
||||||
*~
|
*~
|
||||||
*.dbmdl
|
*.dbmdl
|
||||||
*.dbproj.schemaview
|
*.dbproj.schemaview
|
||||||
*.pfx
|
|
||||||
*.publishsettings
|
*.publishsettings
|
||||||
node_modules/
|
node_modules/
|
||||||
orleans.codegen.cs
|
orleans.codegen.cs
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Azure.Devices.Client;
|
|
||||||
|
|
||||||
static class AzureIoTHub
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Note: this connection string is specific to the device "YogaPants". To configure other devices,
|
|
||||||
// see information on iothub-explorer at http://aka.ms/iothubgetstartedVSCS
|
|
||||||
//
|
|
||||||
const string deviceConnectionString = "HostName=ctdnikolahub.azure-devices.net;DeviceId=YogaPants;SharedAccessKey=c4riiHpgcDHwc2E4khzz7DnMjuKMSelHcBLkXKict+8=";
|
|
||||||
|
|
||||||
//
|
|
||||||
// To monitor messages sent to device "YogaPants" use iothub-explorer as follows:
|
|
||||||
// iothub-explorer HostName=ctdnikolahub.azure-devices.net;SharedAccessKeyName=service;SharedAccessKey=DS9jlVVIot0joEjp/wmJhr2v0vuJuuNBqGUWtP+OOvs= monitor-events "YogaPants"
|
|
||||||
//
|
|
||||||
|
|
||||||
// Refer to http://aka.ms/azure-iot-hub-vs-cs-wiki for more information on Connected Service for Azure IoT Hub
|
|
||||||
|
|
||||||
public static async Task SendDeviceToCloudMessageAsync()
|
|
||||||
{
|
|
||||||
var deviceClient = DeviceClient.CreateFromConnectionString(deviceConnectionString, TransportType.Amqp);
|
|
||||||
|
|
||||||
#if WINDOWS_UWP
|
|
||||||
var str = "Hello, Cloud from a UWP C# app!";
|
|
||||||
#else
|
|
||||||
var str = "Hello, Cloud from a C# app!";
|
|
||||||
#endif
|
|
||||||
var message = new Message(Encoding.ASCII.GetBytes(str));
|
|
||||||
|
|
||||||
await deviceClient.SendEventAsync(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async Task<string> ReceiveCloudToDeviceMessageAsync()
|
|
||||||
{
|
|
||||||
var deviceClient = DeviceClient.CreateFromConnectionString(deviceConnectionString, TransportType.Amqp);
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
var receivedMessage = await deviceClient.ReceiveAsync();
|
|
||||||
|
|
||||||
if (receivedMessage != null)
|
|
||||||
{
|
|
||||||
var messageData = Encoding.ASCII.GetString(receivedMessage.GetBytes());
|
|
||||||
await deviceClient.CompleteAsync(receivedMessage);
|
|
||||||
return messageData;
|
|
||||||
}
|
|
||||||
|
|
||||||
await Task.Delay(TimeSpan.FromSeconds(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Двоичный файл не отображается.
|
@ -1,7 +0,0 @@
|
||||||
{
|
|
||||||
"ProviderId": "Microsoft.AzureIoTHubService",
|
|
||||||
"Version": "1.5.0",
|
|
||||||
"GettingStartedDocument": {
|
|
||||||
"Uri": "http://aka.ms/azure-iot-hub-vs-cs-cs"
|
|
||||||
}
|
|
||||||
}
|
|
Двоичный файл не отображается.
Загрузка…
Ссылка в новой задаче