title | description | services | documentationcenter | author | manager | tags | keywords | ms.assetid | ms.service | ms.devlang | ms.topic | ms.tgt_pltfrm | ms.workload | ms.date | ms.author |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Data conversion on IoT gateway with Azure IoT Edge | Microsoft Docs |
Use IoT gateway to convert the format of sensor data through a customized module from Azure IoT Edge. |
iot-hub |
shizn |
timlt |
iot gateway data conversion, iot gateway data transformation |
75f2573d-500b-4405-bff7-61021c4c3500 |
iot-hub |
c |
article |
na |
na |
06/25/2017 |
xshi |
Note
Before you start this tutorial, make sure you've completed the following lessons in sequence:
One purpose of an Iot gateway is to process collected data before sending it to the cloud. Azure IoT Edge introduces modules which can be created and assembled to form the data processing workflow. A module receives a message, performs some action on it, and then move it on for other modules to process.
You learn how to create a module to convert messages from the SensorTag into a different format.
- Create a module to convert a received message into the .json format.
- Compile the module.
- Add the module to the BLE sample application from Azure IoT Edge.
- Run the sample application.
- The following tutorials completed in sequence:
- An SSH client that runs on your host computer. PuTTY is recommended on Windows. Linux and macOS already come with an SSH client.
- The IP address and the username and password to access the gateway from the SSH client.
- An Internet connection.
-
On the host computer, run the SSH client and connect to the IoT gateway.
-
Clone the source files of the conversion module from GitHub to the home directory of the IoT gateway by running the following commands:
cd ~ git clone https://github.com/Azure-Samples/iot-hub-c-intel-nuc-gateway-customized-module.git
This is a native Azure Edge module written in the C programming language. The module converts the format of received messages into the following one:
{"deviceId": "Intel NUC Gateway", "messageId": 0, "temperature": 0.0}
To compile the module, run the following commands:
cd iot-hub-c-intel-nuc-gateway-customized-module/my_module
# change the build script runnable
chmod 777 build.sh
# remove the invalid windows character
sed -i -e "s/\r$//" build.sh
# run the build shell script
./build.sh
You get a libmy_module.so
file after the compile is completed. Make a note of the absolute path of this file.
-
Go to the samples folder by running the following command:
cd /usr/share/azureiotgatewaysdk/samples
-
Open the configuration file by running the following command:
vi ble_gateway.json
-
Add a module by inserting the following code to the
modules
section.{ "name": "MyModule", "loader": { "name": "native", "entrypoint":{ "module.path": "[Your libmy_module.so path]" } }, "args": null },
-
Replace
[Your libmy_module.so path]
in the code with the absolute path of the libmy_module.so` file. -
Replace the code in the
links
section with the following one:{ "source": "SensorTag", "sink": "MyModule" }, { "source": "MyModule", "sink": "mapping" }
-
Press
ESC
, and then type:wq
to save the file.
-
Power on the SensorTag.
-
Set the SSL_CERT_FILE environment variable by running the following command:
export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
-
Run the sample application with the added module by running the following command:
./ble_gateway ble_gateway.json
You've successfully use the IoT gateway to convert the message from SensorTag into the .json format.