📜 ⬆️ ⬇️

Configuring Intel Edison Board for Microsoft Azure IoT suite



This guide will explain how to connect the Intel Edison board to the Microsoft Azure cloud service.

Check that you have the latest version of the image on Intel Edison. To do this, follow the instructions on the Intel site. After that you will need to set up a serial connection . Then you can complete the installation of the Azure IoT SDK using our instructions.
Before you start:

Please note that following the Microsoft instructions for building the Azure IoT SDK for Linux requires cmake version 3.x or higher.

Installing Git on Intel Edison


Git is a distributed version control system. It will need to be installed to clone the Azure IoT SDK and build it locally. For this you need to install packages that include Git. Intel Edison is based on Yocto , uses the package manager opkg and by default does not include Git support.
')
On Intel Edison, add the following lines to the /etc/opkg/base-feeds.conf file:

 src/gz all http://repo.opkg.net/edison/repo/all src/gz edison http://repo.opkg.net/edison/repo/edison src/gz core2-32 http://repo.opkg.net/edison/repo/core2-32 

This can be done, for example, through the built-in editor vi.
 $ vi /etc/opkg/base-feeds.conf 

If you haven't worked with vi before, you can see the instructions . If you can not exit the program, do not panic and do not press Reset, just press Esc, then "SHIFT" + ":" and type wq. So you save the current file and exit the program.

Then update the opkg database:
 $ opkg update 


You should see the following:



Download Azure IoT SDK to Intel Edison Board


Use Git on Intel Edison to clone the Azure SDK repository with the following commands. We recommend using the default folder / home / root:
 $ opkg install git $ git clone git@github.com:Azure/azure-iot-sdks.git 

If you are asked to add an RSA key to your device, answer “yes”.

Alternative Installation Method


If for any reason you cannot clone the Azure IoT SDK directly to your board, first clone the repository to your computer and then transfer the files over the network to the Intel Edison board using FileZilla or SCP.

If you are using FileZilla, define the board address with the command:
 wpa_cli status 

Use "sftp: // addr_address", user "root" and password from the board to establish an SFTP connection with FileZilla. After you do this, you can copy files directly through the network using drag-and-drop.



Build Azure IoT SDK on Intel Edison


You need to make sure that the Azure IoT SDK is installed correctly. For this you need to build an application based on the SDK. Take the C-example AMQP (AMQP - exchange protocol) and change the parameters in it to match our Azure IoT Hub and everything worked after the build.
In the /c/iothub_client/samples/iothub_client_sample_amqp/iothub_client_sample_amqp.c file /c/iothub_client/samples/iothub_client_sample_amqp/iothub_client_sample_amqp.c replace the parameters in the connectionString line with your information, as shown below (static const char * ....). Be sure to do it, otherwise the example will not work.

 static const char* connectionString = “HostName=[YOUR-HOST-NAME];CredentialType=SharedAccessKey;CredentialScope=Device;DeviceId=[YOUR-DEVICE-ID];SharedAccessKey=[YOUR-ACCESS-KEY]; 


In the terminal, go to /c/build_all/linux and follow these steps:

 $ opkg install util-linux-libuuid-dev $ ./build_proton.sh $ ./build.sh 


Update ldconfig cache


We also need to build Qpid Proton - a library for sending messages. And before we test and build our C example, we need to register the resulting library with ldconfig . To do this, we first need to figure out where the Proton library is and then copy it to the /lib folder in Yocto.

Add libqpid-proton.so.2 to shared libraries. To do this, you need to find it by running the following command in the terminal:

 $ find -name 'libqpid-proton.so.2' 
Copy the name of the found directory to the clipboard.

Replace [directory_to_libqpid-proton.so.2] result of the search command from the first step:
 2. $ cp [directory_to_libqpid-proton.so.2] /lib 


This command will automatically update the cache:
 $ ldconfig 

Check:
 $ ldconfig -v | grep "libqpid-p*" 

If you performed all the operations correctly, you will see in the list “libqpid-proton.so.2”
We added a Qpid Proton to ldcache and can build an example C-project based on Proton:

Return to the /c/iothub_client/samples/iothub_client_sample_amqp/iothub_client_sample_amqp/linux
Run
 make -f makefile.linux 

Then
 ./iothub_client_sample_amqp 


The result should be as follows:

 # ./iothub_client_sample_amqp hub_client/samples/iothub_client_sample_amqp/linux# Starting the IoTHub client sample AMQP... IoTHubClient_SetNotificationCallback...successful. IoTHubClient_SendTelemetryAsync accepted data for transmission to IoT Hub. IoTHubClient_SendTelemetryAsync accepted data for transmission to IoT Hub. IoTHubClient_SendTelemetryAsync accepted data for transmission to IoT Hub. IoTHubClient_SendTelemetryAsync accepted data for transmission to IoT Hub. IoTHubClient_SendTelemetryAsync accepted data for transmission to IoT Hub. Press any key to exit the application. Confirmation[0] received for message tracking id = 0 with result = IOTHUB_CLIENT_CONFIRMATION_OK Confirmation[1] received for message tracking id = 1 with result = IOTHUB_CLIENT_CONFIRMATION_OK Confirmation[2] received for message tracking id = 2 with result = IOTHUB_CLIENT_CONFIRMATION_OK Confirmation[3] received for message tracking id = 3 with result = IOTHUB_CLIENT_CONFIRMATION_OK Confirmation[4] received for message tracking id = 4 with result = IOTHUB_CLIENT_CONFIRMATION_OK 

Source: https://habr.com/ru/post/276757/


All Articles