azure-iot-sdk-c

授权协议 View license
开发语言 C/C++
所属分类 其他开源、 嵌入式操作系统
软件类型 开源软件
地区 不详
投 递 者 左丘烨烁
操作系统 嵌入式
开源组织
适用人群 未知
 软件概览

Azure IoT C SDKs and Libraries

The Azure IOT Hub Device SDK allows applications written in C99 or later or C++ to communicate easily with Azure IoT Hub, Azure IoT Central and toAzure IoT Device Provisioning. This repo includes the source code for the libraries, setup instructions, and samples demonstrating use scenarios.

For constained devices - where memory is measured in kilobytes and not megabytes - there are even lighter weight SDK options available. See Other Azure IoT SDKs for more.

Table of Contents

Critical Upcoming Change Notice

All Azure IoT SDK users are advised to be aware of upcoming TLS certificate changes for Azure IoT Hub and Device Provisioning Servicethat will impact the SDK's ability to connect to these services. In October 2022, both services will migrate from the currentBaltimore CyberTrust CA Root to theDigiCert Global G2 CA root. There will be atransition period beforehand where your IoT devices must have both the Baltimore and Digicert public certificateswhich may be hardcoded in their application or flashed onto your WiFi module in order to prevent connectivity issues.

Devices with only the Baltimore public certificate will lose the ability to connect to Azure IoT Hub and Device Provisioning Service in October 2022.

To prepare for this change, make sure your device's TLS stack has both of these public root of trust certificates configured.

For a more in depth explanation as to why the IoT services are doing this, please seethis article.

Getting the SDK

The simplest way to get started with the Azure IoT SDKs on supported platforms is to use the following packages and libraries:

For other platforms - including Linux - you need to clone and build the SDK directly. You may also build it directly for the platforms above. Instructions can be found here.

Samples

There are many samples available for the SDK. More information can be found here.

SDK API Reference Documentation

The API reference documentation for the C SDKs can be found here.

Other Azure IoT SDKs

To find Azure IoT SDKs in other languages, please refer to the guidance here.

Note on constrained devices: The Embedded C SDK is an alternative for constrained devices which enables the BYO (bring your own) network approach: IoT developers have the freedom of choice to bring an MQTT client, TLS and Socket of their choice to create a device solution. Find more information about the Embedded C SDK here.

Developing Azure IoT Applications

To learn more about building Azure IoT Applications, you can visit the Azure IoT Dev Center.

Key Features

Device Client SDK

IoT Hub supports multiple protocols for the device to connect with : MQTT, AMQP, and HTTPS. MQTT and AMQP can optionally run over WebSockets. The Device Client SDK allows the protocol to be chosen at connection creation time.

If you're not sure which protocol to use, you should use MQTT or MQTT-WS. MQTT requires considerably fewer resources than AMQP and supports considerably more IoT Hub functionality than HTTPS. Neither AMQP nor HTTPS are guaranteed to have Device Client SDK implementations for new features going forward, such as Azure IoT Plug and Play.

✔️ feature available ✖️ feature planned but not supported no support planned

Features mqtt mqtt-ws amqp amqp-ws https Description
Authentication ✔️ ✔️ * ✔️ ✔️ * ✔️ * Connect your device to IoT Hub securely with supported authentication, including private key, SASToken, X-509 Self Signed and Certificate Authority (CA) Signed. *IoT Hub only supports X-509 CA Signed over AMQP and MQTT at the moment.
Send Device-to-Cloud Message ✔️ * ✔️ * ✔️ * ✔️ * ✔️ * Send device-to-cloud messages (max 256KB) to IoT Hub with the option to add custom properties. IoT Hub only supports batch send over AMQP and HTTPS only at the moment. This SDK supports batch send over HTTP. * Batch send over AMQP and AMQP-WS, and add system properties on D2C messages are in progress.
Receive Cloud-to-Device Messages ✔️ * ✔️ * ✔️ ✔️ ✔️ Receive cloud-to-device messages and read associated custom and system properties from IoT Hub, with the option to complete/reject/abandon C2D messages. *IoT Hub supports the option to complete/reject/abandon C2D messages over HTTPS and AMQP only at the moment.
Device Twins ✔️ * ✔️ * ✔️ * ✔️ * IoT Hub persists a device twin for each device that you connect to IoT Hub. The device can perform operations like get twin tags, subscribe to desired properties. *Send reported properties version and desired properties version are in progress.
Direct Methods ✔️ ✔️ ✔️ ✔️ IoT Hub gives you the ability to invoke direct methods on devices from the cloud. The SDK supports handler for method specific and generic operation.
Upload File to Blob ✔️ A device can initiate a file upload and notifies IoT Hub when the upload is complete. File upload requires HTTPS connection, but can be initiated from client using any protocol for other operations.
Connection Status and Error reporting ✔️ * ✔️ * ✔️ * ✔️ * ✖️ Error reporting for IoT Hub supported error code. *This SDK supports error reporting on authentication and Device Not Found.
Retry policies ✔️ * ✔️ * ✔️ * ✔️ * ✖️ Retry policy for unsuccessful device-to-cloud messages have two options: no try, exponential backoff with jitter (default). *Custom retry policy is in progress.
Devices multiplexing over single connection ✔️ ✔️ ✔️ There are more limitations to multiplexing than captured in this table. See this document for more information.
Connection Pooling - Specifying number of connections ✖️ ✖️ ✖️
Azure IoT Plug and Play Support ✔️ ✔️ Ability to build Azure IoT Plug and Play devices.

This SDK also contains options you can set and platform specific features. You can find detail list in this document.

Provisioning Client SDK

This repository contains provisioning client SDK for the Device Provisioning Service.

✔️ feature available ✖️ feature planned but not supported no support planned

Features mqtt mqtt-ws amqp amqp-ws https Description
TPM Individual Enrollment ✔️ ✔️ ✔️ This SDK supports connecting your device to the Device Provisioning Service via individual enrollment using Trusted Platform Module. This quickstart reviews how to create a simulated device for individual enrollment with TPM. TPM over MQTT is currently not supported by the Device Provisioning Service.
X.509 Individual Enrollment ✔️ ✔️ ✔️ ✔️ ✔️ This SDK supports connecting your device to the Device Provisioning Service via individual enrollment using X.509 leaf certificate. This quickstart reviews how to create a simulated device for individual enrollment with X.509.
X.509 Enrollment Group ✔️ ✔️ ✔️ ✔️ ✔️ This SDK supports connecting your device to the Device Provisioning Service via enrollment group using X.509 root certificate.

OS Platforms and Hardware Compatibility

The IoT Hub device SDK for C can be used with a broad range of OS platforms and devices.

The minimum requirements are for the device platform to support the following:

  • Support Azure IoT TLS over TCP/IP Requirements: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-tls-support
  • Support SHA-256 (optional): necessary to generate the secure token for authenticating the device with the service. Different authentication methods are available and not all require SHA-256.
  • Have a Real Time Clock or implement code to connect to an NTP server: necessary for both establishing the TLS connection and generating the secure token for authentication.
  • Having at least 64KB of RAM: the memory footprint of the SDK depends on the SDK and protocol used as well as the platform targeted. The smallest footprint is achieved targeting microcontrollers.

Platform support details can be found in this document.You can find an exhaustive list of the OS platforms the various SDKs have been tested against in the Azure Certified for IoT device catalog. Note that you might still be able to use the SDKs on OS and hardware platforms that are not listed on this page: all the SDKs are open sourced and designed to be portable. If you have suggestions, feedback or issues to report, refer to the Contribution and Support sections below.

Porting the Azure IoT Device Client SDK for C to New Devices

The C SDKs and Libraries:

  • Are written in ANSI C (C99) and avoids compiler extensions to maximize code portability and broad platform compatibility.
  • Expose a platform abstraction layer to isolate OS dependencies (threading and mutual exclusion mechanisms, communications protocol e.g. HTTP). Refer to our porting guide for more information about our abstraction layer.

In the repository you will find instructions and build tools to compile and run the device client SDK for C on Linux, Windows and microcontroller platforms (refer to the links above for more information on compiling the device client for C).

If you are considering porting the device client SDK for C to a new platform, check out the porting guide document.

Contribution, Feedback and Issues

If you encounter any bugs, have suggestions for new features or if you would like to become an active contributor to this project please follow the instructions provided in the contribution guidelines.

Support

  • Have a feature request for SDKs? Please post it on User Voice to help us prioritize.
  • Have a technical question? Ask on Stack Overflow with tag "azure-iot-hub".
  • Need Support? Every customer with an active Azure subscription has access to support with guaranteed response time. Consider submitting a ticket and get assistance from Microsoft support team
  • Found a bug? Please help us fix it by thoroughly documenting it and filing an issue on our GitHub issues.

Read More

SDK Folder Structure

/c-utility, /deps, /umqtt, /uamqp -

These are git submodules that contain code, such as adapters and protocol implementations, shared with other projects.

/build, /build_all

Build and checkin gate related folders.

/certs

Contains certificates needed to communicate with Azure IoT Hub.

/doc

This folder contains application development guides and device setup instructions.

/iothub_client

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 simple samples.
  • tests: unit and end-to-end tests for source code.

/provisioning_client

This folder contains client library for device provisioning client.

/samples

Contains samples demonstrating more complex E2E scenarios using SDK.

/testtools

Contains tools that are used in testing the libraries.

/tools

Miscellaneous tools.

Deprecated Folders

The following folders are deprecated.

/iothub_service_client

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.

/provisioning_service_client

Contains libraries that enable interactions with the Device Proviosining service to perform operations such as setting policy around the enrollments.

/serializer

Contains libraries that provide modeling and JSON serialization capabilities on top of the raw messaging library.

Releases

The C SDK offers releases for new features, critical bug fixes, and Long Term Support (LTS). General bug fixes will not receive a separate release, but are instead contained within the LTS release. Versioning follows semantic versioning, x.y.z. or major.minor.patch. Any time the version is updated, it will be tagged x.y.z.

New Features and Critical Bug Fixes

New features and critical bug fixes (including security updates) will be released on the main branch. These releases will be tagged using the date formatted yyyy-mm-dd. A feature release will bump the minor version and reset the patch version to 0. A critical bug fix will bump the patch version only.

Long Term Support (LTS)

New LTS releases branch off of main every six months and will be tagged LTS_<mm_yyyy>_Ref01. A new LTS release will inherit the version from the main branch at the time of the release. LTS branches are named lts_mm_yyyy for the month and year the branch was created.

An updated LTS release will occur when a critical bug fix (including security updates) is ported from the main branch. These updated releases will be tagged in the same manner except for a bumped Ref##, e.g. LTS_<mm_yyyy>_Ref02. The patch version will also be bumped. No new features and no general bug fixes will be ported to an LTS update.

LTS Schedule

Below is a table showing the mapping of the LTS branches to the packages released.

Package GitHub Branch LTS Tag LTS Start Date Maintenance End Date
vcpkg: 2021-09-09 lts_07_2021 LTS_07_2021_Ref01 2021-08-11 2022-08-11
vcpkg: (unreleased) lts_01_2021 LTS_01_2021_Ref01 2021-01-21 2022-01-21

Release Example

Below is a hypothetical example of versioning and tagging for the C SDK. minor versions are distinguished by color.

Release Node Drawing

  • The main branch is at version 1.8.2.
  • February 23, 2020: A new feature is released on main. The version bumps to 1.9.0, is tagged 1.9.0, and the release is tagged 2020-02-23.
  • July 9, 2020: A new LTS release occurs. A new release branch lts_07_2020 is created, the version remains 1.9.0, and the LTS release is tagged LTS_07_2020_Ref01. The main branch bumps to 1.10.0 and is tagged 1.10.0.
  • August 2, 2020: A new feature is released on main: The main branch has already been bumped for an upcoming release so the version is unchanged. The release is tagged 2020-08-02.
  • September 28, 2020: A critical bug fix is released: The version on main bumps to 1.10.1, is tagged 1.10.1, and the release is tagged 2020-09-28. The critical bug fix is ported to the lts branch lts_07_2020 (and any other existing LTS branch). The lts branch version bumps to 1.9.1, is tagged 1.9.1, and the updated LTS release is tagged LTS_07_2020_Ref02. Any submodules that were part of the critical bug fix will be tagged with LTS_07_2020_Ref02.
  • December 14, 2020: A new feature is released on main. The version bumps to 1.11.0, is tagged 1.11.0, and the release is tagged 2020-12-14.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Microsoft collects performance and usage information which may be used to provide and improve Microsoft products and services and enhance your experience. To learn more, review the privacy statement.

  • IoT 即插即用简化了 IoT 的使用,使你无需了解底层设备实现,就能与某个设备的功能交互。IoT Plug and Play simplifies IoT by enabling you to interact with a device's capabilities without knowledge of the underlying device implementation. 本快速入门

  • https://docs.microsoft.com/zh-cn/azure/iot-hub/iot-hub-java-java-getstarted 在IDEA中执行上述的代码,会出现下面的报错信息: Exception in thread "main" javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorEx

  • 微软云当前势头越来越强,此文简单写下之前的经验。 1. 注册   1)注册地址 https://portal.azure.com/   https://azure.microsoft.com/zh-cn/free/ 以上两个为国际的,需要visa/master信用卡注册才能用 以下是国内的,提供1元免费试用1个月服务 https://www.azure.cn/zh-cn/    2)使用微软账户登

  • 10分钟- 使用Python 示例代码和SDK向IoT Hub 发送遥测消息 本文主要有如下内容:了解C2D/D2C消息; 了解IoT Hub中Device的概念 了解并下载Device SDK 使用Device SDK 向云发送遥测消息(模拟温湿度) 查看发送的数据 视频讲解: 请观看B站视频:https://www.bilibili.com/video/av90223553/ 图文步骤: 本文

  • 面向 Azure 专业人员的阿里云 本文讨论 Azure 和 Alibaba Cloud 在其各自的云环境中提供的大数据服务的主要区别和相似之处,本文主要讨论以下服务类型情况和它涵盖以产品: 1. 数据计算   2. 数据业务流程     以下表格列出了 Azure 大数据产品与 Alibaba Cloud 大数据产品的对比。 特性 Azure Alibaba Cloud 数据计算 Azure H

 相关资料
  • Azure IoT Edge 主要将基于云的分析和定制的业务逻辑转移到边缘设备,使企业能够专注于洞察商业机会而非数据管理。 微软表示,这些设备现在将能够立即采取实时数据行动。 借助开源的 Azure IoT Edge,开发人员可以更灵活地控制自己的边缘解决方案,以及运行时或调试问题。 为了解决 Azure IoT Edge 大规模部署的安全问题,Azure IoT Edge 深入集成了设备调配服务

  • AWS IoT Device SDK for Embedded C Table of Contents Overview License Features coreMQTT coreHTTP coreJSON corePKCS11 AWS IoT Device Shadow AWS IoT Jobs AWS IoT Device Defender AWS IoT Over-the-air Upda

  • 已经部署了一个测试设备,该设备发送到Azure IOT,然后向Dynamics 365报警。 我试图使用https://github.com/azure-samples/web-apps-node-iot-hub-data-visualization查看web应用程序中的数据 设置azure.iot.iothub.connectionstring=sb://iothub-ns-**********

  • Do IOT hub保留遥测数据。如果是,我们可以在Azure Portal中访问多长时间和如何访问这些数据?我们能把IOT hub的遥测数据导出到excel吗?

  • Windows Azure是微软基于云计算的操作系统,和Azure Services Platform一样,是微软“软件和服务”技术的名称。Windows Azure的主要目标是为开发者提供一个平台,帮助开发可运行在云服务器、数据中心、Web和PC上的应用程序。云计算的开发者能使用微软全球数据中心的储存、计算能力和网络基础服务。Azure服务平台包括了以下主要组件:Windows Azure;Mi

  • 我想知道? 任何链接和参考将是可观的。