platform | device | language |
---|---|---|
Debian GNU Linux 7 |
OpenBlocks IoT BX1G |
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 OpenBlocks IoT BX1G device running Debian GNU Linux 7 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
- OpenBlocks IoT BX1G device.
-
Add following lines in /etc/apt/sources.list
deb http://cdn.debian.or.jp/debian/ wheezy-backports main deb-src http://cdn.debian.or.jp/debian/ wheezy-backports main deb http://http.us.debian.org/debian/ testing contrib main
-
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:
apt-get update apt-get install -y gcc-4.9 g++4.9 apt-get install -y curl libcurl4-openssl-dev uuid-dev uuid g++ make git unzip openjdk-7-jre apt-get -y -t wheezy-backports cmake
-
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
-
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.
-
Build the SDK using following command.
./azure-iot-sdks/c/build_all/linux/build.sh
-
Run the sample by issuing following command:
If using AMQP protocol:
azure-iot-sdks/c/cmake/iotsdk_linux/iothub_client/samples/iothub_client_sample_amqp/iothub_client_sample_amqp
If using HTTP protocol:
azure-iot-sdks/c/cmake/iotsdk_linux/iothub_client/samples/iothub_client_sample_http/iothub_client_sample_http
If using MQTT protocol:
azure-iot-sdks/c/cmake/iotsdk_linux/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