| platform | Linaro |
|---|---|
| device | SMART |
| language | 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 SMART device running Linaro 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:
- Micro USB to USB Cable.
- SMART device(It have own wifi device to connect the Internet).
- Take "Ubuntu 14.04 x86_64" as linaro develope system.
- Setup your IoT hub
- Provision your device and get its credentials
On ubuntu 14.04 linux system,we can use micro USB cable to connect SMART device,use andriod-tools-adb to communicate datas with SMART device and run adb shell command. SO:
-
install android device tools:
sudo apt-get install -y android-tools-adb -
Connect SMART device with micro USB cable.
-
Open ubuntu linux bash shell and run:
adb root adb shell
and then you can connect to SMART 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 and in Ubuntu Linux:
-
Install development environment:
sudo apt-get update sudo apt-get install -y uuid-dev build-essential cmake git ***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 -
Install SMART device toolchain (package from qualcomm official website).
-
Install qrSDK and get rootfs (package from qualcomm official website). set env param $QTI_SYSTEM_ROOT as rootfs dirictory path
-
Get curl-7.42.0 package and build libcurl with SMART toolchain:
./configure --host=arm-linux-gnueabi make cp include/curl/ ${QTI_SYSTEM_ROOT}/usr/include/ -rf cp lib/.lib/libcurl.so* ${QTI_SYSTEM_ROOT}/usr/lib -r -
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.cFor HTTPS protocol:
azure-iot-sdks/c/iothub_client/samples/iothub_client_sample_http/iothub_client_sample_http.cFor 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.
-
Create gcc_qti.cmake in azure-iot-sdks directory; gcc_qti.cmake file show below:
#gcc_qti.cmake INCLUDE(CMakeForceCompiler) SET(CMAKE_SYSTEM_NAME Linux) # this one is important SET(CMAKE_SYSTEM_VERSION 1) # this one not so much # this is the location of the amd64 toolchain targeting the Raspberry Pi SET(CMAKE_C_COMPILER $ENV{QTI_TOOLCHAIN_ROOT}/bin/arm-linux-gnueabihf-gcc) SET(CMAKE_CXX_COMPILER $ENV{QTI_TOOLCHAIN_ROOT}/bin/arm-linux-gnueabihf-g++) # this is the file system root of the target SET(CMAKE_FIND_ROOT_PATH $ENV{QTI_SYSTEM_ROOT}) # search for programs in the build host directories SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # for libraries and headers in the target directories SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -
Build the SDK using following command.
cd ./azure-iot-sdks/ sudo ./c/build_all/linux/build.sh --toolchain-file ./gcc_qti.cmake --skip-e2e-tests --skip-unittests -cl -D__STDC_NO_ATOMICS__ -cl --sysroot=$QTI_SYSTEM_ROOT -
Copy exe-data and dll to SMART device
adb push ~/cmake/iothub_client/samples/iothub_client_sample_http/iothub_client_sample_http /home/iottest/ adb push ~/cmake/iothub_client/samples/iothub_client_sample_mqtt/iothub_client_sample_mqtt /home/iottest/ adb push ~/cmake/iothub_client/samples/iothub_client_sample_amqp/iothub_client_sample_amqp /home/iottest/ adb push ${QTI_SYSTEM_ROOT}/usr/lib/libcurl* /usr/lib/
-
Enter into adb shell
adb shell -
Run the sample by issuing following command:
Test AMQP protocol:
/home/iottest/iothub_client_sample_amqpTest HTTPS protocol:
/home/iottest/iothub_client_sample_httpTest MQTT protocol:
/home/iottest/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