|
| 1 | +--- |
| 2 | +platform: ubuntu |
| 3 | +device: adle3800pc |
| 4 | +language: c |
| 5 | +--- |
| 6 | + |
| 7 | +Run a simple C sample on ADLE3800PC device running Ubuntu |
| 8 | +=== |
| 9 | +--- |
| 10 | + |
| 11 | +# Table of Contents |
| 12 | + |
| 13 | +- [Introduction](#Introduction) |
| 14 | +- [Step 1: Prerequisites](#Prerequisites) |
| 15 | +- [Step 2: Prepare your Device](#PrepareDevice) |
| 16 | +- [Step 3: Build and Run the Sample](#Build) |
| 17 | + |
| 18 | +<a name="Introduction"></a> |
| 19 | +# Introduction |
| 20 | + |
| 21 | +**About this document** |
| 22 | + |
| 23 | +This document describes how to connect ADLE3800PC device running Ubuntu with Azure IoT SDK. This multi-step process includes: |
| 24 | + |
| 25 | +- Configuring Azure IoT Hub |
| 26 | +- Registering your IoT device |
| 27 | +- Build and deploy Azure IoT SDK on device |
| 28 | + |
| 29 | +<a name="Prerequisites"></a> |
| 30 | +# Step 1: Prerequisites |
| 31 | + |
| 32 | +You should have the following items ready before beginning the process: |
| 33 | + |
| 34 | +- [Prepare your development environment][setup-devbox-linux] |
| 35 | +- [Setup your IoT hub][lnk-setup-iot-hub] |
| 36 | +- [Provision your device and get its credentials][lnk-manage-iot-hub] |
| 37 | +- ADLE3800PC device |
| 38 | + |
| 39 | +<a name="PrepareDevice"></a> |
| 40 | +# Step 2: Prepare your Device |
| 41 | + |
| 42 | +- Install Ubuntu 14.04 on ADLE3800PC |
| 43 | + |
| 44 | +<a name="Build"></a> |
| 45 | +# Step 3: Build and Run the sample |
| 46 | + |
| 47 | +<a name="Load"></a> |
| 48 | +## 3.1 Build SDK and sample |
| 49 | + |
| 50 | +- Open a PuTTY session and connect to the device. |
| 51 | + |
| 52 | +- Install the prerequisite packages for the Microsoft Azure IoT Device SDK for C by issuing the following commands from the command line on your board: |
| 53 | + |
| 54 | + sudo apt-get update |
| 55 | + |
| 56 | + sudo apt-get install -y curl libcurl4-openssl-dev uuid-dev uuid g++ make cmake git unzip openjdk-7-jre |
| 57 | + |
| 58 | +- Download the Microsoft Azure IoT Device SDK for C to the board by issuing the following command on the board:: |
| 59 | + |
| 60 | + git clone --recursive https://github.com/Azure/azure-iot-sdks.git |
| 61 | + |
| 62 | +- Edit the following file using any text editor of your choice: |
| 63 | + |
| 64 | + **For AMQP protocol:** |
| 65 | + |
| 66 | + azure-iot-sdks/c/iothub_client/samples/iothub_client_sample_amqp/iothub_client_sample_amqp.c |
| 67 | + |
| 68 | + **For HTTPS protocol:** |
| 69 | + |
| 70 | + azure-iot-sdks/c/iothub_client/samples/iothub_client_sample_http/iothub_client_sample_http.c |
| 71 | + |
| 72 | + **For MQTT protocol:** |
| 73 | + |
| 74 | + azure-iot-sdks/c/iothub_client/samples/iothub_client_sample_mqtt/iothub_client_sample_mqtt.c |
| 75 | + |
| 76 | +- Find the following place holder for IoT connection string: |
| 77 | + |
| 78 | + static const char* connectionString = "[device connection string]"; |
| 79 | + |
| 80 | +- Replace the above placeholder with device connection string you obtained in [Step 1](#Prerequisites) and save the changes. |
| 81 | + |
| 82 | +- Build the SDK using following command. |
| 83 | + |
| 84 | + sudo ./azure-iot-sdks/c/build_all/linux/build.sh |
| 85 | + |
| 86 | +## 3.2 Send Device Events to IoT Hub: |
| 87 | + |
| 88 | +- Run the sample by issuing following command: |
| 89 | + |
| 90 | + **If using AMQP protocol:** |
| 91 | + |
| 92 | + ~/azure-iot-sdks/c/cmake/iotsdk_linux/iothub_client/samples/iothub_client_sample_amqp/iothub_client_sample_amqp |
| 93 | + |
| 94 | + **If using HTTP protocol:** |
| 95 | + |
| 96 | + ~/azure-iot-sdks/c/cmake/iotsdk_linux/iothub_client/samples/iothub_client_sample_http/iothub_client_sample_http |
| 97 | + |
| 98 | + **If using MQTT protocol:** |
| 99 | + |
| 100 | + ~/azure-iot-sdks/c/cmake/iotsdk_linux/iothub_client/samples/iothub_client_sample_mqtt/iothub_client_sample_mqtt |
| 101 | + |
| 102 | +- See [Manage IoT Hub][lnk-manage-iot-hub] to learn how to observe the messages IoT Hub receives from the application. |
| 103 | + |
| 104 | +## 3.3 Receive messages from IoT Hub |
| 105 | + |
| 106 | +- See [Manage IoT Hub][lnk-manage-iot-hub] to learn how to send cloud-to-device messages to the application. |
| 107 | + |
| 108 | +<a name="tips"></a> |
| 109 | +# Tips |
| 110 | + |
| 111 | +- If you just want to build the serializer samples, run the following commands: |
| 112 | + |
| 113 | + ``` |
| 114 | + cd ./c/serializer/build/linux |
| 115 | + make -f makefile.linux all |
| 116 | + ``` |
| 117 | + |
| 118 | +[setup-devbox-linux]: https://github.com/Azure/azure-iot-sdk-c/blob/master/doc/devbox_setup.md |
| 119 | +[lnk-setup-iot-hub]: ../setup_iothub.md |
| 120 | +[lnk-manage-iot-hub]: ../manage_iot_hub.md |
0 commit comments