Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Latest commit

 

History

History
144 lines (108 loc) · 4.48 KB

iot-hub-gateway-kit-c-use-iot-gateway-for-data-conversion.md

File metadata and controls

144 lines (108 loc) · 4.48 KB
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

Use IoT gateway for sensor data transformation with Azure IoT Edge

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.

What you learn

You learn how to create a module to convert messages from the SensorTag into a different format.

What you do

  • 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.

What you need

Create a module

  1. On the host computer, run the SSH client and connect to the IoT gateway.

  2. 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}

Compile the module

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.

Add the module to the BLE sample application

  1. Go to the samples folder by running the following command:

    cd /usr/share/azureiotgatewaysdk/samples
  2. Open the configuration file by running the following command:

    vi ble_gateway.json
  3. 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
     },
  4. Replace [Your libmy_module.so path] in the code with the absolute path of the libmy_module.so` file.

  5. Replace the code in the links section with the following one:

    {
        "source": "SensorTag",
        "sink": "MyModule"
    },
    {
        "source": "MyModule",
        "sink": "mapping"
    }
  6. Press ESC, and then type :wq to save the file.

Run the sample application

  1. Power on the SensorTag.

  2. Set the SSL_CERT_FILE environment variable by running the following command:

    export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
  3. Run the sample application with the added module by running the following command:

    ./ble_gateway ble_gateway.json

Next steps

You've successfully use the IoT gateway to convert the message from SensorTag into the .json format.