platform | device | language |
---|---|---|
linux |
trueverit v4 |
c |
- Introduction
- Step 1: Prerequisites
- Step 2: Prepare your Device
- Step 3: Build and Run the Sample
- Tips
About this document
This document describes how to connect Trueverit V4 device running Linux with Azure IoT SDK. This multi-step process includes:
- Configuring Azure IoT Hub
- Registering your IoT device
- Build and deploy Azure IoT SDK on device
You should have the following items ready before beginning the process:
- Prepare your development environment
- Setup your IoT hub
- Provision your device and get its credentials
- Follow the instructions from device website.
-
Open a PuTTY session and connect to the device.
-
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:
sudo apt-get update sudo apt-get install -y curl libcurl4-openssl-dev uuid-dev uuid g++ make cmake git unzip
Note: This setup process requires cmake version 2.8.12 or higher.
You can verify the current version installed in your environment using the following command:
cmake --version
This library also requires gcc version 4.9 or higher. You can verify the current version installed in your environment using the following command:
gcc --version
For information about how to upgrade your version of gcc on Ubuntu 14.04, see http://askubuntu.com/questions/466651/how-do-i-use-the-latest-gcc-4-9-on-ubuntu-14-04.
-
Download the Microsoft Azure IoT Device SDK for C to the board by issuing the following command on the board::
git clone --recursive https://github.com/Azure/azure-iot-sdks.git
-
Verify that you now have a copy of the source code under the directory ~/azure-iot-sdks.
-
Edit the following file using any text editor of your choice:
For AMQP protocol:
azure-iot-sdks/c/iothub_client/samples/iothub_client_sample_amqp/iothub_client_sample_amqp.c
For HTTP protocol:
azure-iot-sdks/c/iothub_client/samples/iothub_client_sample_http/iothub_client_sample_http.c
For MQTT protocol:
azure-iot-sdks/c/iothub_client/samples/iothub_client_sample_mqtt/iothub_client_sample_mqtt.c
-
Find the following place holder for IoT connection string:
static const char* connectionString = "[device connection string]";
-
Replace the above placeholder with device connection string you obtained in Step 1 and save the changes.
-
Open IOT_DEVICE_PARAMS.TXT to edit and set environment variables.
azure-iot-sdks/tools/iot_hub_e2e_tests_params/iot_device_params.txt
-
Set environment variables by running following command on your device:
sudo ./azure-iot-sdks/tools/iot_hub_e2e_tests_params/setiotdeviceparametersfore2etests.sh
-
Restart the Linux machine.
-
Build the SDK using following command.
sudo ./azure-iot-sdks/c/build_all/linux/build.sh | tee LogFile.txt
-
Run the sample by issuing following command:
For AMQP protocol: Run sample iothub_client_sample_amqp
~/cmake/iothub_client/samples/iothub_client_sample_amqp/iothub_client_sample_amqp
For HTTP protocol: Run sample iothub_client_sample_http
~/cmake/iothub_client/samples/iothub_client_sample_http/iothub_client_sample_http
For MQTT protocol: Run sample iothub_client_sample_mqtt
~/cmake/iothub_client/samples/iothub_client_sample_mqtt/iothub_client_sample_mqtt
-
See Manage IoT Hub to learn how to observe the messages IoT Hub receives from the application.
- See Manage IoT Hub to learn how to send cloud-to-device messages to the application.
-
If you just want to build the serializer samples, run the following commands:
cd ./c/serializer/build/linux make -f makefile.linux all