The Microsoft Azure IoT device libraries for C contain code that facilitates building devices and applications that connect to and are managed by Azure IoT Hub services.
The device library consists of a set of reusable components with abstract interfaces that enable pluggability between stock and custom modules.
To meet the wide range of device requirements in the Internet of Things space, the C libraries are provided in source code form to support multiple form factors, operating systems, tools sets, protocols and communications patterns widely in use today.
- Sends event data to Azure IoT based services.
- Maps server commands to device functions.
- Buffers data when the network connection is down.
- Batches messages to improve communication efficiency.
- Supports pluggable transport protocols. HTTPS, AMQP and MQTT are the protocols currently available now.
- Supports pluggable serialization methods. JSON serialization is available now.
The library code:
- Is written in ANSI C (C99) to maximize code portability and broad platform compatibility.
- Avoids compiler extensions.
- Exposes a platform abstraction layer to isolate OS dependencies (threading and mutual exclusion mechanisms, communications protocol e.g. HTTP). Refer to porting guide for more information.
Azure IoT device SDK for C can be used with a broad range of OS platforms and devices. For a list of tested configurations click here.
For information on how to use this library refer to the documents below:
- Prepare your development environment to use the Azure IoT device SDK for C
- Setup IoT Hub
- Provision and manage devices
- Azure IoT device SDK for C tutorial
- Setup a Protocol Gateway - (i.e. MQTT)
- How to port the C libraries to other OS platforms
- Cross compilation example
- C API reference
For guides on how to run the sample applications on supported platforms, check out in this folder.
All C specific resources are located in the azure-iot-sdks\c folder. A description of the key directories follows:
These are git submodules that contain code, such as adapters and protocol implementations, shared with other projects. Note that some of them contain nested submodules.
This folder contains client components that enable access to Azure blob storage.
Contains certificates needed to communicate with Azure IoT Hub.
This folder contains application development guides and device setup instructions.
This folder contains platform-specific build scripts for the client libraries and dependent components.
Contains Azure IoT Hub client components that provide the raw messaging capabilities of the library. Refer to the API documentation and samples for information on how to use it.
- build: has one subfolder for each platform (e.g. Windows, Linux, Mbed). Contains makefiles, batch files, and solutions that are used to generate the library binaries.
- devdoc: contains requirements, designs notes, manuals.
- inc: public include files.
- src: client libraries source files.
- samples: contains the send event and receive message samples (with ports for the supported platforms).
- tests: unit and end-to-end tests for source code.
Contains libraries that provide modeling and JSON serialization capabilities on top of the raw messaging library. These libraries facilitate uploading structured data and command and control for use with Azure IoT services. Refer to the API documentation and samples for information on how to use it.
- build: has one subfolder for each platform (e.g. Windows, Linux, Mbed). Contains makefiles, batch files, and solutions that are used to generate the library binaries.
- devdoc: contains requirements, designs notes, manuals.
- inc: public include files.
- src: client libraries source files.
- samples: contains the send event and receive message samples (with ports for the supported platforms).
- tests: unit tests and end-to-end tests for source code.
Contains libraries that enable interactions with the IoT Hub service to perform operations such as sending messages to devices and managing the device identity registry.
Contains tools that are currently used in testing the client libraries: Mocking Framework (micromock), Generic Test Runner (CTest), Unit Test Project Template, etc.
Miscellaneous tools: compilembed, mbed_build, traceabilitytool (checks spec requirements vs code implementation).
- Clone azure-iot-sdks by:
git clone --recursive https://github.com/Azure/azure-iot-sdks.git
- Create a folder build under azure-iot-sdks
- Switch to the build folder and run cmake ..
Optionally, you may choose to install azure-iot-sdks on your machine:
-
Switch to the cmake folder and run
cmake -Duse_installed_dependencies=ON ../
cmake --build . --target install
or install using the follow commands for each platform:
On Linux:
sudo make install
On Windows:
msbuild /m INSTALL.vcxproj
-
Use it in your project (if installed)
find_package(azure_iot_sdks REQUIRED CONFIG) target_link_library(yourlib iothub_client iothub_service_client serializer)
This requires that azure-c-shared-utility, azure-uamqp-c, and azure-umqtt-c are installed (through CMake) on your machine.
If running tests, this requires that umock-c, azure-ctest, and azure-c-testrunnerswitcher are installed (through CMake) on your machine.