如何裁剪azure_iot_sdk_c并提取iothub_ll_c2d_sample适配嵌入式Linux
提取Azure IoT C SDK中iothub_ll_c2d_sample移植所需文件
一、核心示例源码
- 必须保留的示例文件:
iothub_ll_c2d_sample.c(路径:azure-iot-sdk-c/iothub_client/samples/iothub_ll_c2d_sample/)
二、IoT Hub低层级客户端核心依赖
基础客户端模块
iothub_client_ll.c、iothub_client_ll.hiothub_client_core_ll.c、iothub_client_core_ll.hiothub_client_transport.c、iothub_client_transport.hiothub_message.c、iothub_message.hiothub_client_options.c、iothub_client_options.hiothub_client_version.h
传输协议依赖(以MQTT为例,C2D场景首选)
如果使用MQTT协议,需保留:
iothubtransport_mqtt.c、iothubtransport_mqtt.hiothubtransport_mqtt_common.c、iothubtransport_mqtt_common.h
三、嵌入式Linux平台适配层(PAL)
系统抽象层核心文件
pal_linux.c、pal_linux.h(路径:azure-iot-sdk-c/c-utility/pal/linux/)pal.c、pal.h(通用PAL接口)pal_socket.c、pal_socket.hpal_thread.c、pal_thread.hpal_time.c、pal_time.hpal_crypto.c、pal_crypto.h(TLS加密必备)
通用工具库依赖(azure_c_shared_utility)
vector.c、vector.hlist.c、list.hstrings.c、strings.hlogging.c、logging.hmutex.c、mutex.hthreadapi.c、threadapi.huniqueid.c、uniqueid.htlsio_openssl.c、tlsio_openssl.h(嵌入式Linux常用TLS实现)
四、编译与链接要点
- 编译宏定义:添加
-D_LINUX、-DUSE_OPENSSL(使用OpenSSL时) - 链接依赖库:
-lpthread -lssl -lcrypto - 嵌入式环境需使用对应交叉编译工具链,确保OpenSSL等依赖已完成交叉编译
内容的提问来源于stack exchange,提问作者coalboss
相关产品推荐
相关产品推荐

