The Azure IoT Field Gateway SDK is a set of libraries that allow you to build a device that acts as a proxy between an individual IoT device and Azure IoT Hub.
Individual IoT devices will connect to the Gateway via some transport layer (BLE, NFC, etc) and the Gateway will forward the device data to IoT Hub. The Gateway will usually aggregate many messages into a single message or convert it to a data protocol (MQTT, AMQP, etc) that IoT Hub understands.
Here’s how to get it the Field Gateway running on a Raspberry Pi 3.
I’m using Raspbian Jessie full desktop image.
This will be used to write Raspbian to the MicroSD card
Open Win32DiskImager. Find the yyyy-mm-dd-raspbian-jessie.img file. Select your USB drive. Click Write. This took about 5 minutes on my machine.
Plug in HDMI monitor, keyboard, mouse and Ethernet cable (you can also use Wifi instead)
TightVNC allows you to remote desktop into the Raspberry Pi from your Windows desktop. This step is optional. You could also just use the monitor, mouse and keyboard that is connected to the Pi, but that gets old quick. There are other options here, but I’ve found TightVNC to be the most reliable when you just need to connect to the Pi from the same wireless network. If the Pi is on a difference network, then use Weaved.
All your remote options are located here: https://www.raspberrypi.org/documentation/remote-access/. Feel free to use one that best suits your needs. SSH with Putty is a good option if you don’t need to access the desktop.
If you are using TightVNC, on the Pi, open the web browser and go to http://bit.ly/azuregatewaypi – that will redirect you to this page on your Pi, so you can easily copy and paste the following commands.
If you are using SSH, then just execute the commands below in your SSH window.
You can clone into any directly you want. I usually put everything in a /code folder.
This is the branch that contains a fix that allows the Gateway to be built on the Pi
I like to execute this command after I checkout a branch to be sure I have the latest submodule bits that correspond to my current branch.
Change to the /tools directory and excute ./build.sh
This will take a while. Come back in 30 mins or so.
You will likely see these test failures, which are known issues reported here on GitHub. The e2e tests fail because we didn’t setup the IoT Hub connection. That’ll be the topic of a different blog post.
The following tests FAILED:
27 - constbuffer_unittests (Failed)
34 - httpapiex_unittests (Failed)
41 - sastoken_unittests (Failed)
63 - mqtt_client_unittests (Failed)
77 - iothubclient_http_e2etests (Failed)
79 - iothubclient_mqtt_e2etests (Failed)
81 - iothubclient_amqp_e2etests (Failed)
109 - gw_e2etests (Failed)
Errors while running CTest
From the root of the repo run this command to copy the sample JSON settings file to the build output folder.
Change to the /build folder
Run the following command to start the sample.
You should now see this output.
This sample writes an entry to the /build/log.txt file. If you open that file you will see the entries. From the /build folder just enter “vi log.txt” to view the file.
You might see this error when you stop the gateway – it appears that you can ignore it because it is still writing data to the log file. I have reported the issue on GitHub, which was resolved 8/13/2016.
Error: Time:Fri Aug 5 19:41:42 2016 File:/home/pi/code/azure-iot-gateway-sdk/deps/azure-c-shared-utility/src/consolelogger.c Func:consolelogger_log Line:31 byte array is not a gateway message serialization
- Azure IoT Field Gateway SDK: https://github.com/Azure/azure-iot-gateway-sdk
- Good Design Overview: https://github.com/Azure/azure-iot-gateway-sdk/blob/master/doc/getting_started.md