예제 #1
0
        public MainPage()
        {
            this.InitializeComponent();
            // Namespace refers to the string before the .azure-devices.net url
            // Eventhubcompatible name space is the name space provided in the azure IoT Hub portal
            // DeviceName refers to the name of the device in the IoTHub
            // KeyName and Key Value refers to the Access key name and Access key in the Azure portal
            iotHub = new UWPIoTHubSDK.IoTHub("remotecamerahub", "iothub-ns-remotecame-3364-ba3a28ad2c.servicebus.windows.net", "RasberryPi", "iothubowner", "xhuG9TcaieP9s+bNN51KTKy3H73Pw/0Sd8XOyrVJet8=");
            // This handler is passed to the Receive function
            UWPIoTHubSDK.IoTHub.ReceivedData         handler   = DelegateMethod;
            UWPIoTHubSDK.IoTHub.ReceivedFeedBackData handlerFB = DelegateFBMethod;
            // This function is used to send data to the device. In case you need receiverfeedback you can specify call back or ignore it in case you dont need one
            iotHub.SendCloudToDeviceMessage("This is Test Message", handlerFB);
            // Receive message is blocking and once called will be active till we call clean up. So we have to implement it as separate parallel task
            taskReceive = new Task(() =>
            {
                string[] temp = iotHub.GetPartitions();
                foreach (string s in temp)
                {
                    Debug.WriteLine(s);
                }
                iotHub.ReceiveMessagesFromDevice("13", DateTime.UtcNow, handler);
            });

            taskReceive.Start();
        }
예제 #2
0
 public MainPage()
 {
     this.InitializeComponent();
     // Namespace refers to the string before the .azure-devices.net url
     // Eventhubcompatible name space is the name space provided in the azure IoT Hub portal
     // DeviceName refers to the name of the device in the IoTHub
     // KeyName and Key Value refers to the Access key name and Access key in the Azure portal
     iotHub = new UWPIoTHubSDK.IoTHub("remotecamerahub", "iothub-ns-remotecame-3364-ba3a28ad2c.servicebus.windows.net", "RasberryPi", "iothubowner", "xhuG9TcaieP9s+bNN51KTKy3H73Pw/0Sd8XOyrVJet8=");
     // This handler is passed to the Receive function 
     UWPIoTHubSDK.IoTHub.ReceivedData handler = DelegateMethod;
     UWPIoTHubSDK.IoTHub.ReceivedFeedBackData handlerFB = DelegateFBMethod;
     // This function is used to send data to the device. In case you need receiverfeedback you can specify call back or ignore it in case you dont need one 
     iotHub.SendCloudToDeviceMessage("This is Test Message", handlerFB);
     // Receive message is blocking and once called will be active till we call clean up. So we have to implement it as separate parallel task
     taskReceive = new Task(() =>
     {
         string[] temp = iotHub.GetPartitions();
         foreach( string s in temp)
             Debug.WriteLine(s);
         iotHub.ReceiveMessagesFromDevice("13", DateTime.UtcNow, handler);
     });
     
     taskReceive.Start();
 }