Universal Windows Platform (UWP) samples and showcases
Перейти к файлу
Nikola Metulev 4118f2e3c4 Update README.md 2016-12-06 23:09:37 -08:00
ARMTemplate Changed target repo to Microsoft org 2016-10-14 15:19:37 -07:00
BestForYou cleaned up 2016-10-12 21:00:19 -07:00
.gitignore cleaned up 2016-10-12 21:00:19 -07:00
LICENSE added Best For You 2016-10-12 20:25:17 -07:00
README.md Update README.md 2016-12-06 23:09:37 -08:00

README.md

Note: latest code for this sample can be found in the master or iot branch. This branch is deprecated.

Best For You (iot app)

BestForYou

Best For You is a sample fitness UWP app focused on collecting data from a fictional IoT enabled yoga clothes and presenting it to the user in a meaningful and helpful way on all of their devices to track progress of exercise and health.

The solution contains two client side projects and several Azure services:

  1. UWP client app designed for Xbox One, Desktop, and Mobile
  2. UWP IoT app intended to run on an IoT device such as the Raspberry Pi 3 (it can also run on any other UWP device for demo purposes)
  3. Azure IoT Hub, Azure Event Hub, Azure Stream Analytics and more

Architecture

Read the full blog post or visit the App Dev on Xbox landing page for more videos and blogs.

Setup

Cloud

To deploy the Best For Me solution to your Azure subscription you will need to follow the below instructions. We are using Azure Resource Manager to deploy the needed services and connect them to one another. We are also using the Azure cross platform CLI tool which will allow you to deploy the services from your favorite development machine, running Windows, Linux or OSX. The below services will be deployed in your Azure subscription:

  • 1 instance of Azure IoT Hub (using the SKU of your choice, considering you can only deploy 1 instance of the free SKU per subscription)
  • 1 Storage account (Standard performance)
  • 1 Service Bus instance (Basic tier) with 1 Event Hub (1 throughput Unit)
  • 1 Stream Analytics Job (1 streaming unit)

The simplest way is to click on the button below and follow instructions. If you prefer command line tools, or to learn more, checkout the ConnectTheDots project.

Deploy to Azure

Client

  1. Add IoT Hub Connected Service to the HeartRateDevice project and connect it to the IoT Hub service you created in the previous section

    • Make sure Visual Studio is closed and install the Connected Service for Azure IoT Hub
    • Launch Visual Studio, right click on the HeartRateDevice project and click on Add Connected Service
    • Choose Azure IoT Hub and click configure
    • Choose Hardcore shared access key in application's code
    • Make sure you are logged in to Visual Studio with the same account associated with the Azure subscription and select the IoT Hub project you created in the previous section
    • Chose a device to connect - most likely you will need to create one
    • Click OK
  2. In the HeartRateDevice application, change the SendDeviceToCloudMessageAsync method in the AzureIoTHub.cs file to the following:

public static async Task SendDeviceToCloudMessageAsync(double heartBeat)
{
   var deviceClient = DeviceClient.CreateFromConnectionString(deviceConnectionString, TransportType.Amqp);
   var message = new Message(Encoding.ASCII.GetBytes(heartBeat.ToString()));
   await deviceClient.SendEventAsync(message);
}

That's it for the HeartRateDevice, feel free to run it on your desktop and play around with the slider to send the data to Azure IoT Hub. If you want to run it on a real IoT Device, you can run it on a Raspberry Pi 3. We used the FEZ HAT to simulate heart rate by pressing one of the buttons. For more info on connecting your app to Azure IoT Hub, check out this blog post

  1. Next, you will need to add the correct strings in the Keys.cs source file in the Yoga project so it can receive the data from the HeartRateDevice through the IoT Hub and Event Hub.

    • EventHubCompatibleEndpoint and EventHubCompatibleName are found in the Azure Portal under the Event Hub -> Messaging section
    • IoTHubAccessPolicyName and IoTHubAccessPolicyPrimaryKey are found in the Azure Portal under the IoT Hub -> Settings -> Shared Policies

    The project uses the Azure SB Lite library to receive the IoT Hub data. Visit this blog post to learn more about it.

  2. Run