├── .clang-format ├── .gitignore ├── CMakeLists.txt ├── CMakeSettings.json ├── LICENSE ├── Makefile ├── README.md ├── certs └── README.md ├── cmake_build.sh ├── device_info.json ├── docs ├── C-SDK_API及可变参数说明.md ├── C-SDK_Build编译环境及配置选项说明.md ├── C-SDK_Porting跨平台移植概述.md ├── Device_Auth设备接入认证.md ├── Device_Type设备类型说明.md ├── FAQ.md ├── FreeRTOS+lwIP平台移植说明.md ├── IoT_Explorer开发平台快速入门.md ├── MCU+腾讯云定制AT模组.md ├── MCU+通用TCP_AT模组移植(FreeRTOS).md ├── MCU+通用TCP_AT模组移植(nonOS).md ├── mqtt_sample_快速入门.md ├── 二进制数据上报.md ├── 动态注册使用说明.md ├── 数据模板开发 │ ├── 数据模板代码生成.md │ ├── 数据模板协议.md │ └── 数据模板应用开发.md ├── 文件管理协议设计.md ├── 物模型数据模板动态解析体验例子说明.md ├── 网关子设备场景示例说明.md ├── 网关设备小程序自动智能本地联动.md ├── 网关设备快速入门.md ├── 腾讯连连小程序 WIFI 配网.md ├── 腾讯连连蓝牙辅助配网协议V1.1.pdf ├── 设备固件升级.md ├── 设备基础信息上报.md ├── 设备接入QQ音乐.md ├── 设备接入酷狗音乐.md └── 资源管理协议设计.md ├── external_libs ├── cJSON │ ├── CHANGELOG.md │ ├── CMakeLists.txt │ ├── CONTRIBUTORS.md │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── appveyor.yml │ ├── cJSON.c │ ├── cJSON.h │ ├── cJSON_Utils.c │ ├── cJSON_Utils.h │ ├── test.c │ └── valgrind.supp └── mbedtls │ ├── CMakeLists.txt │ ├── Makefile │ ├── configs │ ├── README.txt │ ├── config-ccm-psk-tls1_2.h │ ├── config-mini-tls1_1.h │ ├── config-no-entropy.h │ ├── config-picocoin.h │ ├── config-suite-b.h │ └── config-thread.h │ ├── include │ └── mbedtls │ │ ├── aes.h │ │ ├── aesni.h │ │ ├── arc4.h │ │ ├── asn1.h │ │ ├── asn1write.h │ │ ├── base64.h │ │ ├── bignum.h │ │ ├── blowfish.h │ │ ├── bn_mul.h │ │ ├── camellia.h │ │ ├── ccm.h │ │ ├── certs.h │ │ ├── check_config.h │ │ ├── cipher.h │ │ ├── cipher_internal.h │ │ ├── cmac.h │ │ ├── compat-1.3.h │ │ ├── config.h │ │ ├── ctr_drbg.h │ │ ├── debug.h │ │ ├── des.h │ │ ├── dhm.h │ │ ├── ecdh.h │ │ ├── ecdsa.h │ │ ├── ecjpake.h │ │ ├── ecp.h │ │ ├── entropy.h │ │ ├── entropy_poll.h │ │ ├── error.h │ │ ├── gcm.h │ │ ├── havege.h │ │ ├── hmac_drbg.h │ │ ├── md.h │ │ ├── md2.h │ │ ├── md4.h │ │ ├── md5.h │ │ ├── md_internal.h │ │ ├── memory_buffer_alloc.h │ │ ├── net.h │ │ ├── net_sockets.h │ │ ├── oid.h │ │ ├── padlock.h │ │ ├── pem.h │ │ ├── pk.h │ │ ├── pk_internal.h │ │ ├── pkcs11.h │ │ ├── pkcs12.h │ │ ├── pkcs5.h │ │ ├── platform.h │ │ ├── platform_time.h │ │ ├── ripemd160.h │ │ ├── rsa.h │ │ ├── sha1.h │ │ ├── sha256.h │ │ ├── sha512.h │ │ ├── ssl.h │ │ ├── ssl_cache.h │ │ ├── ssl_ciphersuites.h │ │ ├── ssl_cookie.h │ │ ├── ssl_internal.h │ │ ├── ssl_ticket.h │ │ ├── threading.h │ │ ├── timing.h │ │ ├── version.h │ │ ├── x509.h │ │ ├── x509_crl.h │ │ ├── x509_crt.h │ │ ├── x509_csr.h │ │ └── xtea.h │ └── library │ ├── Makefile │ ├── aes.c │ ├── aesni.c │ ├── arc4.c │ ├── asn1parse.c │ ├── asn1write.c │ ├── base64.c │ ├── bignum.c │ ├── blowfish.c │ ├── camellia.c │ ├── ccm.c │ ├── certs.c │ ├── cipher.c │ ├── cipher_wrap.c │ ├── cmac.c │ ├── ctr_drbg.c │ ├── debug.c │ ├── des.c │ ├── dhm.c │ ├── ecdh.c │ ├── ecdsa.c │ ├── ecjpake.c │ ├── ecp.c │ ├── ecp_curves.c │ ├── entropy.c │ ├── entropy_poll.c │ ├── error.c │ ├── gcm.c │ ├── havege.c │ ├── hmac_drbg.c │ ├── md.c │ ├── md2.c │ ├── md4.c │ ├── md5.c │ ├── md_wrap.c │ ├── memory_buffer_alloc.c │ ├── net_sockets.c │ ├── oid.c │ ├── padlock.c │ ├── pem.c │ ├── pk.c │ ├── pk_wrap.c │ ├── pkcs11.c │ ├── pkcs12.c │ ├── pkcs5.c │ ├── pkparse.c │ ├── pkwrite.c │ ├── platform.c │ ├── ripemd160.c │ ├── rsa.c │ ├── sha1.c │ ├── sha256.c │ ├── sha512.c │ ├── ssl_cache.c │ ├── ssl_ciphersuites.c │ ├── ssl_cli.c │ ├── ssl_cookie.c │ ├── ssl_srv.c │ ├── ssl_ticket.c │ ├── ssl_tls.c │ ├── threading.c │ ├── timing.c │ ├── version.c │ ├── version_features.c │ ├── x509.c │ ├── x509_create.c │ ├── x509_crl.c │ ├── x509_crt.c │ ├── x509_csr.c │ ├── x509write_crt.c │ ├── x509write_csr.c │ └── xtea.c ├── include ├── config.h ├── exports │ ├── qcloud_iot_export_asr.h │ ├── qcloud_iot_export_data_template.h │ ├── qcloud_iot_export_device_bind.h │ ├── qcloud_iot_export_dynreg.h │ ├── qcloud_iot_export_error.h │ ├── qcloud_iot_export_file_manage.h │ ├── qcloud_iot_export_gateway.h │ ├── qcloud_iot_export_kgmusic.h │ ├── qcloud_iot_export_location.h │ ├── qcloud_iot_export_log.h │ ├── qcloud_iot_export_method.h │ ├── qcloud_iot_export_mqtt.h │ ├── qcloud_iot_export_ota.h │ ├── qcloud_iot_export_qqmusic.h │ ├── qcloud_iot_export_resource.h │ └── qcloud_iot_export_system.h ├── gitinfo.h ├── lite-list.h ├── lite-utils.h ├── platform.h ├── qcloud_iot_export.h ├── qcloud_iot_export_variables.h ├── qcloud_iot_import.h └── utils_getopt.h ├── make.settings ├── platform ├── CMakeLists.txt ├── at_device │ └── esp8266 │ │ ├── at_device_esp8266.c │ │ └── at_device_esp8266.h ├── os │ ├── freertos │ │ ├── HAL_AT_UART_freertos.c │ │ ├── HAL_Device_freertos.c │ │ ├── HAL_Music_freertos.c │ │ ├── HAL_OS_freertos.c │ │ ├── HAL_TCP_lwip.c │ │ ├── HAL_Timer_freertos.c │ │ └── HAL_UDP_lwip.c │ ├── linux │ │ ├── HAL_AT_UART_linux.c │ │ ├── HAL_Device_linux.c │ │ ├── HAL_File_linux.c │ │ ├── HAL_Log_linux.c │ │ ├── HAL_Music_Linux.c │ │ ├── HAL_OS_linux.c │ │ ├── HAL_TCP_linux.c │ │ ├── HAL_Timer_linux.c │ │ └── HAL_UDP_linux.c │ ├── nonos │ │ ├── HAL_AT_UART_nonos.c │ │ ├── HAL_Device_nonos.c │ │ ├── HAL_Music_freertos.c │ │ ├── HAL_OS_nonos.c │ │ └── HAL_Timer_nonos.c │ ├── rtthread │ │ ├── HAL_Device_rtthread.c │ │ ├── HAL_Music_freertos.c │ │ ├── HAL_OS_rtthread.c │ │ ├── HAL_TCP_rtthread.c │ │ ├── HAL_TLS_mbedtls_rtthread.c │ │ ├── HAL_Timer_rtthread.c │ │ └── tc_tls_config.h │ └── windows │ │ ├── HAL_AT_UART_win.c │ │ ├── HAL_Device_win.c │ │ ├── HAL_File_win.c │ │ ├── HAL_Log_win.c │ │ ├── HAL_Music_freertos.c │ │ ├── HAL_OS_win.c │ │ ├── HAL_TCP_win.c │ │ ├── HAL_Timer_win.c │ │ └── HAL_UDP_win.c ├── tls │ └── mbedtls │ │ ├── HAL_DTLS_mbedtls.c │ │ └── HAL_TLS_mbedtls.c └── wifi_config_adapter │ ├── HAL_Airkiss.c │ ├── HAL_BTCombo_config.c │ ├── HAL_Simple_config.c │ ├── HAL_Smart_config.c │ ├── HAL_Soft_ap.c │ └── HAL_Wifi_api.c ├── samples ├── CMakeLists.txt ├── Makefile ├── asr │ └── asr_data_template_sample.c ├── data_template │ ├── action_config.c │ ├── data_config.c │ ├── data_template_sample.c │ └── events_config.c ├── dynreg_dev │ └── dynreg_dev_sample.c ├── file_manage │ └── file_mqtt_sample.c ├── gateway │ ├── gateway_sample.c │ └── sub_dev001.c ├── kgmusic │ ├── action_config.c │ ├── data_config.c │ └── kgmusic_data_template_sample.c ├── location │ ├── data_config.c │ └── location_sample.c ├── mqtt │ └── mqtt_sample.c ├── ota │ └── ota_mqtt_sample.c ├── qqmusic │ ├── action_config.c │ ├── data_config.c │ └── qqmusic_data_template.c ├── raw_data │ └── raw_data_sample.c ├── resource │ └── resource_mqtt_sample.c ├── scenarized │ ├── dyn_parse_data_template_sample.c │ ├── gateway_sim_sample.c │ ├── light_data_template_sample.c │ └── subdev_sim_sample.c └── wifi_config │ └── wifi_config_sample.c ├── sdk_src ├── CMakeLists.txt ├── internal_inc │ ├── asr_client.h │ ├── at_client.h │ ├── at_socket_inf.h │ ├── at_uart_hal.h │ ├── at_utils.h │ ├── data_template_action.h │ ├── data_template_client.h │ ├── data_template_client_common.h │ ├── data_template_client_json.h │ ├── data_template_event.h │ ├── file_manage_client.h │ ├── gateway_common.h │ ├── json_parser.h │ ├── log_upload.h │ ├── mqtt_client.h │ ├── mqtt_client_net.h │ ├── network_interface.h │ ├── ota_client.h │ ├── ota_fetch.h │ ├── ota_lib.h │ ├── qcloud_iot_ca.h │ ├── qcloud_iot_common.h │ ├── qcloud_iot_device.h │ ├── qcloud_wifi_config.h │ ├── qcloud_wifi_config_internal.h │ ├── resource_client.h │ ├── resource_lib.h │ ├── resource_upload.h │ ├── service_mqtt.h │ ├── utils_aes.h │ ├── utils_base64.h │ ├── utils_bitmap.h │ ├── utils_hmac.h │ ├── utils_httpc.h │ ├── utils_list.h │ ├── utils_md5.h │ ├── utils_param_check.h │ ├── utils_ringbuff.h │ ├── utils_sha1.h │ ├── utils_timer.h │ ├── utils_url_download.h │ └── utils_url_upload.h ├── network │ ├── at_socket │ │ ├── at_client.c │ │ ├── at_socket_inf.c │ │ ├── at_utils.c │ │ └── network_at_tcp.c │ ├── network_interface.c │ ├── socket │ │ └── network_socket.c │ └── tls │ │ └── network_tls.c ├── protocol │ ├── http │ │ ├── utils_httpc.c │ │ ├── utils_url_download.c │ │ └── utils_url_upload.c │ └── mqtt │ │ ├── mqtt_client.c │ │ ├── mqtt_client_common.c │ │ ├── mqtt_client_connect.c │ │ ├── mqtt_client_net.c │ │ ├── mqtt_client_publish.c │ │ ├── mqtt_client_subscribe.c │ │ ├── mqtt_client_unsubscribe.c │ │ └── mqtt_client_yield.c ├── services │ ├── asr │ │ └── asr_client.c │ ├── data_template │ │ ├── data_template_action.c │ │ ├── data_template_client.c │ │ ├── data_template_client_common.c │ │ ├── data_template_client_json.c │ │ ├── data_template_client_manager.c │ │ └── data_template_event.c │ ├── device_bind │ │ └── device_bind.c │ ├── dynreg │ │ └── dynreg.c │ ├── file_manage │ │ └── file_manage_client.c │ ├── gateway │ │ ├── gateway_api.c │ │ └── gateway_common.c │ ├── kgmusic │ │ └── kgmusic_client.c │ ├── location │ │ └── location.c │ ├── log │ │ ├── log_mqtt.c │ │ └── log_upload.c │ ├── ota │ │ ├── ota_client.c │ │ ├── ota_fetch.c │ │ ├── ota_lib.c │ │ └── ota_mqtt.c │ ├── qqmusic │ │ └── qqmusic_client.c │ ├── resource │ │ ├── resource_client.c │ │ ├── resource_lib.c │ │ ├── resource_mqtt.c │ │ └── resource_upload.c │ ├── service_com │ │ └── service_mqtt.c │ └── system │ │ └── system_mqtt.c ├── utils │ ├── json_parser.c │ ├── json_token.c │ ├── qcloud_iot_ca.c │ ├── qcloud_iot_device.c │ ├── qcloud_iot_log.c │ ├── string_utils.c │ ├── utils_aes.c │ ├── utils_base64.c │ ├── utils_bitmap.c │ ├── utils_getopt.c │ ├── utils_hmac.c │ ├── utils_list.c │ ├── utils_md5.c │ ├── utils_ringbuff.c │ ├── utils_sha1.c │ └── utils_timer.c └── wifi_config │ ├── qcloud_wifi_config.c │ ├── qcloud_wifi_config_comm_service.c │ ├── qcloud_wifi_config_device_bind.c │ ├── qcloud_wifi_config_error_handle.c │ └── qcloud_wifi_config_log_handle.c └── tools ├── build_scripts ├── function_rename.sh ├── internal_make_funcs.mk ├── parse_make_settings.mk ├── rules-tests.mk ├── rules.mk ├── stats_static_lib.sh ├── update_gtest.sh └── update_mbedtls.sh ├── cmake_scripts ├── config.h.in └── convert.sh ├── codegen.py ├── example_config.json ├── run-clang-tidy.py └── test_file └── test.wav /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Google 2 | BreakBeforeBraces: Linux 3 | AlignConsecutiveDeclarations: true 4 | AlignConsecutiveMacros: true 5 | AlignConsecutiveAssignments: true 6 | AllowShortFunctionsOnASingleLine: Inline 7 | AllowShortIfStatementsOnASingleLine: false 8 | SortIncludes: false 9 | IndentWidth: 4 10 | ColumnLimit: 120 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | *.o 3 | *.a 4 | /*.cproject 5 | /*.autotools 6 | /.project 7 | /output 8 | /build 9 | /sdk-tests/unit_test/unit_test.BASE 10 | /sdk-tests/unit_test/unit_test.LOCAL 11 | /sdk-tests/unit_test/unit_test.REMOTE 12 | .DS_Store 13 | *.DS_Store 14 | *.crt 15 | *.key 16 | sdk-tests/certs/unittest_private.key 17 | sdk-tests/certs/unittest_private.key 18 | .vscode/settings.json 19 | .vs/ 20 | /mplayer -------------------------------------------------------------------------------- /CMakeSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "x86-Debug", 5 | "generator": "Ninja", 6 | "configurationType": "Debug", 7 | "inheritEnvironments": [ 8 | "msvc_x86" 9 | ], 10 | "buildRoot": "${projectDir}\\build\\${name}", 11 | "installRoot": "${projectDir}\\build\\install\\${name}", 12 | "cmakeCommandArgs": "", 13 | "buildCommandArgs": "-v", 14 | "ctestCommandArgs": "" 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Tencent is pleased to support the open source community by making IoT Hub available. 2 | 3 | Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | 5 | If you have downloaded a copy of the IoT Hub binary from Tencent, please note that the IoT Hub binary is licensed under the MIT License. 6 | 7 | If you have downloaded a copy of the IoT Hub source code from Tencent, please note that IoT Hub source code is licensed under the MIT License, 8 | 9 | except for the third-party components listed below which are subject to different license terms. Your integration of IoT Hub into your own projects may require compliance with the MIT License, 10 | 11 | as well as the other licenses applicable to the third-party components included within IoT Hub. 12 | 13 | A copy of the MIT License is included in this file. 14 | 15 | Open Source Software Licensed under the MIT License: The below software in this distribution may have been modified by Tencent (“Tencent Modifications”). All Tencent Modifications are Copyright (C) 2016 THL A29 Limited. 16 | -------------------------------------------------------------------- 17 | 1. cpp-feather-ini-parser 1.42 18 | Copyright (c) 2014 Turbine1991 19 | 20 | 2. Dirent 1.22 21 | Copyright (c) 2015 Toni Rönkkö 22 | 23 | 24 | Terms of the MIT License: 25 | -------------------------------------------------------------------- 26 | 27 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 28 | 29 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 腾讯云物联网开发平台设备端 C-SDK 2 | 腾讯云物联网开发平台(IoT Explorer)设备端 C-SDK ,配合平台对设备数据模板化的定义,实现和云端基于数据模板协议的数据交互框架,开发者基于IoT_Explorer C-SDK数据模板框架,通过脚本自动生成模板代码,快速实现设备和平台、设备和应用之间的数据交互。 3 | 4 | ## IoT_Explorer C-SDK 架构 5 | 6 | #### 架构图 7 | 8 | ![framework](https://main.qcloudimg.com/raw/583a783ca9189bd3beb9df0991dc0bec.jpg) 9 | 10 | #### 架构说明 11 | 12 | SDK分四层设计,从上至下分别为平台服务层、核心协议层、网络层、硬件抽象层。 13 | 14 | - 服务层 15 | 在网络协议层之上,实现了包括设备接入鉴权,设备影子,数据模板,网关,动态注册,日志上报和OTA等功能,并提供相关API接口给用户使用,关于服务层API说明,请参考doc目录文档[C-SDK_API及可变参数说明](https://github.com/tencentyun/qcloud-iot-explorer-sdk-embedded-c/blob/master/docs/C-SDK_API%E5%8F%8A%E5%8F%AF%E5%8F%98%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E.md) 16 | 17 | - 协议层 18 | 设备端和IoT平台交互的网络协议包括MQTT/COAP/HTTP 19 | 20 | - 网络层 21 | 实现基于TLS/SSL(TLS/DTLS)方式,Bsd_socket(TCP/UDP)方式和AT_socket方式的网络协议栈,不同服务可根据需要使用不同的协议栈接口函数。 22 | 23 | - 硬件抽象层 24 | 实现对不同硬件平台的底层操作的抽象封装,需要针对具体的软硬件平台开展移植,分为必须实现和可选实现两部分HAL层接口。 25 | 26 | ## SDK 目录结构简介 27 | 28 | #### 目录结构及顶层文件简介 29 | 30 | | 名称 | 说明 | 31 | | ------------------ | ------------------------------------------------------------ | 32 | | CMakeLists.txt | cmake编译描述文件 | 33 | | CMakeSettings.json | visual studio下的cmake配置文件 | 34 | | cmake_build.sh | Linux下使用cmake的编译脚本 | 35 | | make.settings | Linux下使用Makefile直接编译的配置文件 | 36 | | Makefile | Linux下使用Makefile直接编译 | 37 | | device_info.json | 设备信息文件,当DEBUG_DEV_INFO_USED=OFF时,将从该文件解析出设备信息 | 38 | | docs | 文档目录,SDK使用说明文档。 | 39 | | external_libs | 第三方软件包组件,如mbedtls | 40 | | samples | 应用示例 | 41 | | include | 提供给用户使用的外部头文件 | 42 | | platform | 平台相关的源码文件,目前提供了针对不同OS(Linux/Windows/FreeRTOS/nonOS),TLS(mbedtls)以及AT模组下的实现。 | 43 | | sdk_src | SDK核心通信协议及服务代码 | 44 | | tools | SDK配套的编译及代码生成脚本工具 | 45 | 46 | ## SDK 编译方式说明 47 | 48 | C-SDK 支持三种编译方式: 49 | 50 | - cmake 方式 51 | - Makefile 方式 52 | - 代码抽取方式 53 | 54 | 编译方式以及编译配置选项的详细说明请参考docs目录文档[C-SDK_Build编译环境及配置选项说明](https://github.com/tencentyun/qcloud-iot-explorer-sdk-embedded-c/blob/master/docs/C-SDK_Build%E7%BC%96%E8%AF%91%E7%8E%AF%E5%A2%83%E5%8F%8A%E9%85%8D%E7%BD%AE%E9%80%89%E9%A1%B9%E8%AF%B4%E6%98%8E.md) 55 | 56 | ## SDK 快速体验 57 | 58 | 请参考docs目录文档 [IoT_Explorer开发平台快速入门](https://github.com/tencentyun/qcloud-iot-explorer-sdk-embedded-c/blob/master/docs/IoT_Explorer%E5%BC%80%E5%8F%91%E5%B9%B3%E5%8F%B0%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8.md) 59 | 60 | -------------------------------------------------------------------------------- /certs/README.md: -------------------------------------------------------------------------------- 1 | 该目录用于存放两个文件: 2 | 1. 客户端证书文件; 3 | 2. 客户端私钥文件, 该文件需与客户端证书文件一一对应。 -------------------------------------------------------------------------------- /cmake_build.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | commit_id=`git log -1 | head -1 | cut -d' ' -f2` 4 | cat >./include/gitinfo.h<../code-check-clang-tidy.txt 55 | echo "clang-tidy check end" 56 | echo "cpplint check begin" 57 | cd .. 58 | find ./samples/ ./include/ ./sdk_src/ ./platform/ -name *.c -o -name *.h | xargs clang-format -i 59 | cpplint_rules="--filter=-whitespace/line_length,-readability/casting,-build/include_subdir,-whitespace/braces,-whitespace/comments,-whitespace/blank_line,-whitespace/parens,-whitespace/semicolon,-whitespace/end_of_line,-whitespace/ending_newline,-whitespace/comma,-build/header_guard,-runtime/int,-runtime/printf,-readability/todo,-build/include_order,-build/include_what_you_use" 60 | cpplint_coverage="include/ samples/ platform/ sdk_src/" 61 | cpplint ${cpplint_rules} --recursive ${cpplint_coverage} &>./code-check-cpplint.txt 62 | echo "cpplint check end" 63 | exit 64 | else 65 | echo "Usage: "$0" " 66 | exit 67 | fi 68 | -------------------------------------------------------------------------------- /device_info.json: -------------------------------------------------------------------------------- 1 | { 2 | "auth_mode": "KEY", 3 | "productId": "PRODUCT_ID", 4 | "productSecret": "YOUR_PRODUCT_SECRET", 5 | "deviceName": "YOUR_DEV_NAME", 6 | "key_deviceinfo": { 7 | "deviceSecret": "YOUR_IOT_PSK" 8 | }, 9 | "cert_deviceinfo": { 10 | "devCertFile": "YOUR_DEVICE_CERT_FILE_NAME", 11 | "devPrivateKeyFile": "YOUR_DEVICE_PRIVATE_KEY_FILE_NAME" 12 | }, 13 | "subDev": { 14 | "subdev_num": 3, 15 | "subdev_list": [ 16 | { 17 | "sub_productId": "VQ2AWWC1R6", 18 | "sub_devName": "subDev001" 19 | }, 20 | { 21 | "sub_productId": "VQ2AWWC1R6", 22 | "sub_devName": "subDev002" 23 | }, 24 | { 25 | "sub_productId": "VQ2AWWC1R6", 26 | "sub_devName": "subDev003" 27 | } 28 | ] 29 | }, 30 | "region": "china" 31 | } -------------------------------------------------------------------------------- /docs/Device_Type设备类型说明.md: -------------------------------------------------------------------------------- 1 | # 设备联网类型说明 2 | 本文对连接腾讯云物联网平台(下文以 IoT Explorer 为例)的设备类型进行说明,并阐明各设备类型如何移植C-SDK。 3 | 4 | ## IoT设备联网类型 5 | IoT设备首先得具备接入网络的能力,接入网络必须要有TCP/IP协议栈,从TCP/IP协议栈承载的载体区分,IoT设备分为如下三类: 6 | 7 | **类型一**: TCP/IP协议栈跑在主芯片上,主芯片的处理能力和资源较丰富,譬如路由器,本文称作 资源丰富类 IoT设备。 8 | 9 | ![soc](https://main.qcloudimg.com/raw/b8b8c257ff2a0862fccee025ac361883.jpg) 10 | 11 | **类型二**: TCP/IP协议栈跑在通信模组上,主芯片处理能力和资源特别有限,譬如STM32F103系列,本文称作 资源受限类 IoT设备。 12 | ![mcu+module](https://main.qcloudimg.com/raw/aa148085175ebc615c4bc6fa3e483188.jpg) 13 | 14 | **类型三**: TCP/IP协议栈跑在网关上,设备本身并不能直接接入网络,通过有线(485/CAN等)或无线(Ble/ZigBee等)的方式和网关交互,网关(设备类型一或设备类型二)再将数据转发到服务端,这类设备本文称作区域通信类设备。 15 | ![lan](https://main.qcloudimg.com/raw/31fa38d9eb941fc48041ae18ca1860f6.jpg) 16 | 17 | 18 | ## 不同联网类型的设备接入方式 19 | 20 | ### 资源丰富类设备接入 21 | C-SDK可以在 Linux 和 Windows 环境直接编译并运行示例,请参照[C-SDK_Build编译环境及配置选项说明]()说明。针对常见的FreeRTOS+lwIP的场景,我们也提供了HAL层的示例实现。具体参见[FreeRTOS+lwIP平台移植说明]()。 22 | 23 | ### 资源受限类设备接入 24 | 资源受限类设备,借助于通信模组实现网络访问,即MCU+模组方式。模组一般是蜂窝模组(2/3/4/5G)或者WIFI模组,市面可选的模组非常之多,各家的AT指令也各不一样,为此我们提供两种方式实现平台接入。 25 | - 一种是基于SDK提供的AT_Socket框架,基于模组的通用TCP指令,参照at_device目录下的已支持的模组,实现AT_Device驱动的结构体**at_device_op_t**实现对应的驱动接口即可,具体参见[MCU+通用TCP_AT模组移植]()。 26 | - 另一种方式是,我们和主流的模组厂商做了深度合作,将SDK的核心协议已移植到模组中,模组对外封装统一的腾讯云AT指令,同时我们对MCU提供实现和定制模组交互的SDK,,具体参见[MCU+腾讯云定制AT模组]()。 27 | 28 | ### 区域通信类设备接入 29 | 对于区域通信类设备,网关需要实现SDK的移植,SDK针对网关提供对应的协议逻辑代理子设备上线、下线及协议数据交互,网关实现和子设备通信方式和数据格式可根据场景定义,网关将子设备数据及平台下行数据做响应转换后实现上传下达。网关设备归属于类型一或类型二设备,可以对应参照实现SDK移植。 -------------------------------------------------------------------------------- /docs/FreeRTOS+lwIP平台移植说明.md: -------------------------------------------------------------------------------- 1 | # 文档说明 2 | 本文档介绍如何将腾讯云物联 C-SDK 移植到**FreeRTOS+lwIP** 平台。 3 | 4 | ## FreeRTOS移植简介 5 | FreeRTOS作为一个微内核系统,主要提供任务创建及调度和任务间通信等OS核心机制,在不同设备平台还需要搭配多个软件组件包括C运行库(如newlib或者ARM CMSIS库)和TCP/IP网络协议栈(如lwIP)才能形成完整的嵌入式运行平台。同时各个设备平台的编译开发环境也各不相同,因此在移植C-SDK的时候,需要根据不同设备的具体情况进行适配。 6 | SDK 在**platform/os/freertos**里面提供了一个基于 **FreeRTOS+lwIP+newlib** 的参考实现,该实现已经在乐鑫ESP8266平台上验证测试过。 7 | 8 | ## 从腾讯云物联 C-SDK 中抽取相关代码 9 | 10 | 因为基于RTOS系统的平台编译方式各不相同,一般无法直接使用SDK 的cmake或者make编译,因此SDK提供了代码抽取功能,可根据需要将相关代码抽取到一个单独的文件夹,文件夹里面的代码层次目录简洁,方便用户拷贝集成到自己的开发环境。 11 | 12 | 首先修改 CMakeLists.txt 中配置为freertos平台,并开启代码抽取功能: 13 | ``` 14 | set(BUILD_TYPE "release") 15 | set(PLATFORM "freertos") 16 | set(EXTRACT_SRC ON) 17 | set(FEATURE_AT_TCP_ENABLED OFF) 18 | ``` 19 | 在Linux环境运行以下命令 20 | ``` 21 | mkdir build 22 | cd build 23 | cmake .. 24 | ``` 25 | 即可在output/qcloud_iot_c_sdk中找到相关代码文件,目录层次如下: 26 | ``` 27 | qcloud_iot_c_sdk 28 | ├── include 29 | │   ├── config.h 30 | │   ├── exports 31 | ├── platform 32 | └── sdk_src 33 | └── internal_inc 34 | ``` 35 | include目录为SDK供用户使用的API及可变参数,其中config.h为根据编译选项生成的编译宏。API具体介绍请参考**C-SDK_API及可变参数说明**。 36 | platform目录为平台相关的代码,可根据设备的具体情况进行修改适配。具体的函数说明请参考文档**C-SDK_Porting跨平台移植概述** 37 | sdk_src为SDK的核心逻辑及协议相关代码,一般不需要修改,其中internal_inc为SDK内部使用的头文件。 38 | 39 | 用户可将qcloud_iot_c_sdk拷贝到其目标平台的编译开发环境,并根据具体情况修改编译选项。 40 | 41 | ## 乐鑫ESP8266 RTOS平台移植示例 42 | 在Linux开发环境基于乐鑫ESP8266 RTOS平台搭建一个工程示例 43 | 44 | ### 1. 获取 ESP8266_RTOS_SDK 并创建工程 45 | 46 | 请参考[ESP8266_RTOS_SDK](https://github.com/espressif/ESP8266_RTOS_SDK) 获取RTOS_SDK 和交叉编译器,并创建一个项目工程 47 | 48 | ### 2. 拷贝SDK代码 49 | 50 | 将上面抽取的qcloud_iot_c_sdk目录拷贝到components/qcloud_iot下面 51 | 52 | 在components/qcloud_iot下面新建一个编译配置文件component.mk,内容如下 53 | ``` 54 | # 55 | # Component Makefile 56 | # 57 | 58 | COMPONENT_ADD_INCLUDEDIRS := \ 59 | qcloud_iot_c_sdk/include \ 60 | qcloud_iot_c_sdk/include/exports \ 61 | qcloud_iot_c_sdk/sdk_src/internal_inc 62 | 63 | COMPONENT_SRCDIRS := \ 64 | qcloud_iot_c_sdk/sdk_src \ 65 | qcloud_iot_c_sdk/platform 66 | 67 | ``` 68 | 69 | 这样就可以将qcloud_iot_c_sdk作为一个组件进行编译了,之后在用户代码里面就可以调用物联 C-SDK的接口进行连接和收发消息。 70 | -------------------------------------------------------------------------------- /docs/MCU+腾讯云定制AT模组.md: -------------------------------------------------------------------------------- 1 | ## 简介 2 | 腾讯云物联网提供了专用的腾讯云IoT AT指令集([wifi版](https://main.qcloudimg.com/raw/550b58dc11a5a04e3957fa1357ee92b5.pdf)、[蜂窝版](https://main.qcloudimg.com/raw/eca29b5f1684b0127b2c294c466959da.pdf)),如果通讯模组实现了该指令集,则设备接入和通讯更为简单,所需代码量更少,针对这种场景,请参考面向腾讯云定制AT模组专用的 [MCU AT SDK](https://github.com/tencentyun/qcloud-iot-sdk-tencent-at-based.git) 3 | 4 | 目前腾讯云和主流的模组厂商进行了深度合作,将SDK的核心协议已移植到模组中,模组对外封装统一的腾讯云AT指令。已支持腾讯云定制AT指令的模组列表如下: 5 | 6 | | 序号 | 模组商 | 模组型号 | 通信制式 | 7 | | -------| ------------| -------------------|------------------| 8 | | 1 | 乐鑫 | ESP8266 | WIFI | 9 | | 2 | 中移 | M5310-A | NB-IoT | 10 | | 3 | 中移 | M5311 | NB-IoT | 11 | | 4 | 中移 | M6315 | 2G | 12 | | 5 | 中移 | M8321 | 4G | 13 | | 6 | 中移 | ML302 | LTE Cat.1 | 14 | | 7 | 有方 | N10 | 2G | 15 | | 8 | 有方 | N21 | NB-IoT | 16 | | 9 | 有方 | N58 | NB-IoT | 17 | | 10 | 有方 | N720 | 4G | 18 | | 11 | 移柯 | L206D | 2G | 19 | | 12 | 移柯 | L501C | LTE Cat.1 | 20 | | 13 | 移柯 | L620C | NB-IoT | 21 | | 14 | 广和通 | L610 | LTE Cat.1 | 22 | | 15 | 广和通 | ME3616 | NB-IoT | 23 | -------------------------------------------------------------------------------- /docs/MCU+通用TCP_AT模组移植(FreeRTOS).md: -------------------------------------------------------------------------------- 1 | ## 简介 2 | 3 | 对于不具备网络通讯能力的MCU,一般采用MCU+通讯模组的方式,通讯模组(包括WiFi/2G/4G/NB-IoT)一般提供了基于串口的AT指令协议供MCU进行网络通讯。针对这种场景,C-SDK 封装了AT-socket网络层,网络层之上的核心协议和服务层无须移植。本文阐述针对 MCU(FreeRTOS)+通用TCP AT模组的目标环境,如何移植C-SDK 并接入腾讯云物联网平台(以IoT Explorer为例)。 4 | 5 | ## 系统框图 6 | ![mcu+module](https://main.qcloudimg.com/raw/aa148085175ebc615c4bc6fa3e483188.jpg) 7 | 8 | ## 移植步骤 9 | ![port_flow](https://main.qcloudimg.com/raw/3717052f47405e66a754f2f8594c6c84.jpg) 10 | 11 | ### 1. 下载最新版本设备端 [C-SDK](https://github.com/tencentyun/qcloud-iot-sdk-embedded-c)。 12 | 13 | ### 2. SDK功能配置及代码抽取 14 | - 使用通用TCP模组编译配置选项配置如下: 15 | 16 | | 名称 | 配置 | 说明 | 17 | | :------------------------------- | ------------- | ------------------------------------------------------------ | 18 | | BUILD_TYPE | debug/release,根据需要设置 | 19 | | EXTRACT_SRC | ON | 使能代码抽取 | 20 | | COMPILE_TOOLS | gcc/MSVC | 根据需要设置,IDE情况不关注 | 21 | | PLATFORM | linux/windows | 根据需要设置,IDE情况不关注 | 22 | | FEATURE_OTA_COMM_ENABLED | ON/OFF | 根据需要设置 | 23 | | FEATURE_AUTH_MODE | KEY | 资源受限设备认证方式建议选秘钥认证 | 24 | | FEATURE_AUTH_WITH_NOTLS | ON/OFF | 根据需要是否使能TLS | 25 | | FEATURE_EVENT_POST_ENABLED | ON/OFF | 根据需要是否使能事件上报 | 26 | | FEATURE_AT_TCP_ENABLED | ON | AT模组TCP功能开关 | 27 | | FEATURE_AT_UART_RECV_IRQ | ON | AT模组中断接受功能开关 | 28 | | FEATURE_AT_OS_USED | ON | AT模组多线程功能开关 | 29 | | FEATURE_AT_DEBUG | OFF | 默认关闭AT模组调试功能,有调试需要再打开| 30 | 31 | - 参考文档[C-SDK_Build编译环境及配置选项说明]()抽取代码 32 | 33 | - 将抽取的代码目录作为通信组件放在类似 RTOS、FATFS 的第三方组件的同级目录,系统代码框架大体如下: 34 | ![](https://main.qcloudimg.com/raw/5e3da49ac27e57d72fd6f6a70bb98547.jpg) 35 | 36 | ### 3. 数据模板模板代码生成 37 | 对于IoT_Explorer产品可以参考[IoT_Explorer/Data_template数据模板代码生成]() 38 | 对于IoT_Hub产品,可跳过这一步 39 | 40 | ### 4. HAL 层移植 41 | 42 | 参见[C-SDK_Porting跨平台移植概述]() 43 | 对于网络相关的HAL接口,通过上面的编译选项已选择SDK提供的AT_Socket框架,SDK会调用 network_at_tcp.c 的at_socket接口,at_socket层不需要移植,需要实现AT串口驱动及AT模组驱动,AT模组驱动只需要实现AT框架中at_device的驱动结构体 *at_device_op_t* 的驱动接口即可,可以参照at_device目录下的已支持的模组。目前SDK针对物联网使用较广的WiFi模组ESP8266提供了底层接口实现,供移植到其他通讯模组时作为参考。 44 | 45 | ### 5. 业务逻辑开发 46 | 47 | 对于IoT_Explorer产品,可以参考[IoT_Explorer/Data_template数据模板应用开发]()实现具体业务场景下的业务逻辑开发。 48 | 对于IoT_Hub产品,可以参考IoT_Hub目录下的例程。 49 | 50 | -------------------------------------------------------------------------------- /docs/MCU+通用TCP_AT模组移植(nonOS).md: -------------------------------------------------------------------------------- 1 | ## 简介 2 | 3 | 对于不具备网络通讯能力的MCU,一般采用MCU+通讯模组的方式,通讯模组(包括WiFi/2G/4G/NB-IoT)一般提供了基于串口的AT指令协议供MCU进行网络通讯。针对这种场景,C-SDK 封装了AT-socket网络层,网络层之上的核心协议和服务层无须移植。本文阐述针对 MCU(无OS)+通用TCP AT模组的目标环境,如何移植C-SDK 并接入腾讯云物联网平台(以IoT Explorer为例)。 4 | 相较于有RTOS场景,at_socket网络接收数据的处理会有差异,应用层需要周期性的调用**IOT_MQTT_Yield**来接收服务端下行数据,错过接收窗口则会存在数据丢失的情况,所以在业务逻辑较为复杂的场景建议使用RTOS,通过配置 FEATURE_AT_OS_USED = OFF选择无OS方式。 5 | 6 | ## 系统框图 7 | ![mcu+module](https://main.qcloudimg.com/raw/aa148085175ebc615c4bc6fa3e483188.jpg) 8 | 9 | ## 移植步骤 10 | ![port_flow](https://main.qcloudimg.com/raw/3717052f47405e66a754f2f8594c6c84.jpg) 11 | 12 | ### 1. 下载最新版本设备端 [C-SDK](https://github.com/tencentyun/qcloud-iot-sdk-embedded-c)。 13 | 14 | ### 2. SDK功能配置及代码抽取 15 | - 无RTOS使用通用TCP模组编译配置选项配置如下: 16 | 17 | | 名称 | 配置 | 说明 | 18 | | :------------------------------- | ------------- | ------------------------------------------------------------ | 19 | | BUILD_TYPE | debug/release,根据需要设置 | 20 | | EXTRACT_SRC | ON | 使能代码抽取 | 21 | | COMPILE_TOOLS | gcc/MSVC | 根据需要设置,IDE情况不关注 | 22 | | PLATFORM | linux/windows | 根据需要设置,IDE情况不关注 | 23 | | FEATURE_OTA_COMM_ENABLED | ON/OFF | 根据需要设置 | 24 | | FEATURE_AUTH_MODE | KEY | 资源受限设备认证方式建议选秘钥认证 | 25 | | FEATURE_AUTH_WITH_NOTLS | ON/OFF | 根据需要是否使能TLS | 26 | | FEATURE_EVENT_POST_ENABLED | ON/OFF | 根据需要是否使能事件上报 | 27 | | FEATURE_AT_TCP_ENABLED | ON | 使能at_socket组件 | 28 | | FEATURE_AT_UART_RECV_IRQ | ON | 使能AT串口中断接收 | 29 | | FEATURE_AT_OS_USED | OFF | at_socket组件无RTOS环境使用 | 30 | | FEATURE_AT_DEBUG | OFF | 默认关闭AT模组调试功能,有调试需要再打开| 31 | 32 | - 参考文档[C-SDK_Build编译环境及配置选项说明]()抽取代码 33 | 34 | - 将抽取的代码目录作为通信组件放在类似 RTOS、FATFS 的第三方组件的同级目录,系统代码框架大体如下: 35 | ![](https://main.qcloudimg.com/raw/5e3da49ac27e57d72fd6f6a70bb98547.jpg) 36 | 37 | ### 3. 数据模板模板代码生成 38 | 对于IoT_Explorer产品可以参考[IoT_Explorer/Data_template数据模板代码生成]() 39 | 对于IoT_Hub产品,可跳过这一步 40 | 41 | ### 4. HAL 层移植 42 | 43 | 参见[C-SDK_Porting跨平台移植概述]() 44 | 45 | 对于网络相关的HAL接口,通过上面的编译选项已选择SDK提供的AT_Socket框架,SDK会调用 network_at_tcp.c 的at_socket接口,at_socket层不需要移植,需要实现AT串口驱动及AT模组驱动,AT模组驱动只需要实现AT框架中at_device的驱动结构体 *at_device_op_t* 的驱动接口即可,可以参照at_device目录下的已支持的模组。AT串口驱动需要实现串口的中断接收,然后在中断服务程序中调用回调函数 *at_client_uart_rx_isr_cb* 即可,可以参考 HAL_OS_nonos.c 实现目标平台的移植。 46 | 47 | ### 5. 业务逻辑开发 48 | 49 | 对于IoT_Explorer产品,可以参考[IoT_Explorer/Data_template数据模板应用开发]()实现具体业务场景下的业务逻辑开发。 50 | 对于IoT_Hub产品,可以参考IoT_Hub目录下的例程。 51 | 52 | -------------------------------------------------------------------------------- /docs/动态注册使用说明.md: -------------------------------------------------------------------------------- 1 | ### 动态注册使用说明 2 | - 对于一机一密的场景,需要在生产环节将为每一个设备烧录由平台生成的唯一设备信息。 3 | - 对于一型一密场景,同一产品类型的设备只要预置产品级密钥,可省去工厂的设备信息烧录。设备出厂后,在第一次开机且成功联网的情况下,可发起动态注册,通过产品密钥鉴权,从平台获取设备信息,然后存在本地,达成和工厂烧录一样的效果。 4 | 5 | 6 | ### 使用步骤 7 | - 1、在[控制台使能](https://cloud.tencent.com/document/product/1081/47494)产品的动态注册功能。 8 | >! 使能动态注册后才有产品密钥。 9 | 10 | ![](https://main.qcloudimg.com/raw/d615cf031e5d3d8b06c56cb4caeec383.png) 11 | 12 | - 2 、选择是否使能自动设备创建。这个选项决定动态注册的时候的设备名,是设备自定义的(需要保证统一产品下设备名唯一),还是使用平台预定义的设备名。 13 | 14 | - 3、将产品密钥预置在设备侧。设备信息获取接口`HAL_GetDevInfo` 获取设备信息时会获取产品密钥,可通过设备信息设置接口`HAL_SetDevInfo`设置产品密钥。 15 | 16 | - 4、判断是否触发动态注册。一般的方法是,设备启动,在动态注册使能的情况下,通过设备信息获取接口`HAL_GetDevInfo` 获取设备信息,判断设备密钥是否是默认值,如果是,则调用SDK的动态注册接口`IOT_DynReg_Device`发起动态注册,若动态注册成功,则通过设备信息设置接口`HAL_SetDevInfo`保存返回设备信息。后续设备即可按一机一密启动流程正常使用。 17 | 18 | - 5、SDK设备动态注册示例`dynreg_dev_sample.c`说明: 19 | - 判断设备密钥是否为空,是否触发动态注册 20 | ``` 21 | memset((char *)&sDevInfo, 0, sizeof(DeviceInfo)); 22 | ret = HAL_GetDevInfo(&sDevInfo); 23 | /* just demo the PSK is empty */ 24 | if (!strcmp(sDevInfo.device_secret, QCLOUD_IOT_NULL_DEVICE_SECRET)) { 25 | Log_d("dev psk not exist!"); 26 | infoNullFlag = true; 27 | } else { 28 | Log_d("dev psk exist"); 29 | } 30 | ``` 31 | 32 | - 发起动态注册,并保存动态注册的设备信息 33 | ``` 34 | /* device cert/key files or PSK is empty, do dynamic register to fetch */ 35 | if (infoNullFlag) { 36 | if (QCLOUD_RET_SUCCESS == IOT_DynReg_Device(&sDevInfo)) { 37 | ret = HAL_SetDevInfo(&sDevInfo); 38 | if (QCLOUD_RET_SUCCESS != ret) { 39 | Log_e("devices info save fail"); 40 | } else { 41 | Log_d( 42 | "dynamic register success,productID: %s, devName: %s, " 43 | "device_secret: %s", 44 | sDevInfo.product_id, sDevInfo.device_name, sDevInfo.device_secret); 45 | } 46 | } else { 47 | Log_e("%s dynamic register fail", sDevInfo.device_name); 48 | } 49 | } 50 | 51 | ``` 52 | 53 | - 6、重复注册说明。一般情况动态注册只要执行一次,后续使用保存的设备信息即可。如果设备动态注册成功,但未激活(和平台成功建立过连接),则可重复注册。若已激活,则需要在控制台删除设备,才可以再次注册。不建议通过更换设备名的方式多次动态注册,相当于一个设备消耗多个设备的资源,对于运营管理也会带来麻烦。 54 | 55 | > 注意:目前平台只支持预定义设备名动态注册,不支持自定义设备名动态注册(没有在平台预创建的设备将会动态注册失败)。 -------------------------------------------------------------------------------- /docs/数据模板开发/数据模板代码生成.md: -------------------------------------------------------------------------------- 1 | ## 简介 2 | 本文介绍基于物联开发平台 IoT Explorer 创建的数据模板如何生成模板代码。 3 | 4 | ## 数据模板创建 5 | 参阅[产品定义](https://cloud.tencent.com/document/product/1081/34739?!preview&!editLang=zh#.E6.95.B0.E6.8D.AE.E6.A8.A1.E6.9D.BF)创建数据模板 6 | 7 | ## 数据模板描述文件导出 8 | 数据模板描述文件是一个 JSON 格式的文件,描述了产品定义的属性、事件及其他信息,在平台导出此json文件,如下图示: 9 | ![](https://main.qcloudimg.com/raw/0951d7c3f540ca716442e08651a0efa5.jpg) 10 | 11 | ## 数据模板模板代码生成 12 | 将下载的json文件拷贝到tools目录,执行./codegen.py -c xx/config.json -d ../targetdir/ 命令,则会根据json文件在target目录生成所定义产品的数据模板及事件的配置文件,将这个生成的配置文件拷贝到data_template_sample.c的同级目录,data_template_sample.c示例了通用的数据模板处理框架,可以基于此框架添加业务逻辑。智能灯示例light_data_template_sample.c即是基于此框架的场景示例。 13 | 14 | ``` 15 | ./codegen.py -c light.json -d ../samples/data_template/ 16 | 加载 light.json 文件成功 17 | 文件 ../samples/data_template/data_config.c 生成成功 18 | 文件 ../samples/data_template/events_config.c 生成成功 19 | ``` -------------------------------------------------------------------------------- /docs/腾讯连连蓝牙辅助配网协议V1.1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentCloud/tencentcloud-iot-explorer-sdk-embedded-c/48d928ceb9c8350d29ef0f87f125ce1292a0111c/docs/腾讯连连蓝牙辅助配网协议V1.1.pdf -------------------------------------------------------------------------------- /external_libs/cJSON/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009-2017 Dave Gamble and cJSON contributors 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | 21 | -------------------------------------------------------------------------------- /external_libs/cJSON/appveyor.yml: -------------------------------------------------------------------------------- 1 | os: Visual Studio 2015 2 | 3 | # ENABLE_CUSTOM_COMPILER_FLAGS - on by default 4 | # ENABLE_SANITIZERS - off by default 5 | # ENABLE_PUBLIC_SYMBOLS - on by default 6 | # BUILD_SHARED_LIBS - on by default 7 | # ENABLE_TARGET_EXPORT - on by default 8 | # ENABLE_CJSON_UTILS - off by default 9 | # ENABLE_CJSON_TEST -on by default 10 | # ENABLE_VALGRIND - off by default 11 | # ENABLE_FUZZING - off by default 12 | 13 | environment: 14 | matrix: 15 | - GENERATOR: "Visual Studio 14 2015" 16 | BUILD_SHARED_LIBS: ON 17 | ENABLE_CJSON_TEST: OFF 18 | ENABLE_CJSON_UTILS: ON 19 | 20 | - GENERATOR: "Visual Studio 14 2015" 21 | BUILD_SHARED_LIBS: OFF 22 | ENABLE_CJSON_TEST: OFF 23 | ENABLE_CJSON_UTILS: ON 24 | 25 | - GENERATOR: "Visual Studio 12 2013" 26 | BUILD_SHARED_LIBS: ON 27 | ENABLE_CJSON_TEST: OFF 28 | ENABLE_CJSON_UTILS: ON 29 | 30 | - GENERATOR: "Visual Studio 12 2013" 31 | BUILD_SHARED_LIBS: OFF 32 | ENABLE_CJSON_TEST: OFF 33 | ENABLE_CJSON_UTILS: ON 34 | 35 | - GENERATOR: "Visual Studio 11 2012" 36 | BUILD_SHARED_LIBS: ON 37 | ENABLE_CJSON_TEST: OFF 38 | ENABLE_CJSON_UTILS: ON 39 | 40 | - GENERATOR: "Visual Studio 11 2012" 41 | BUILD_SHARED_LIBS: OFF 42 | ENABLE_CJSON_TEST: OFF 43 | ENABLE_CJSON_UTILS: ON 44 | 45 | - GENERATOR: "Visual Studio 10 2010" 46 | BUILD_SHARED_LIBS: ON 47 | ENABLE_CJSON_TEST: OFF 48 | ENABLE_CJSON_UTILS: ON 49 | 50 | - GENERATOR: "Visual Studio 10 2010" 51 | BUILD_SHARED_LIBS: OFF 52 | ENABLE_CJSON_TEST: OFF 53 | ENABLE_CJSON_UTILS: ON 54 | 55 | - GENERATOR: "Visual Studio 9 2008" 56 | BUILD_SHARED_LIBS: ON 57 | ENABLE_CJSON_TEST: OFF 58 | ENABLE_CJSON_UTILS: ON 59 | 60 | - GENERATOR: "Visual Studio 9 2008" 61 | BUILD_SHARED_LIBS: OFF 62 | ENABLE_CJSON_TEST: OFF 63 | ENABLE_CJSON_UTILS: ON 64 | 65 | 66 | platform: 67 | - x86 68 | - x64 69 | matrix: 70 | exclude: 71 | - platform: x64 72 | GENERATOR: "Visual Studio 9 2008" 73 | 74 | configuration: 75 | - Release 76 | 77 | 78 | build_script: 79 | - ps: if($env:PLATFORM -eq "x64") { $env:CMAKE_GEN_SUFFIX=" Win64" } 80 | - cmake "-G%GENERATOR%%CMAKE_GEN_SUFFIX%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% -DENABLE_CJSON_TEST=%ENABLE_CJSON_TEST% -H. -Bbuild 81 | - cmake --build build --config "%CONFIGURATION%" 82 | 83 | 84 | on_failure: 85 | - ps: if(Test-Path builds/CMakeFiles/CMakeOutput.log) { cat builds/CMakeFiles/CMakeOutput.log } 86 | - ps: if(Test-Path builds/CMakeFiles/CMakeError.log) { cat builds/CMakeFiles/CMakeError.log } -------------------------------------------------------------------------------- /external_libs/cJSON/valgrind.supp: -------------------------------------------------------------------------------- 1 | { 2 | suppress_ld_on_armv7 3 | Memcheck:Cond 4 | ... 5 | obj:*/ld-*.so 6 | } 7 | -------------------------------------------------------------------------------- /external_libs/mbedtls/Makefile: -------------------------------------------------------------------------------- 1 | 2 | DESTDIR=/usr/local 3 | PREFIX=mbedtls_ 4 | 5 | .SILENT: 6 | 7 | .PHONY: all lib tests install uninstall clean test check covtest lcov apidoc apidoc_clean 8 | 9 | all: lib 10 | $(MAKE) post_build 11 | 12 | no_test: programs 13 | 14 | programs: lib 15 | $(MAKE) -s -C programs 16 | 17 | lib: 18 | $(MAKE) -C library 19 | 20 | tests: lib 21 | $(MAKE) -C tests 22 | 23 | ifndef WINDOWS 24 | install: no_test 25 | mkdir -p $(DESTDIR)/include/mbedtls 26 | cp -r include/mbedtls $(DESTDIR)/include 27 | 28 | mkdir -p $(DESTDIR)/lib 29 | cp -RP library/libmbedtls.* $(DESTDIR)/lib 30 | cp -RP library/libmbedx509.* $(DESTDIR)/lib 31 | cp -RP library/libmbedcrypto.* $(DESTDIR)/lib 32 | 33 | mkdir -p $(DESTDIR)/bin 34 | for p in programs/*/* ; do \ 35 | if [ -x $$p ] && [ ! -d $$p ] ; \ 36 | then \ 37 | f=$(PREFIX)`basename $$p` ; \ 38 | cp $$p $(DESTDIR)/bin/$$f ; \ 39 | fi \ 40 | done 41 | 42 | uninstall: 43 | rm -rf $(DESTDIR)/include/mbedtls 44 | rm -f $(DESTDIR)/lib/libmbedtls.* 45 | rm -f $(DESTDIR)/lib/libmbedx509.* 46 | rm -f $(DESTDIR)/lib/libmbedcrypto.* 47 | 48 | for p in programs/*/* ; do \ 49 | if [ -x $$p ] && [ ! -d $$p ] ; \ 50 | then \ 51 | f=$(PREFIX)`basename $$p` ; \ 52 | rm -f $(DESTDIR)/bin/$$f ; \ 53 | fi \ 54 | done 55 | endif 56 | 57 | WARNING_BORDER =*******************************************************\n 58 | NULL_ENTROPY_WARN_L1=**** WARNING! MBEDTLS_TEST_NULL_ENTROPY defined! ****\n 59 | NULL_ENTROPY_WARN_L2=**** THIS BUILD HAS NO DEFINED ENTROPY SOURCES ****\n 60 | NULL_ENTROPY_WARN_L3=**** AND IS *NOT* SUITABLE FOR PRODUCTION USE ****\n 61 | 62 | NULL_ENTROPY_WARNING=\n$(WARNING_BORDER)$(NULL_ENTROPY_WARN_L1)$(NULL_ENTROPY_WARN_L2)$(NULL_ENTROPY_WARN_L3)$(WARNING_BORDER) 63 | 64 | # Post build steps 65 | post_build: 66 | ifndef WINDOWS 67 | # If NULL Entropy is configured, display an appropriate warning 68 | -scripts/config.pl get MBEDTLS_TEST_NULL_ENTROPY && ([ $$? -eq 0 ]) && \ 69 | echo '$(NULL_ENTROPY_WARNING)' 70 | endif 71 | 72 | clean: 73 | $(MAKE) -C library clean 74 | ifndef WINDOWS 75 | find . \( -name \*.gcno -o -name \*.gcda -o -name \*.info \) -exec rm {} + 76 | endif 77 | 78 | check: lib tests 79 | $(MAKE) -C tests check 80 | 81 | test: check 82 | 83 | ifndef WINDOWS 84 | # note: for coverage testing, build with: 85 | # make CFLAGS='--coverage -g3 -O0' 86 | covtest: 87 | $(MAKE) check 88 | programs/test/selftest 89 | tests/compat.sh 90 | tests/ssl-opt.sh 91 | 92 | lcov: 93 | rm -rf Coverage 94 | lcov --capture --initial --directory library -o files.info 95 | lcov --capture --directory library -o tests.info 96 | lcov --add-tracefile files.info --add-tracefile tests.info -o all.info 97 | lcov --remove all.info -o final.info '*.h' 98 | gendesc tests/Descriptions.txt -o descriptions 99 | genhtml --title "mbed TLS" --description-file descriptions --keep-descriptions --legend --no-branch-coverage -o Coverage final.info 100 | rm -f files.info tests.info all.info final.info descriptions 101 | 102 | apidoc: 103 | mkdir -p apidoc 104 | doxygen doxygen/mbedtls.doxyfile 105 | 106 | apidoc_clean: 107 | rm -rf apidoc 108 | endif 109 | -------------------------------------------------------------------------------- /external_libs/mbedtls/configs/README.txt: -------------------------------------------------------------------------------- 1 | This directory contains example configuration files. 2 | 3 | The examples are generally focused on a particular usage case (eg, support for 4 | a restricted number of ciphersuites) and aim at minimizing resource usage for 5 | this target. They can be used as a basis for custom configurations. 6 | 7 | These files are complete replacements for the default config.h. To use one of 8 | them, you can pick one of the following methods: 9 | 10 | 1. Replace the default file include/mbedtls/config.h with the chosen one. 11 | (Depending on your compiler, you may need to ajust the line with 12 | #include "mbedtls/check_config.h" then.) 13 | 14 | 2. Define MBEDTLS_CONFIG_FILE and adjust the include path accordingly. 15 | For example, using make: 16 | 17 | CFLAGS="-I$PWD/configs -DMBEDTLS_CONFIG_FILE=''" make 18 | 19 | Or, using cmake: 20 | 21 | find . -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} + 22 | CFLAGS="-I$PWD/configs -DMBEDTLS_CONFIG_FILE=''" cmake . 23 | make 24 | 25 | Note that the second method also works if you want to keep your custom 26 | configuration file outside the mbed TLS tree. 27 | -------------------------------------------------------------------------------- /external_libs/mbedtls/configs/config-ccm-psk-tls1_2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Minimal configuration for TLS 1.2 with PSK and AES-CCM ciphersuites 3 | * 4 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 5 | * SPDX-License-Identifier: Apache-2.0 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 8 | * not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 15 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * This file is part of mbed TLS (https://tls.mbed.org) 20 | */ 21 | /* 22 | * Minimal configuration for TLS 1.2 with PSK and AES-CCM ciphersuites 23 | * Distinguishing features: 24 | * - no bignum, no PK, no X509 25 | * - fully modern and secure (provided the pre-shared keys have high entropy) 26 | * - very low record overhead with CCM-8 27 | * - optimized for low RAM usage 28 | * 29 | * See README.txt for usage instructions. 30 | */ 31 | #ifndef MBEDTLS_CONFIG_H 32 | #define MBEDTLS_CONFIG_H 33 | 34 | /* System support */ 35 | //#define MBEDTLS_HAVE_TIME /* Optionally used in Hello messages */ 36 | /* Other MBEDTLS_HAVE_XXX flags irrelevant for this configuration */ 37 | 38 | /* mbed TLS feature support */ 39 | #define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED 40 | #define MBEDTLS_SSL_PROTO_TLS1_2 41 | 42 | /* mbed TLS modules */ 43 | #define MBEDTLS_AES_C 44 | #define MBEDTLS_CCM_C 45 | #define MBEDTLS_CIPHER_C 46 | #define MBEDTLS_CTR_DRBG_C 47 | #define MBEDTLS_ENTROPY_C 48 | #define MBEDTLS_MD_C 49 | #define MBEDTLS_NET_C 50 | #define MBEDTLS_SHA256_C 51 | #define MBEDTLS_SSL_CLI_C 52 | #define MBEDTLS_SSL_SRV_C 53 | #define MBEDTLS_SSL_TLS_C 54 | 55 | /* Save RAM at the expense of ROM */ 56 | #define MBEDTLS_AES_ROM_TABLES 57 | 58 | /* Save some RAM by adjusting to your exact needs */ 59 | #define MBEDTLS_PSK_MAX_LEN 16 /* 128-bits keys are generally enough */ 60 | 61 | /* 62 | * You should adjust this to the exact number of sources you're using: default 63 | * is the "platform_entropy_poll" source, but you may want to add other ones 64 | * Minimum is 2 for the entropy test suite. 65 | */ 66 | #define MBEDTLS_ENTROPY_MAX_SOURCES 2 67 | 68 | /* 69 | * Use only CCM_8 ciphersuites, and 70 | * save ROM and a few bytes of RAM by specifying our own ciphersuite list 71 | */ 72 | #define MBEDTLS_SSL_CIPHERSUITES \ 73 | MBEDTLS_TLS_PSK_WITH_AES_256_CCM_8, \ 74 | MBEDTLS_TLS_PSK_WITH_AES_128_CCM_8 75 | 76 | /* 77 | * Save RAM at the expense of interoperability: do this only if you control 78 | * both ends of the connection! (See comments in "mbedtls/ssl.h".) 79 | * The optimal size here depends on the typical size of records. 80 | */ 81 | #define MBEDTLS_SSL_MAX_CONTENT_LEN 512 82 | 83 | #include "mbedtls/check_config.h" 84 | 85 | #endif /* MBEDTLS_CONFIG_H */ 86 | -------------------------------------------------------------------------------- /external_libs/mbedtls/configs/config-mini-tls1_1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Minimal configuration for TLS 1.1 (RFC 4346) 3 | * 4 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 5 | * SPDX-License-Identifier: Apache-2.0 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 8 | * not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 15 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * This file is part of mbed TLS (https://tls.mbed.org) 20 | */ 21 | /* 22 | * Minimal configuration for TLS 1.1 (RFC 4346), implementing only the 23 | * required ciphersuite: MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA 24 | * 25 | * See README.txt for usage instructions. 26 | */ 27 | 28 | #ifndef MBEDTLS_CONFIG_H 29 | #define MBEDTLS_CONFIG_H 30 | 31 | /* System support */ 32 | #define MBEDTLS_HAVE_ASM 33 | #define MBEDTLS_HAVE_TIME 34 | 35 | /* mbed TLS feature support */ 36 | #define MBEDTLS_CIPHER_MODE_CBC 37 | #define MBEDTLS_PKCS1_V15 38 | #define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED 39 | #define MBEDTLS_SSL_PROTO_TLS1_1 40 | 41 | /* mbed TLS modules */ 42 | #define MBEDTLS_AES_C 43 | #define MBEDTLS_ASN1_PARSE_C 44 | #define MBEDTLS_ASN1_WRITE_C 45 | #define MBEDTLS_BIGNUM_C 46 | #define MBEDTLS_CIPHER_C 47 | #define MBEDTLS_CTR_DRBG_C 48 | #define MBEDTLS_DES_C 49 | #define MBEDTLS_ENTROPY_C 50 | #define MBEDTLS_MD_C 51 | #define MBEDTLS_MD5_C 52 | #define MBEDTLS_NET_C 53 | #define MBEDTLS_OID_C 54 | #define MBEDTLS_PK_C 55 | #define MBEDTLS_PK_PARSE_C 56 | #define MBEDTLS_RSA_C 57 | #define MBEDTLS_SHA1_C 58 | #define MBEDTLS_SHA256_C 59 | #define MBEDTLS_SSL_CLI_C 60 | #define MBEDTLS_SSL_SRV_C 61 | #define MBEDTLS_SSL_TLS_C 62 | #define MBEDTLS_X509_CRT_PARSE_C 63 | #define MBEDTLS_X509_USE_C 64 | 65 | /* For test certificates */ 66 | #define MBEDTLS_BASE64_C 67 | #define MBEDTLS_CERTS_C 68 | #define MBEDTLS_PEM_PARSE_C 69 | 70 | /* For testing with compat.sh */ 71 | #define MBEDTLS_FS_IO 72 | 73 | #include "mbedtls/check_config.h" 74 | 75 | #endif /* MBEDTLS_CONFIG_H */ 76 | -------------------------------------------------------------------------------- /external_libs/mbedtls/configs/config-no-entropy.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Minimal configuration of features that do not require an entropy source 3 | * 4 | * Copyright (C) 2016, ARM Limited, All Rights Reserved 5 | * SPDX-License-Identifier: Apache-2.0 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 8 | * not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 15 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * This file is part of mbed TLS (https://tls.mbed.org) 20 | */ 21 | /* 22 | * Minimal configuration of features that do not require an entropy source 23 | * Distinguishing reatures: 24 | * - no entropy module 25 | * - no TLS protocol implementation available due to absence of an entropy 26 | * source 27 | * 28 | * See README.txt for usage instructions. 29 | */ 30 | 31 | #ifndef MBEDTLS_CONFIG_H 32 | #define MBEDTLS_CONFIG_H 33 | 34 | /* System support */ 35 | #define MBEDTLS_HAVE_ASM 36 | #define MBEDTLS_HAVE_TIME 37 | 38 | /* mbed TLS feature support */ 39 | #define MBEDTLS_CIPHER_MODE_CBC 40 | #define MBEDTLS_CIPHER_PADDING_PKCS7 41 | #define MBEDTLS_REMOVE_ARC4_CIPHERSUITES 42 | #define MBEDTLS_ECP_DP_SECP256R1_ENABLED 43 | #define MBEDTLS_ECP_DP_SECP384R1_ENABLED 44 | #define MBEDTLS_ECP_DP_CURVE25519_ENABLED 45 | #define MBEDTLS_ECP_NIST_OPTIM 46 | #define MBEDTLS_ECDSA_DETERMINISTIC 47 | #define MBEDTLS_PK_RSA_ALT_SUPPORT 48 | #define MBEDTLS_PKCS1_V15 49 | #define MBEDTLS_PKCS1_V21 50 | #define MBEDTLS_SELF_TEST 51 | #define MBEDTLS_VERSION_FEATURES 52 | #define MBEDTLS_X509_CHECK_KEY_USAGE 53 | #define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE 54 | 55 | /* mbed TLS modules */ 56 | #define MBEDTLS_AES_C 57 | #define MBEDTLS_ASN1_PARSE_C 58 | #define MBEDTLS_ASN1_WRITE_C 59 | #define MBEDTLS_BASE64_C 60 | #define MBEDTLS_BIGNUM_C 61 | #define MBEDTLS_CCM_C 62 | #define MBEDTLS_CIPHER_C 63 | #define MBEDTLS_ECDSA_C 64 | #define MBEDTLS_ECP_C 65 | #define MBEDTLS_ERROR_C 66 | #define MBEDTLS_GCM_C 67 | #define MBEDTLS_HMAC_DRBG_C 68 | #define MBEDTLS_MD_C 69 | #define MBEDTLS_OID_C 70 | #define MBEDTLS_PEM_PARSE_C 71 | #define MBEDTLS_PK_C 72 | #define MBEDTLS_PK_PARSE_C 73 | #define MBEDTLS_PK_WRITE_C 74 | #define MBEDTLS_PLATFORM_C 75 | #define MBEDTLS_RSA_C 76 | #define MBEDTLS_SHA256_C 77 | #define MBEDTLS_SHA512_C 78 | #define MBEDTLS_VERSION_C 79 | #define MBEDTLS_X509_USE_C 80 | #define MBEDTLS_X509_CRT_PARSE_C 81 | #define MBEDTLS_X509_CRL_PARSE_C 82 | 83 | #include "check_config.h" 84 | 85 | #endif /* MBEDTLS_CONFIG_H */ 86 | -------------------------------------------------------------------------------- /external_libs/mbedtls/configs/config-picocoin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Reduced configuration used by Picocoin. 3 | * 4 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 5 | * SPDX-License-Identifier: Apache-2.0 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 8 | * not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 15 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * This file is part of mbed TLS (https://tls.mbed.org) 20 | */ 21 | /* 22 | * Reduced configuration used by Picocoin. 23 | * 24 | * See README.txt for usage instructions. 25 | * 26 | * Distinguishing features: 27 | * - no SSL/TLS; 28 | * - no X.509; 29 | * - ECDSA/PK and some other chosen crypto bits. 30 | */ 31 | 32 | #ifndef MBEDTLS_CONFIG_H 33 | #define MBEDTLS_CONFIG_H 34 | 35 | /* System support */ 36 | #define MBEDTLS_HAVE_ASM 37 | #define MBEDTLS_HAVE_TIME 38 | 39 | /* mbed TLS feature support */ 40 | #define MBEDTLS_CIPHER_MODE_CBC 41 | #define MBEDTLS_CIPHER_PADDING_PKCS7 42 | #define MBEDTLS_ECP_DP_SECP256K1_ENABLED 43 | #define MBEDTLS_ECDSA_DETERMINISTIC 44 | #define MBEDTLS_PK_PARSE_EC_EXTENDED 45 | #define MBEDTLS_ERROR_STRERROR_DUMMY 46 | #define MBEDTLS_FS_IO 47 | 48 | /* mbed TLS modules */ 49 | #define MBEDTLS_AESNI_C 50 | #define MBEDTLS_AES_C 51 | #define MBEDTLS_ASN1_PARSE_C 52 | #define MBEDTLS_ASN1_WRITE_C 53 | #define MBEDTLS_BASE64_C 54 | #define MBEDTLS_BIGNUM_C 55 | #define MBEDTLS_ECDSA_C 56 | #define MBEDTLS_ECP_C 57 | #define MBEDTLS_ENTROPY_C 58 | #define MBEDTLS_HMAC_DRBG_C 59 | #define MBEDTLS_MD_C 60 | #define MBEDTLS_OID_C 61 | #define MBEDTLS_PADLOCK_C 62 | #define MBEDTLS_PK_C 63 | #define MBEDTLS_PK_PARSE_C 64 | #define MBEDTLS_PK_WRITE_C 65 | #define MBEDTLS_RIPEMD160_C 66 | #define MBEDTLS_SHA1_C 67 | #define MBEDTLS_SHA256_C 68 | 69 | #include "mbedtls/check_config.h" 70 | 71 | #endif /* MBEDTLS_CONFIG_H */ 72 | -------------------------------------------------------------------------------- /external_libs/mbedtls/configs/config-thread.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Minimal configuration for using TLS as part of Thread 3 | * 4 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 5 | * SPDX-License-Identifier: Apache-2.0 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 8 | * not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 15 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * This file is part of mbed TLS (https://tls.mbed.org) 20 | */ 21 | 22 | /* 23 | * Minimal configuration for using TLS a part of Thread 24 | * http://threadgroup.org/ 25 | * 26 | * Distinguishing features: 27 | * - no RSA or classic DH, fully based on ECC 28 | * - no X.509 29 | * - support for experimental EC J-PAKE key exchange 30 | * 31 | * See README.txt for usage instructions. 32 | */ 33 | 34 | #ifndef MBEDTLS_CONFIG_H 35 | #define MBEDTLS_CONFIG_H 36 | 37 | /* System support */ 38 | #define MBEDTLS_HAVE_ASM 39 | 40 | /* mbed TLS feature support */ 41 | #define MBEDTLS_AES_ROM_TABLES 42 | #define MBEDTLS_ECP_DP_SECP256R1_ENABLED 43 | #define MBEDTLS_ECP_NIST_OPTIM 44 | #define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED 45 | #define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 46 | #define MBEDTLS_SSL_PROTO_TLS1_2 47 | #define MBEDTLS_SSL_PROTO_DTLS 48 | #define MBEDTLS_SSL_DTLS_ANTI_REPLAY 49 | #define MBEDTLS_SSL_DTLS_HELLO_VERIFY 50 | #define MBEDTLS_SSL_EXPORT_KEYS 51 | 52 | /* mbed TLS modules */ 53 | #define MBEDTLS_AES_C 54 | #define MBEDTLS_ASN1_PARSE_C 55 | #define MBEDTLS_ASN1_WRITE_C 56 | #define MBEDTLS_BIGNUM_C 57 | #define MBEDTLS_CCM_C 58 | #define MBEDTLS_CIPHER_C 59 | #define MBEDTLS_CTR_DRBG_C 60 | #define MBEDTLS_CMAC_C 61 | #define MBEDTLS_ECJPAKE_C 62 | #define MBEDTLS_ECP_C 63 | #define MBEDTLS_ENTROPY_C 64 | #define MBEDTLS_HMAC_DRBG_C 65 | #define MBEDTLS_MD_C 66 | #define MBEDTLS_OID_C 67 | #define MBEDTLS_PK_C 68 | #define MBEDTLS_PK_PARSE_C 69 | #define MBEDTLS_SHA256_C 70 | #define MBEDTLS_SSL_COOKIE_C 71 | #define MBEDTLS_SSL_CLI_C 72 | #define MBEDTLS_SSL_SRV_C 73 | #define MBEDTLS_SSL_TLS_C 74 | 75 | /* For tests using ssl-opt.sh */ 76 | #define MBEDTLS_NET_C 77 | #define MBEDTLS_TIMING_C 78 | 79 | /* Save RAM at the expense of ROM */ 80 | #define MBEDTLS_AES_ROM_TABLES 81 | 82 | /* Save RAM by adjusting to our exact needs */ 83 | #define MBEDTLS_ECP_MAX_BITS 256 84 | #define MBEDTLS_MPI_MAX_SIZE 32 // 256 bits is 32 bytes 85 | 86 | /* Save ROM and a few bytes of RAM by specifying our own ciphersuite list */ 87 | #define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 88 | 89 | #include "mbedtls/check_config.h" 90 | 91 | #endif /* MBEDTLS_CONFIG_H */ 92 | -------------------------------------------------------------------------------- /external_libs/mbedtls/include/mbedtls/arc4.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file arc4.h 3 | * 4 | * \brief The ARCFOUR stream cipher 5 | * 6 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 7 | * SPDX-License-Identifier: Apache-2.0 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 10 | * not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 17 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * 21 | * This file is part of mbed TLS (https://tls.mbed.org) 22 | */ 23 | #ifndef MBEDTLS_ARC4_H 24 | #define MBEDTLS_ARC4_H 25 | 26 | #if !defined(MBEDTLS_CONFIG_FILE) 27 | #include "config.h" 28 | #else 29 | #include MBEDTLS_CONFIG_FILE 30 | #endif 31 | 32 | #include 33 | 34 | #if !defined(MBEDTLS_ARC4_ALT) 35 | // Regular implementation 36 | // 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /** 43 | * \brief ARC4 context structure 44 | */ 45 | typedef struct 46 | { 47 | int x; /*!< permutation index */ 48 | int y; /*!< permutation index */ 49 | unsigned char m[256]; /*!< permutation table */ 50 | } 51 | mbedtls_arc4_context; 52 | 53 | /** 54 | * \brief Initialize ARC4 context 55 | * 56 | * \param ctx ARC4 context to be initialized 57 | */ 58 | void mbedtls_arc4_init( mbedtls_arc4_context *ctx ); 59 | 60 | /** 61 | * \brief Clear ARC4 context 62 | * 63 | * \param ctx ARC4 context to be cleared 64 | */ 65 | void mbedtls_arc4_free( mbedtls_arc4_context *ctx ); 66 | 67 | /** 68 | * \brief ARC4 key schedule 69 | * 70 | * \param ctx ARC4 context to be setup 71 | * \param key the secret key 72 | * \param keylen length of the key, in bytes 73 | */ 74 | void mbedtls_arc4_setup( mbedtls_arc4_context *ctx, const unsigned char *key, 75 | unsigned int keylen ); 76 | 77 | /** 78 | * \brief ARC4 cipher function 79 | * 80 | * \param ctx ARC4 context 81 | * \param length length of the input data 82 | * \param input buffer holding the input data 83 | * \param output buffer for the output data 84 | * 85 | * \return 0 if successful 86 | */ 87 | int mbedtls_arc4_crypt( mbedtls_arc4_context *ctx, size_t length, const unsigned char *input, 88 | unsigned char *output ); 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #else /* MBEDTLS_ARC4_ALT */ 95 | #include "arc4_alt.h" 96 | #endif /* MBEDTLS_ARC4_ALT */ 97 | 98 | #ifdef __cplusplus 99 | extern "C" { 100 | #endif 101 | 102 | /** 103 | * \brief Checkup routine 104 | * 105 | * \return 0 if successful, or 1 if the test failed 106 | */ 107 | int mbedtls_arc4_self_test( int verbose ); 108 | 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | 113 | #endif /* arc4.h */ 114 | -------------------------------------------------------------------------------- /external_libs/mbedtls/include/mbedtls/base64.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file base64.h 3 | * 4 | * \brief RFC 1521 base64 encoding/decoding 5 | * 6 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 7 | * SPDX-License-Identifier: Apache-2.0 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 10 | * not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 17 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * 21 | * This file is part of mbed TLS (https://tls.mbed.org) 22 | */ 23 | #ifndef MBEDTLS_BASE64_H 24 | #define MBEDTLS_BASE64_H 25 | 26 | #include 27 | 28 | #define MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL -0x002A /**< Output buffer too small. */ 29 | #define MBEDTLS_ERR_BASE64_INVALID_CHARACTER -0x002C /**< Invalid character in input. */ 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /** 36 | * \brief Encode a buffer into base64 format 37 | * 38 | * \param dst destination buffer 39 | * \param dlen size of the destination buffer 40 | * \param olen number of bytes written 41 | * \param src source buffer 42 | * \param slen amount of data to be encoded 43 | * 44 | * \return 0 if successful, or MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL. 45 | * *olen is always updated to reflect the amount 46 | * of data that has (or would have) been written. 47 | * If that length cannot be represented, then no data is 48 | * written to the buffer and *olen is set to the maximum 49 | * length representable as a size_t. 50 | * 51 | * \note Call this function with dlen = 0 to obtain the 52 | * required buffer size in *olen 53 | */ 54 | int mbedtls_base64_encode( unsigned char *dst, size_t dlen, size_t *olen, 55 | const unsigned char *src, size_t slen ); 56 | 57 | /** 58 | * \brief Decode a base64-formatted buffer 59 | * 60 | * \param dst destination buffer (can be NULL for checking size) 61 | * \param dlen size of the destination buffer 62 | * \param olen number of bytes written 63 | * \param src source buffer 64 | * \param slen amount of data to be decoded 65 | * 66 | * \return 0 if successful, MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL, or 67 | * MBEDTLS_ERR_BASE64_INVALID_CHARACTER if the input data is 68 | * not correct. *olen is always updated to reflect the amount 69 | * of data that has (or would have) been written. 70 | * 71 | * \note Call this function with *dst = NULL or dlen = 0 to obtain 72 | * the required buffer size in *olen 73 | */ 74 | int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, 75 | const unsigned char *src, size_t slen ); 76 | 77 | /** 78 | * \brief Checkup routine 79 | * 80 | * \return 0 if successful, or 1 if the test failed 81 | */ 82 | int mbedtls_base64_self_test( int verbose ); 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif /* base64.h */ 89 | -------------------------------------------------------------------------------- /external_libs/mbedtls/include/mbedtls/havege.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file havege.h 3 | * 4 | * \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion 5 | * 6 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 7 | * SPDX-License-Identifier: Apache-2.0 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 10 | * not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 17 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * 21 | * This file is part of mbed TLS (https://tls.mbed.org) 22 | */ 23 | #ifndef MBEDTLS_HAVEGE_H 24 | #define MBEDTLS_HAVEGE_H 25 | 26 | #include 27 | 28 | #define MBEDTLS_HAVEGE_COLLECT_SIZE 1024 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /** 35 | * \brief HAVEGE state structure 36 | */ 37 | typedef struct 38 | { 39 | int PT1, PT2, offset[2]; 40 | int pool[MBEDTLS_HAVEGE_COLLECT_SIZE]; 41 | int WALK[8192]; 42 | } 43 | mbedtls_havege_state; 44 | 45 | /** 46 | * \brief HAVEGE initialization 47 | * 48 | * \param hs HAVEGE state to be initialized 49 | */ 50 | void mbedtls_havege_init( mbedtls_havege_state *hs ); 51 | 52 | /** 53 | * \brief Clear HAVEGE state 54 | * 55 | * \param hs HAVEGE state to be cleared 56 | */ 57 | void mbedtls_havege_free( mbedtls_havege_state *hs ); 58 | 59 | /** 60 | * \brief HAVEGE rand function 61 | * 62 | * \param p_rng A HAVEGE state 63 | * \param output Buffer to fill 64 | * \param len Length of buffer 65 | * 66 | * \return 0 67 | */ 68 | int mbedtls_havege_random( void *p_rng, unsigned char *output, size_t len ); 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | #endif /* havege.h */ 75 | -------------------------------------------------------------------------------- /external_libs/mbedtls/include/mbedtls/net.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file net.h 3 | * 4 | * \brief Deprecated header file that includes mbedtls/net_sockets.h 5 | * 6 | * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved 7 | * SPDX-License-Identifier: Apache-2.0 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 10 | * not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 17 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * 21 | * This file is part of mbed TLS (https://tls.mbed.org) 22 | * 23 | * \deprecated Superseded by mbedtls/net_sockets.h 24 | */ 25 | 26 | #if !defined(MBEDTLS_DEPRECATED_REMOVED) 27 | #include "mbedtls/net_sockets.h" 28 | #if defined(MBEDTLS_DEPRECATED_WARNING) 29 | #warning "Deprecated header file: Superseded by mbedtls/net_sockets.h" 30 | #endif /* MBEDTLS_DEPRECATED_WARNING */ 31 | #endif /* !MBEDTLS_DEPRECATED_REMOVED */ 32 | -------------------------------------------------------------------------------- /external_libs/mbedtls/include/mbedtls/platform_time.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file platform_time.h 3 | * 4 | * \brief mbed TLS Platform time abstraction 5 | * 6 | * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved 7 | * SPDX-License-Identifier: Apache-2.0 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 10 | * not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 17 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * 21 | * This file is part of mbed TLS (https://tls.mbed.org) 22 | */ 23 | #ifndef MBEDTLS_PLATFORM_TIME_H 24 | #define MBEDTLS_PLATFORM_TIME_H 25 | 26 | #if !defined(MBEDTLS_CONFIG_FILE) 27 | #include "config.h" 28 | #else 29 | #include MBEDTLS_CONFIG_FILE 30 | #endif 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /** 37 | * \name SECTION: Module settings 38 | * 39 | * The configuration options you can set for this module are in this section. 40 | * Either change them in config.h or define them on the compiler command line. 41 | * \{ 42 | */ 43 | 44 | /* 45 | * The time_t datatype 46 | */ 47 | #if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) 48 | typedef MBEDTLS_PLATFORM_TIME_TYPE_MACRO mbedtls_time_t; 49 | #else 50 | /* For time_t */ 51 | #include 52 | typedef time_t mbedtls_time_t; 53 | #endif /* MBEDTLS_PLATFORM_TIME_TYPE_MACRO */ 54 | 55 | /* 56 | * The function pointers for time 57 | */ 58 | #if defined(MBEDTLS_PLATFORM_TIME_ALT) 59 | extern mbedtls_time_t (*mbedtls_time)( mbedtls_time_t* time ); 60 | 61 | /** 62 | * \brief Set your own time function pointer 63 | * 64 | * \param time_func the time function implementation 65 | * 66 | * \return 0 67 | */ 68 | int mbedtls_platform_set_time( mbedtls_time_t (*time_func)( mbedtls_time_t* time ) ); 69 | #else 70 | #if defined(MBEDTLS_PLATFORM_TIME_MACRO) 71 | #define mbedtls_time MBEDTLS_PLATFORM_TIME_MACRO 72 | #else 73 | #define mbedtls_time time 74 | #endif /* MBEDTLS_PLATFORM_TIME_MACRO */ 75 | #endif /* MBEDTLS_PLATFORM_TIME_ALT */ 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif /* platform_time.h */ 82 | -------------------------------------------------------------------------------- /external_libs/mbedtls/library/version.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Version information 3 | * 4 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 5 | * SPDX-License-Identifier: Apache-2.0 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 8 | * not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 15 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * This file is part of mbed TLS (https://tls.mbed.org) 20 | */ 21 | 22 | #if !defined(MBEDTLS_CONFIG_FILE) 23 | #include "mbedtls/config.h" 24 | #else 25 | #include MBEDTLS_CONFIG_FILE 26 | #endif 27 | 28 | #if defined(MBEDTLS_VERSION_C) 29 | 30 | #include "mbedtls/version.h" 31 | #include 32 | 33 | unsigned int mbedtls_version_get_number() 34 | { 35 | return ( MBEDTLS_VERSION_NUMBER ); 36 | } 37 | 38 | void mbedtls_version_get_string( char *string ) 39 | { 40 | memcpy( string, MBEDTLS_VERSION_STRING, 41 | sizeof( MBEDTLS_VERSION_STRING ) ); 42 | } 43 | 44 | void mbedtls_version_get_string_full( char *string ) 45 | { 46 | memcpy( string, MBEDTLS_VERSION_STRING_FULL, 47 | sizeof( MBEDTLS_VERSION_STRING_FULL ) ); 48 | } 49 | 50 | #endif /* MBEDTLS_VERSION_C */ 51 | -------------------------------------------------------------------------------- /include/config.h: -------------------------------------------------------------------------------- 1 | /* #undef AUTH_MODE_CERT */ 2 | #define AUTH_MODE_KEY 3 | #define AUTH_WITH_NOTLS 4 | #define GATEWAY_ENABLED 5 | #define GATEWAY_AUTOMATION_ENABLED 6 | #define GATEWAY_SCENE_ENABLED 7 | #define GATEWAY_GROUP_ENABLED 8 | /* #undef COAP_COMM_ENABLED */ 9 | #define OTA_MQTT_CHANNEL 10 | /* #undef SYSTEM_COMM */ 11 | /* #undef EVENT_POST_ENABLED */ 12 | #define ACTION_ENABLED 13 | #define DEV_DYN_REG_ENABLED 14 | /* #undef LOG_UPLOAD */ 15 | /* #undef IOT_DEBUG */ 16 | /* #undef DEBUG_DEV_INFO_USED */ 17 | /* #undef AT_TCP_ENABLED */ 18 | /* #undef AT_UART_RECV_IRQ */ 19 | /* #undef AT_OS_USED */ 20 | /* #undef AT_DEBUG */ 21 | /* #undef OTA_USE_HTTPS */ 22 | #define GATEWAY_ENABLED 23 | /* #undef MULTITHREAD_ENABLED */ 24 | /* #undef GATEWAY_DYN_BIND_SUBDEV_ENABLED */ 25 | /* #undef ASR_ENABLED */ 26 | #define RESOURCE_UPDATE_ENABLED 27 | /* #undef WIFI_CONFIG_ENABLED */ 28 | #define KGMUSIC_ENABLED 29 | #define QQMUSIC_ENABLED 30 | -------------------------------------------------------------------------------- /include/exports/qcloud_iot_export_device_bind.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making IoT Hub available. 3 | * Copyright(C) 2018 - 2021 THL A29 Limited, a Tencent company.All rights reserved. 4 | * 5 | * Licensed under the MIT License(the "License"); you may not use this file except in 6 | * compliance with the License. You may obtain a copy of the License at 7 | * http://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is 10 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 11 | * either express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | #ifndef QLCOUD_IOT_EXPORT_DEVICE_BIND_H_ 16 | #define QLCOUD_IOT_EXPORT_DEVICE_BIND_H_ 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #include "qcloud_iot_export.h" 23 | 24 | /** 25 | * @brief Register a callback function to receive the device unbinding message 26 | * sent by the platform. 27 | * before use it you must call qcloud_service_mqtt_init() to sub service topic 28 | * 29 | * @param callback [in] a callback function 30 | * @param context [in] the program context 31 | * @return QCLOUD_RET_SUCCESS for success, or err code for failure 32 | */ 33 | int IOT_Unbind_Device_Register(void *callback, void *context); 34 | /** 35 | * @brief Register a callback function to receive the device unbinding message 36 | * sent by the platform 37 | * 38 | * @param mqtt_client the mqtt client 39 | * @param callback [in] a callback function 40 | * @param context [in] the program context 41 | * @return QCLOUD_RET_SUCCESS for success, or err code for failure 42 | */ 43 | int IOT_Unbind_Device_ByCloud(void *mqtt_client, void *callback, void *context); 44 | /** 45 | * @brief Actively initiate a request to unbind the device to the platform 46 | * 47 | * @param mqtt_client the mqtt client 48 | * @param timeout_ms timeout value (unit: ms) for this operation 49 | * @return QCLOUD_RET_SUCCESS for success, or err code for failure 50 | */ 51 | int IOT_Unbind_Device_Request(void *mqtt_client, int timeout_ms); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | #endif // QLCOUD_IOT_EXPORT_DEVICE_BIND_H_ -------------------------------------------------------------------------------- /include/exports/qcloud_iot_export_dynreg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef QLCOUD_IOT_EXPORT_DYNREG_H_ 22 | #define QLCOUD_IOT_EXPORT_DYNREG_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include "qcloud_iot_export.h" 29 | 30 | /** 31 | * @brief Do dynamic register/create device 32 | * 33 | * @param pDevInfo In: device info with [ProductId, ProductKey, DeviceName] 34 | * Out: device info with [ProductId, DeviceName, 35 | * DeviceSecret or Device cert/key file] 36 | * 37 | * @return QCLOUD_RET_SUCCESS for success, or err code for failure 38 | */ 39 | int IOT_DynReg_Device(DeviceInfo *pDevInfo); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif // QLCOUD_IOT_EXPORT_DYNREG_H_ -------------------------------------------------------------------------------- /include/exports/qcloud_iot_export_location.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making IoT Hub available. 3 | * Copyright(C) 2018 - 2021 THL A29 Limited, a Tencent company.All rights reserved. 4 | * 5 | * Licensed under the MIT License(the "License"); you may not use this file except in 6 | * compliance with the License. You may obtain a copy of the License at 7 | * http://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is 10 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 11 | * either express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | #ifndef QLCOUD_IOT_EXPORT_LOCATION_H_ 16 | #define QLCOUD_IOT_EXPORT_LOCATION_H_ 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #include "qcloud_iot_export.h" 23 | 24 | /** 25 | * @brief Register a callback function to receive the electric fence aleart 26 | * sent by the platform 27 | * 28 | * @param mqtt_client the mqtt client 29 | * @param callback [in] a callback function 30 | * @param context [in] the program context 31 | * @return QCLOUD_RET_SUCCESS for success, or err code for failure 32 | */ 33 | int IOT_Location_Capture_Fence_Aleart_Register(void *mqtt_client, void *callback, void *context); 34 | /** 35 | * @brief 36 | * 37 | * @param mqtt_client the mqtt client 38 | * @param client_token reply client token 39 | * @param reply_code 0 is success 40 | * @param reply_msg success or others 41 | * @return QCLOUD_RET_SUCCESS for success, or err code for failure 42 | */ 43 | int IOT_Location_Fence_Aleart_Reply(void *mqtt_client, char *client_token, int reply_code, char *reply_msg); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif // QLCOUD_IOT_EXPORT_DEVICE_BIND_H_ -------------------------------------------------------------------------------- /include/exports/qcloud_iot_export_qqmusic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef QCLOUD_IOT_EXPORT_QQMUSIC_H_ 22 | #define QCLOUD_IOT_EXPORT_QQMUSIC_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include "utils_list.h" 29 | 30 | #define QQMUSIC_SONG_URL_SIZE (512) 31 | #define QQMUSIC_SONG_NAME_SIZE (128) 32 | #define QQMUSIC_SONG_SINGER_NAME_SIZE (128) 33 | #define QQMUSIC_SONG_LIST_STR_SIZE (2048) 34 | 35 | typedef enum { 36 | QQMUSIC_GET_CURRENT_SONG = 0, 37 | QQMUSIC_GET_PREVIOUS_SONG = 1, 38 | QQMUSIC_GET_NEXT_SONG = 2, 39 | QQMUSIC_GET_RANDOM_SONG = 3, 40 | QQMUSIC_GET_NONE, 41 | } QQMusicGetSongInfoType; 42 | 43 | typedef struct { 44 | int userOwnRule; 45 | uint64_t songId; 46 | int songPlayTime; 47 | char songUrl[QQMUSIC_SONG_URL_SIZE]; 48 | char songName[QQMUSIC_SONG_NAME_SIZE]; 49 | char singerName[QQMUSIC_SONG_SINGER_NAME_SIZE]; 50 | } QQMusicSongInfo; 51 | 52 | typedef struct { 53 | void (*sync_song_list_callback)(char *song_list_str, int song_list_len); 54 | void (*play_song_in_song_list)(uint32_t song_id); 55 | } QQMusicCallback; 56 | 57 | /** 58 | * @brief Initialize the QQMusic module. 59 | * 60 | * @param mqtt_client 61 | * @param qq_music @see QCloudIoTQQMusic 62 | * @return int 0: success, other: fail 63 | */ 64 | int IOT_QQMusic_Enable(void *mqtt_client, QQMusicCallback callback, void **qq_music); 65 | 66 | /** 67 | * @brief Deinitialize the QQMusic module. 68 | * 69 | * @param qq_music @see QCloudIoTQQMusic 70 | */ 71 | void IOT_QQMusic_Disable(void **qq_music); 72 | 73 | /** 74 | * @brief Get the current playing song. 75 | * 76 | * @param type @see QQMusicGetSongInfoType 77 | * @param qq_music @see QCloudIoTQQMusic 78 | * @return QQMusicSongInfo or NULL 79 | */ 80 | QQMusicSongInfo *IOT_QQMusic_GetPlaySongInfo(uint64_t song_id, QQMusicGetSongInfoType type, void *qq_music); 81 | 82 | QQMusicSongInfo *IOT_QQMusic_GetSongInfoFromCloud(void *qq_music, uint64_t song_id, int quality, char *token, 83 | int timeout_ms); 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif /* QCLOUD_IOT_EXPORT_QQMUSIC_H_ */ -------------------------------------------------------------------------------- /include/exports/qcloud_iot_export_system.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef QCLOUD_IOT_EXPORT_SYSTEM_H_ 22 | #define QCLOUD_IOT_EXPORT_SYSTEM_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #define IP_MAX_NUM 10 29 | #define ONE_IP_MAX_LEN 24 30 | 31 | typedef enum { 32 | eRESOURCE_TIME = 0, 33 | eRESOURCE_IP, 34 | } eSysResourcType; 35 | 36 | /** 37 | * @brief Get domain ip list for dns disaster recovery 38 | * 39 | * @param pClient MQTTClient pointer 40 | * @param eType type of sys resource to get 41 | * @param usrArg usr arg to return the target resource 42 | * @return QCLOUD_RET_SUCCESS for success 43 | * otherwise, failure 44 | */ 45 | int IOT_Get_Sys_Resource(void *pClient, eSysResourcType eType, DeviceInfo *pDevInfo, void *usrArg); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* QCLOUD_IOT_EXPORT_COAP_H_ */ -------------------------------------------------------------------------------- /include/gitinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef __GIT_INFO_H_ 2 | #define __GIT_INFO_H_ 3 | #define GIT_COMMIT_ID "77c26bdb692c2fed2f5acf68027614992d8d6266" 4 | #endif 5 | -------------------------------------------------------------------------------- /include/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef PLATFORM_H_ 22 | #define PLATFORM_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #ifndef PATH_MAX 29 | #define PATH_MAX 4096 30 | #endif 31 | /* Max size of cert/key file full path */ 32 | #define FILE_PATH_MAX_LEN 256 33 | 34 | #ifdef WIN32 35 | #include 36 | #include 37 | #include 38 | typedef unsigned long ssize_t; 39 | #define getcwd(buffer, len) _getcwd(buffer, len) 40 | #endif 41 | 42 | #if defined(__linux__) 43 | #include 44 | #include 45 | //#include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | 53 | #endif 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif /* PLATFORM_H_ */ 60 | -------------------------------------------------------------------------------- /include/qcloud_iot_export_variables.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef QCLOUD_IOT_EXPORT_VARIABLES_H_ 22 | #define QCLOUD_IOT_EXPORT_VARIABLES_H_ 23 | 24 | /* 25 | * Below variables are dependant on user situation (network status/device 26 | * memory/application context) 27 | * Adjust the default value to meet your requirement 28 | */ 29 | 30 | /* default MQTT/CoAP timeout value when connect/pub/sub (unit: ms) */ 31 | #define QCLOUD_IOT_MQTT_COMMAND_TIMEOUT (5 * 1000) 32 | 33 | /* default MQTT keep alive interval, in case of celular work, 60 * 1000 recommended (unit: ms) */ 34 | #define QCLOUD_IOT_MQTT_KEEP_ALIVE_INTERNAL (120 * 1000) 35 | 36 | /* default MQTT Tx buffer size, MAX: 16*1024 */ 37 | #define QCLOUD_IOT_MQTT_TX_BUF_LEN (2048) 38 | 39 | /* default MQTT Rx buffer size, MAX: 16*1024 */ 40 | #define QCLOUD_IOT_MQTT_RX_BUF_LEN (2048) 41 | 42 | /* default COAP Tx buffer size, MAX: 1*1024 */ 43 | #define COAP_SENDMSG_MAX_BUFLEN (512) 44 | 45 | /* default COAP Rx buffer size, MAX: 1*1024 */ 46 | #define COAP_RECVMSG_MAX_BUFLEN (512) 47 | 48 | /* MAX MQTT reconnect interval (unit: ms) */ 49 | #define MAX_RECONNECT_WAIT_INTERVAL (60 * 1000) 50 | 51 | /* MAX valid time when connect to MQTT server. 0: always valid */ 52 | /* Use this only if the device has accurate UTC time. Otherwise, set to 0 */ 53 | #define MAX_ACCESS_EXPIRE_TIMEOUT (0) 54 | 55 | /* log print/upload related variables */ 56 | /* MAX size of log buffer for one log item including header and content */ 57 | #define MAX_LOG_MSG_LEN (511) 58 | 59 | #if defined(__linux__) 60 | #undef MAX_LOG_MSG_LEN 61 | #define MAX_LOG_MSG_LEN (1023) 62 | #endif 63 | 64 | /* 65 | * Log upload related params, which will affect the size of device memory/disk 66 | * consumption 67 | * the default value can be changed for different user situation 68 | */ 69 | // size of buffer for log upload 70 | #define LOG_UPLOAD_BUFFER_SIZE 5000 71 | 72 | // Max size of one http log upload. Should not larger than 5000 73 | #define MAX_HTTP_LOG_POST_SIZE 3000 74 | 75 | // MAX size for saving log into NVS (files/FLASH) after upload fail 76 | #define MAX_LOG_SAVE_SIZE (3 * LOG_UPLOAD_BUFFER_SIZE) 77 | 78 | // interval of log upload (unit: ms) Decrease this value if 79 | // LOG_UPLOAD_BUFFER_SIZE is small 80 | #define LOG_UPLOAD_INTERVAL_MS 2000 81 | 82 | #endif /* QCLOUD_IOT_EXPORT_VARIABLES_H_ */ 83 | -------------------------------------------------------------------------------- /include/utils_getopt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights 5 | reserved. 6 | 7 | * Licensed under the MIT License (the "License"); you may not use this file 8 | except in 9 | * compliance with the License. You may obtain a copy of the License at 10 | * http://opensource.org/licenses/MIT 11 | 12 | * Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is 14 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, 16 | * either express or implied. See the License for the specific language 17 | governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | 22 | #ifndef __UTILS_GETOPT_H__ 23 | #define __UTILS_GETOPT_H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | extern char *utils_optarg; /* pointer to argument of current option */ 30 | int utils_getopt(int nargc, char *const *nargv, const char *options); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /make.settings: -------------------------------------------------------------------------------- 1 | # 编译类型: release/debug 2 | BUILD_TYPE = release 3 | # Makefile编译打印 echo 4 | DEBUG_MAKEFILE = n 5 | 6 | # 编译工具链 7 | PLATFORM_CC = gcc 8 | PLATFORM_AR = ar 9 | PLATFORM_OS = linux 10 | PLATFORM_SSL = mbedtls 11 | PLATFORM_AT_DEV = esp8266 12 | 13 | # 交叉编译工具链示例 14 | # PLATFORM_CC = /opt/openwrt/packages/toolchain/mipsel-linux-gcc 15 | # PLATFORM_AR = /opt/openwrt/packages/toolchain/mipsel-linux-ar 16 | # PLATFORM_CC = armcc 17 | # PLATFORM_AR = armar 18 | 19 | # 是否打开MQTT通道的总开关 20 | FEATURE_MQTT_COMM_ENABLED = y 21 | 22 | # 是否打开网关功能 23 | FEATURE_GATEWAY_ENABLED = n 24 | 25 | # 是否使能网关子设备动态绑定解绑功能 26 | FEATURE_GATEWAY_DYN_BIND_SUBDEV_ENABLED = n 27 | 28 | # 是否使能网关本地联动功能 29 | FEATURE_GATEWAY_AUTOMATION_ENABLED = n 30 | 31 | # 是否使能多线程 32 | FEATURE_MULTITHREAD_ENABLED = n 33 | 34 | # 是否使能设备动态注册 35 | FEATURE_DEV_DYN_REG_ENABLED = y 36 | 37 | # 是否打开OTA固件升级总开关 38 | FEATURE_OTA_COMM_ENABLED = y 39 | 40 | # 是否打开资源管理总开关 41 | FEATURE_RESOURCE_UPDATE_ENABLED = y 42 | 43 | # 是否打开文件管理总开关 44 | FEATURE_FILE_MANAGE_ENABLED = y 45 | 46 | # 是否使能语音识别功能 47 | FEATURE_ASR_ENABLED = y 48 | 49 | # 是否使用HTTPS下载固件 50 | FEATURE_OTA_USE_HTTPS = y 51 | 52 | # 接入认证方式,使用证书认证:CERT;使用密钥认证:KEY 53 | FEATURE_AUTH_MODE = KEY 54 | 55 | # 接入认证是否不使用TLS,证书方式必须选择使用TLS,密钥认证可选择不使用TLS 56 | FEATURE_AUTH_WITH_NOTLS = n 57 | 58 | # 是否打开数据模板功能 59 | FEATURE_DATA_TEMPLATE_ENABLED = y 60 | 61 | # 是否打开数据模板事件上报功能 62 | FEATURE_EVENT_POST_ENABLED = n 63 | 64 | # 是否打开数据模板行为功能 65 | FEATURE_ACTION_ENABLED = n 66 | 67 | # 是否打开获取iot后台时间功能 68 | FEATURE_SYSTEM_COMM_ENABLED = n 69 | 70 | # 是否打开日志上报云端功能 71 | FEATURE_LOG_UPLOAD_ENABLED = n 72 | 73 | # 是否打开代码中获取设备信息功能,OFF时将从device_info.json中读取设备信息 74 | FEATURE_DEBUG_DEV_INFO_USED = n 75 | 76 | # 是否使用AT方式实现TCP通信 77 | FEATURE_AT_TCP_ENABLED = n 78 | 79 | # 是否打开AT模组中断接收功能 80 | FEATURE_AT_UART_RECV_IRQ = y 81 | 82 | # 是否打开AT模组多线程功能 83 | FEATURE_AT_OS_USED = y 84 | 85 | # 是否打开AT模组调试功能 86 | FEATURE_AT_DEBUG = y 87 | 88 | # 是否打开WIFI配网功能 89 | FEATURE_WIFI_CONFIG_ENABLED = n 90 | 91 | # 是否打开酷狗音乐功能 92 | FEATURE_KGMUSIC_ENABLED = y 93 | 94 | # 是否打开QQ音乐功能 95 | FEATURE_QQMUSIC_ENABLED = y 96 | 97 | # 是否打开位置功能 98 | FEATURE_LOCATION_ENABLED = y -------------------------------------------------------------------------------- /platform/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # src platform 2 | file(GLOB src_os ./os/${PLATFORM}/*.c ) 3 | set(src_platform ${src_os}) 4 | 5 | if(${FEATURE_AUTH_WITH_NOTLS} STREQUAL "OFF") 6 | file(GLOB src_platform_tls ./tls/mbedtls/*.c) 7 | list(APPEND src_platform ${src_platform_tls}) 8 | endif() 9 | 10 | if(AT_TCP_ENABLED STREQUAL "OFF") 11 | file(GLOB src_os ./os/${PLATFORM}/HAL_AT*.c) 12 | list(REMOVE_ITEM src_platform ${src_os}) 13 | endif() 14 | 15 | if(${EXTRACT_SRC} STREQUAL "ON") 16 | file(COPY ${src_platform} DESTINATION ${PROJECT_SOURCE_DIR}/output/qcloud_iot_c_sdk/platform/) 17 | endif() 18 | 19 | # src at_device 20 | if(AT_TCP_ENABLED STREQUAL "ON") 21 | file(GLOB src_at_device ./at_device/${AT_DEVICE_NAME}/*.c) 22 | endif() 23 | 24 | if(AT_TCP_ENABLED STREQUAL "ON" AND ${EXTRACT_SRC} STREQUAL "ON") 25 | file(COPY ${src_at_device} DESTINATION ${PROJECT_SOURCE_DIR}/output/qcloud_iot_c_sdk/platform/) 26 | endif() 27 | 28 | # target 29 | set(platform_target "iot_platform") 30 | 31 | if(FEATURE_WIFI_CONFIG_ENABLED STREQUAL "ON") 32 | file(GLOB src_wifi_config_adapter ./wifi_config_adapter/*.c) 33 | list(APPEND src_wifi_config_adapter ${src_platform_tls}) 34 | if(${EXTRACT_SRC} STREQUAL "ON") 35 | file(COPY ${src_wifi_config_adapter} DESTINATION ${PROJECT_SOURCE_DIR}/output/qcloud_iot_c_sdk/platform/) 36 | endif() 37 | endif() 38 | 39 | list(APPEND src_platform ${src_wifi_config_adapter}) 40 | 41 | # add library 42 | SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/output/${BUILD_TYPE}/lib/) 43 | if(AT_TCP_ENABLED STREQUAL "ON") 44 | add_library(${platform_target} STATIC ${src_platform} ${src_at_device}) 45 | else() 46 | add_library(${platform_target} STATIC ${src_platform}) 47 | endif() 48 | -------------------------------------------------------------------------------- /platform/at_device/esp8266/at_device_esp8266.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef __AT_DEVICE_ESP8266_H__ 22 | #define __AT_DEVICE_ESP8266_H__ 23 | 24 | #define AT_RESP_TIMEOUT_MS (5000) 25 | #define ESP8266_SEND_MAX_LEN_ONCE (2048) 26 | #define ESP8266_MAX_SOCKET_NUM (5) 27 | 28 | int at_device_esp8266_init(void); 29 | 30 | #endif /* __AT_DEVICE_ESP8266_H__ */ 31 | -------------------------------------------------------------------------------- /platform/os/freertos/HAL_AT_UART_freertos.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights 5 | reserved. 6 | 7 | * Licensed under the MIT License (the "License"); you may not use this file 8 | except in 9 | * compliance with the License. You may obtain a copy of the License at 10 | * http://opensource.org/licenses/MIT 11 | 12 | * Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is 14 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, 16 | * either express or implied. See the License for the specific language 17 | governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | #include "qcloud_iot_export.h" 22 | #include "qcloud_iot_import.h" 23 | 24 | #ifdef AT_TCP_ENABLED 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "at_client.h" 32 | #include "stm32l4xx_hal.h" 33 | #include "utils_ringbuff.h" 34 | 35 | #define HAL_AT_UART_IRQHandler USART1_IRQHandler 36 | extern UART_HandleTypeDef huart1; 37 | static UART_HandleTypeDef *pAtUart = &huart1; 38 | 39 | extern void AT_Uart_Init(void); 40 | extern void at_client_uart_rx_isr_cb(uint8_t *pdata, uint8_t len); 41 | 42 | #include "board.h" 43 | /** 44 | * @brief This function handles AT UART global interrupt,push recv char to 45 | * ringbuff. 46 | */ 47 | void HAL_AT_UART_IRQHandler(void) 48 | { 49 | uint8_t ch; 50 | if (__HAL_UART_GET_FLAG(pAtUart, UART_FLAG_RXNE) == SET) { 51 | ch = (uint8_t)READ_REG(pAtUart->Instance->RDR) & 0xFF; 52 | /*this callback for at_client*/ 53 | at_client_uart_rx_isr_cb(&ch, 1); 54 | HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin); 55 | } 56 | __HAL_UART_CLEAR_PEFLAG(pAtUart); 57 | } 58 | 59 | /** 60 | *pdata: pointer of data for send 61 | *len: len of data to be sent 62 | *return: the len of data send success 63 | * @brief hal api for at data send 64 | */ 65 | int HAL_AT_Uart_Send(void *data, uint32_t size) 66 | { 67 | if (HAL_OK == HAL_UART_Transmit(pAtUart, data, size, 0xFFFF)) { 68 | return size; 69 | } else { 70 | return 0; 71 | } 72 | } 73 | 74 | int HAL_AT_Uart_Init(void) 75 | { 76 | AT_Uart_Init(); 77 | return QCLOUD_RET_SUCCESS; 78 | } 79 | 80 | int HAL_AT_Uart_Deinit(void) 81 | { 82 | return QCLOUD_RET_SUCCESS; 83 | } 84 | #endif 85 | -------------------------------------------------------------------------------- /platform/os/freertos/HAL_Music_freertos.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file HAL_Music_freertos.c 3 | * @author {hubert} ({hubertxxu@tencent.com}) 4 | * @brief 5 | * @version 1.0 6 | * @date 2024-01-17 7 | * 8 | * @copyright 9 | * 10 | * Tencent is pleased to support the open source community by making IoT Hub available. 11 | * Copyright(C) 2018 - 2024 THL A29 Limited, a Tencent company.All rights reserved. 12 | * 13 | * Licensed under the MIT License(the "License"); you may not use this file except in 14 | * compliance with the License. You may obtain a copy of the License at 15 | * http://opensource.org/licenses/MIT 16 | * 17 | * Unless required by applicable law or agreed to in writing, software distributed under the License is 18 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 19 | * either express or implied. See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * 22 | * @par Change Log: 23 | * 24 | * Date Version Author Description 25 | * 2024-01-17 1.0 hubertxxu first commit 26 | *
27 | */ 28 | 29 | #include "qcloud_iot_import.h" 30 | #include "qcloud_iot_export.h" 31 | 32 | #ifdef QQMUSIC_ENABLED 33 | 34 | int HAL_Music_Play(void **player, const char *url, int duration) 35 | { 36 | return 0; 37 | } 38 | 39 | int HAL_Music_Stop(void **player) 40 | { 41 | POINTER_SANITY_CHECK(*player, QCLOUD_ERR_INVAL); 42 | return 0; 43 | } 44 | 45 | bool HAL_Music_PlayPause(void *player, uint8_t playPause) 46 | { 47 | POINTER_SANITY_CHECK(player, false); 48 | return false; 49 | } 50 | 51 | int HAL_Music_SetVolume(void *player, int volume) 52 | { 53 | POINTER_SANITY_CHECK(player, -1); 54 | return 0; 55 | } 56 | 57 | int HAL_Music_GetVolume(void *player) 58 | { 59 | POINTER_SANITY_CHECK(player, -1); 60 | return 0; 61 | } 62 | 63 | bool HAL_Music_PlayEndCheck(void *player) 64 | { 65 | POINTER_SANITY_CHECK(player, true); 66 | return 0; 67 | } 68 | 69 | int HAL_Music_GetPlayPosition(void *player) 70 | { 71 | POINTER_SANITY_CHECK(player, -1); 72 | return 0; 73 | } 74 | 75 | int HAL_Music_SetPlayPosition(void *player, int position) 76 | { 77 | POINTER_SANITY_CHECK(player, -1); 78 | 79 | return 0; 80 | } 81 | 82 | #endif // QQMUSIC_ENABLED 83 | -------------------------------------------------------------------------------- /platform/os/freertos/HAL_Timer_freertos.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights 5 | reserved. 6 | 7 | * Licensed under the MIT License (the "License"); you may not use this file 8 | except in 9 | * compliance with the License. You may obtain a copy of the License at 10 | * http://opensource.org/licenses/MIT 11 | 12 | * Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is 14 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, 16 | * either express or implied. See the License for the specific language 17 | governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "qcloud_iot_import.h" 32 | 33 | #define PLATFORM_HAS_TIME_FUNCS 34 | //#define PLATFORM_HAS_CMSIS 35 | 36 | #ifdef PLATFORM_HAS_TIME_FUNCS 37 | #include 38 | #include 39 | #endif 40 | 41 | #ifdef PLATFORM_HAS_CMSIS 42 | #include "cmsis_os.h" 43 | #include "stm32l4xx_hal.h" 44 | #endif 45 | 46 | uint64_t HAL_GetTimeMs(void) 47 | { 48 | #if defined PLATFORM_HAS_TIME_FUNCS 49 | struct timeval tv; 50 | gettimeofday(&tv, NULL); 51 | return tv.tv_sec * 1000 + tv.tv_usec / 1000; 52 | 53 | #elif defined PLATFORM_HAS_CMSIS 54 | return HAL_GetTick(); 55 | #else 56 | return xTaskGetTickCount(); 57 | #endif 58 | } 59 | 60 | /*Get timestamp*/ 61 | long HAL_Timer_current_sec(void) 62 | { 63 | return HAL_GetTimeMs() / 1000; 64 | } 65 | 66 | char *HAL_Timer_current(char *time_str) 67 | { 68 | #if defined PLATFORM_HAS_TIME_FUNCS 69 | struct timeval tv; 70 | gettimeofday(&tv, NULL); 71 | time_t now_time = tv.tv_sec; 72 | struct tm tm_tmp = *localtime(&now_time); 73 | strftime(time_str, TIME_FORMAT_STR_LEN, "%F %T", &tm_tmp); 74 | return time_str; 75 | #else 76 | long time_sec; 77 | time_sec = HAL_Timer_current_sec(); 78 | memset(time_str, 0, TIME_FORMAT_STR_LEN); 79 | snprintf(time_str, TIME_FORMAT_STR_LEN, "%ld", time_sec); 80 | return time_str; 81 | #endif 82 | } 83 | 84 | bool HAL_Timer_expired(Timer *timer) 85 | { 86 | uint64_t now_ts; 87 | 88 | now_ts = HAL_GetTimeMs(); 89 | 90 | return (now_ts > timer->end_time) ? true : false; 91 | } 92 | 93 | void HAL_Timer_countdown_ms(Timer *timer, unsigned int timeout_ms) 94 | { 95 | timer->end_time = HAL_GetTimeMs(); 96 | timer->end_time += timeout_ms; 97 | } 98 | 99 | void HAL_Timer_countdown(Timer *timer, unsigned int timeout) 100 | { 101 | timer->end_time = HAL_GetTimeMs(); 102 | timer->end_time += timeout * 1000; 103 | } 104 | 105 | int HAL_Timer_remain(Timer *timer) 106 | { 107 | return (int)(timer->end_time - HAL_GetTimeMs()); 108 | } 109 | 110 | void HAL_Timer_init(Timer *timer) 111 | { 112 | timer->end_time = 0; 113 | } 114 | 115 | #ifdef __cplusplus 116 | } 117 | #endif 118 | -------------------------------------------------------------------------------- /platform/os/linux/HAL_File_linux.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights 5 | reserved. 6 | 7 | * Licensed under the MIT License (the "License"); you may not use this file 8 | except in 9 | * compliance with the License. You may obtain a copy of the License at 10 | * http://opensource.org/licenses/MIT 11 | 12 | * Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is 14 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, 16 | * either express or implied. See the License for the specific language 17 | governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | #include 22 | #include 23 | 24 | void *HAL_FileOpen(const char *filename, const char *mode) 25 | { 26 | return (void *)fopen(filename, mode); 27 | } 28 | 29 | size_t HAL_FileRead(void *ptr, size_t size, size_t nmemb, void *fp) 30 | { 31 | return fread(ptr, size, nmemb, (FILE *)fp); 32 | } 33 | 34 | size_t HAL_FileWrite(const void *ptr, size_t size, size_t nmemb, void *fp) 35 | { 36 | return fwrite(ptr, size, nmemb, (FILE *)fp); 37 | } 38 | 39 | int HAL_FileSeek(void *fp, long int offset, int whence) 40 | { 41 | return fseek((FILE *)fp, offset, whence); 42 | } 43 | 44 | int HAL_FileClose(void *fp) 45 | { 46 | return fclose((FILE *)fp); 47 | } 48 | 49 | int HAL_FileRemove(const char *filename) 50 | { 51 | return remove(filename); 52 | } 53 | 54 | int HAL_FileRewind(void *fp) 55 | { 56 | rewind((FILE *)fp); 57 | 58 | return 0; 59 | } 60 | 61 | long HAL_FileTell(void *fp) 62 | { 63 | return ftell((FILE *)fp); 64 | } 65 | 66 | long HAL_FileSize(void *fp) 67 | { 68 | long size = 0; 69 | 70 | fseek((FILE *)fp, 0, SEEK_END); 71 | size = ftell((FILE *)fp); 72 | rewind((FILE *)fp); 73 | 74 | return size; 75 | } 76 | 77 | char *HAL_FileGets(char *str, int n, void *fp) 78 | { 79 | return fgets(str, n, (FILE *)fp); 80 | } 81 | 82 | int HAL_FileRename(const char *old_filename, const char *new_filename) 83 | { 84 | return rename(old_filename, new_filename); 85 | } 86 | 87 | int HAL_FileEof(void *fp) 88 | { 89 | return feof((FILE *)fp); 90 | } 91 | 92 | int HAL_FileFlush(void *fp) 93 | { 94 | return fflush((FILE *)fp); 95 | } 96 | -------------------------------------------------------------------------------- /platform/os/linux/HAL_Log_linux.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights 5 | reserved. 6 | 7 | * Licensed under the MIT License (the "License"); you may not use this file 8 | except in 9 | * compliance with the License. You may obtain a copy of the License at 10 | * http://opensource.org/licenses/MIT 11 | 12 | * Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is 14 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, 16 | * either express or implied. See the License for the specific language 17 | governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | #include "qcloud_iot_export_error.h" 26 | #include "qcloud_iot_export_log.h" 27 | #include "qcloud_iot_import.h" 28 | 29 | #ifdef LOG_UPLOAD 30 | 31 | #define LOG_SAVE_FILE_PATH "upload-fail-save.log" 32 | 33 | size_t HAL_Log_Save(const char *log, size_t wLen) 34 | { 35 | FILE * fp; 36 | size_t len; 37 | 38 | if ((fp = fopen(LOG_SAVE_FILE_PATH, "a+")) == NULL) { 39 | Log_e("fail to open file %s", LOG_SAVE_FILE_PATH); 40 | return 0; 41 | } 42 | 43 | len = fwrite((void *)log, 1, wLen, fp); 44 | Log_d("write %d of %d to log file", len, wLen); 45 | 46 | fclose(fp); 47 | 48 | return len; 49 | } 50 | 51 | size_t HAL_Log_Read(char *buff, size_t rLen) 52 | { 53 | FILE * fp; 54 | size_t len; 55 | 56 | if ((fp = fopen(LOG_SAVE_FILE_PATH, "r")) == NULL) { 57 | Log_e("fail to open file %s", LOG_SAVE_FILE_PATH); 58 | return 0; 59 | } 60 | 61 | len = fread((void *)buff, 1, rLen, fp); 62 | Log_d("read %d of %d from log file", len, rLen); 63 | 64 | fclose(fp); 65 | 66 | return len; 67 | } 68 | 69 | int HAL_Log_Del(void) 70 | { 71 | return remove(LOG_SAVE_FILE_PATH); 72 | } 73 | 74 | size_t HAL_Log_Get_Size(void) 75 | { 76 | long length; 77 | FILE *fp; 78 | 79 | /* check if file exists */ 80 | if (access(LOG_SAVE_FILE_PATH, 0)) 81 | return 0; 82 | 83 | if ((fp = fopen(LOG_SAVE_FILE_PATH, "r")) == NULL) { 84 | Log_e("fail to open file %s", LOG_SAVE_FILE_PATH); 85 | return 0; 86 | } 87 | 88 | fseek(fp, 0L, SEEK_END); 89 | length = ftell(fp); 90 | fclose(fp); 91 | if (length > 0) 92 | return (size_t)length; 93 | else 94 | return 0; 95 | } 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /platform/os/linux/HAL_Timer_linux.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights 5 | reserved. 6 | 7 | * Licensed under the MIT License (the "License"); you may not use this file 8 | except in 9 | * compliance with the License. You may obtain a copy of the License at 10 | * http://opensource.org/licenses/MIT 11 | 12 | * Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is 14 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, 16 | * either express or implied. See the License for the specific language 17 | governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | #include 27 | #include 28 | 29 | #include "qcloud_iot_import.h" 30 | 31 | bool HAL_Timer_expired(Timer *timer) 32 | { 33 | struct timeval now, res; 34 | gettimeofday(&now, NULL); 35 | timersub(&timer->end_time, &now, &res); 36 | return res.tv_sec < 0 || (res.tv_sec == 0 && res.tv_usec <= 0); 37 | } 38 | 39 | void HAL_Timer_countdown_ms(Timer *timer, unsigned int timeout_ms) 40 | { 41 | struct timeval now; 42 | gettimeofday(&now, NULL); 43 | struct timeval interval = {timeout_ms / 1000, (timeout_ms % 1000) * 1000}; 44 | timeradd(&now, &interval, &timer->end_time); 45 | } 46 | 47 | void HAL_Timer_countdown(Timer *timer, unsigned int timeout) 48 | { 49 | struct timeval now; 50 | gettimeofday(&now, NULL); 51 | struct timeval interval = {timeout, 0}; 52 | timeradd(&now, &interval, &timer->end_time); 53 | } 54 | 55 | int HAL_Timer_remain(Timer *timer) 56 | { 57 | struct timeval now, res; 58 | gettimeofday(&now, NULL); 59 | timersub(&timer->end_time, &now, &res); 60 | return (res.tv_sec < 0) ? 0 : res.tv_sec * 1000 + res.tv_usec / 1000; 61 | } 62 | 63 | void HAL_Timer_init(Timer *timer) 64 | { 65 | timer->end_time = (struct timeval){0, 0}; 66 | } 67 | 68 | char *HAL_Timer_current(char *time_str) 69 | { 70 | if (time_str == NULL) 71 | return " "; 72 | 73 | struct timeval tv; 74 | gettimeofday(&tv, NULL); 75 | time_t now_time = tv.tv_sec; 76 | 77 | struct tm tm_tmp = *localtime(&now_time); 78 | strftime(time_str, TIME_FORMAT_STR_LEN, "%F %T", &tm_tmp); 79 | 80 | return time_str; 81 | } 82 | 83 | long HAL_Timer_current_sec(void) 84 | { 85 | struct timeval tv; 86 | gettimeofday(&tv, NULL); 87 | 88 | return tv.tv_sec; 89 | } 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | -------------------------------------------------------------------------------- /platform/os/nonos/HAL_AT_UART_nonos.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights 5 | reserved. 6 | 7 | * Licensed under the MIT License (the "License"); you may not use this file 8 | except in 9 | * compliance with the License. You may obtain a copy of the License at 10 | * http://opensource.org/licenses/MIT 11 | 12 | * Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is 14 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, 16 | * either express or implied. See the License for the specific language 17 | governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "at_client.h" 27 | #include "qcloud_iot_export.h" 28 | #include "qcloud_iot_import.h" 29 | #include "stm32l4xx_hal.h" 30 | #include "utils_ringbuff.h" 31 | 32 | #define HAL_AT_UART_IRQHandler USART1_IRQHandler 33 | extern UART_HandleTypeDef huart1; 34 | static UART_HandleTypeDef *pAtUart = &huart1; 35 | 36 | extern void AT_Uart_Init(void); 37 | extern void at_client_uart_rx_isr_cb(uint8_t *pdata, uint8_t len); 38 | 39 | #include "board.h" 40 | /** 41 | * @brief This function handles AT UART global interrupt,push recv char to 42 | * ringbuff. 43 | */ 44 | void HAL_AT_UART_IRQHandler(void) 45 | { 46 | uint8_t ch; 47 | if (__HAL_UART_GET_FLAG(pAtUart, UART_FLAG_RXNE) == SET) { 48 | ch = (uint8_t)READ_REG(pAtUart->Instance->RDR) & 0xFF; 49 | /*this callback for at_client*/ 50 | at_client_uart_rx_isr_cb(&ch, 1); 51 | HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin); 52 | } 53 | __HAL_UART_CLEAR_PEFLAG(pAtUart); 54 | } 55 | 56 | /** 57 | *pdata: pointer of data for send 58 | *len: len of data to be sent 59 | *return: the len of data send success 60 | * @brief hal api for at data send 61 | */ 62 | int HAL_AT_Uart_Send(void *data, uint32_t size) 63 | { 64 | if (HAL_OK == HAL_UART_Transmit(pAtUart, data, size, 0xFFFF)) { 65 | return size; 66 | } else { 67 | return 0; 68 | } 69 | } 70 | 71 | int HAL_AT_Uart_Init(void) 72 | { 73 | AT_Uart_Init(); 74 | return QCLOUD_RET_SUCCESS; 75 | } 76 | 77 | int HAL_AT_Uart_Deinit(void) 78 | { 79 | return QCLOUD_RET_SUCCESS; 80 | } 81 | -------------------------------------------------------------------------------- /platform/os/nonos/HAL_Music_freertos.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file HAL_Music_freertos.c 3 | * @author {hubert} ({hubertxxu@tencent.com}) 4 | * @brief 5 | * @version 1.0 6 | * @date 2024-01-17 7 | * 8 | * @copyright 9 | * 10 | * Tencent is pleased to support the open source community by making IoT Hub available. 11 | * Copyright(C) 2018 - 2024 THL A29 Limited, a Tencent company.All rights reserved. 12 | * 13 | * Licensed under the MIT License(the "License"); you may not use this file except in 14 | * compliance with the License. You may obtain a copy of the License at 15 | * http://opensource.org/licenses/MIT 16 | * 17 | * Unless required by applicable law or agreed to in writing, software distributed under the License is 18 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 19 | * either express or implied. See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * 22 | * @par Change Log: 23 | * 24 | * Date Version Author Description 25 | * 2024-01-17 1.0 hubertxxu first commit 26 | *
27 | */ 28 | 29 | #include "qcloud_iot_import.h" 30 | #include "qcloud_iot_export.h" 31 | 32 | #ifdef QQMUSIC_ENABLED 33 | 34 | int HAL_Music_Play(void **player, const char *url, int duration) 35 | { 36 | return 0; 37 | } 38 | 39 | int HAL_Music_Stop(void **player) 40 | { 41 | POINTER_SANITY_CHECK(*player, QCLOUD_ERR_INVAL); 42 | return 0; 43 | } 44 | 45 | bool HAL_Music_PlayPause(void *player, uint8_t playPause) 46 | { 47 | POINTER_SANITY_CHECK(player, false); 48 | return false; 49 | } 50 | 51 | int HAL_Music_SetVolume(void *player, int volume) 52 | { 53 | POINTER_SANITY_CHECK(player, -1); 54 | return 0; 55 | } 56 | 57 | int HAL_Music_GetVolume(void *player) 58 | { 59 | POINTER_SANITY_CHECK(player, -1); 60 | return 0; 61 | } 62 | 63 | bool HAL_Music_PlayEndCheck(void *player) 64 | { 65 | POINTER_SANITY_CHECK(player, true); 66 | return 0; 67 | } 68 | 69 | int HAL_Music_GetPlayPosition(void *player) 70 | { 71 | POINTER_SANITY_CHECK(player, -1); 72 | return 0; 73 | } 74 | 75 | int HAL_Music_SetPlayPosition(void *player, int position) 76 | { 77 | POINTER_SANITY_CHECK(player, -1); 78 | 79 | return 0; 80 | } 81 | 82 | #endif // QQMUSIC_ENABLED 83 | -------------------------------------------------------------------------------- /platform/os/nonos/HAL_OS_nonos.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights 5 | reserved. 6 | 7 | * Licensed under the MIT License (the "License"); you may not use this file 8 | except in 9 | * compliance with the License. You may obtain a copy of the License at 10 | * http://opensource.org/licenses/MIT 11 | 12 | * Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is 14 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, 16 | * either express or implied. See the License for the specific language 17 | governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "qcloud_iot_import.h" 27 | #include "stm32l4xx_hal.h" 28 | 29 | void HAL_Printf(_IN_ const char *fmt, ...) 30 | { 31 | va_list args; 32 | 33 | va_start(args, fmt); 34 | vprintf(fmt, args); 35 | va_end(args); 36 | 37 | fflush(stdout); 38 | } 39 | 40 | int HAL_Snprintf(_IN_ char *str, const int len, const char *fmt, ...) 41 | { 42 | va_list args; 43 | int rc; 44 | 45 | va_start(args, fmt); 46 | rc = vsnprintf(str, len, fmt, args); 47 | va_end(args); 48 | 49 | return rc; 50 | } 51 | 52 | int HAL_Vsnprintf(_IN_ char *str, _IN_ const int len, _IN_ const char *format, va_list ap) 53 | { 54 | return vsnprintf(str, len, format, ap); 55 | } 56 | 57 | void HAL_SleepMs(_IN_ uint32_t ms) 58 | { 59 | (void)HAL_Delay(ms); 60 | } 61 | 62 | void HAL_DelayMs(_IN_ uint32_t ms) 63 | { 64 | (void)HAL_Delay(ms); 65 | } 66 | 67 | void HAL_Free(void *ptr) 68 | { 69 | if (ptr) 70 | free(ptr); 71 | } 72 | 73 | void *HAL_Malloc(uint32_t size) 74 | { 75 | return malloc(size); 76 | } 77 | 78 | void *HAL_MutexCreate(void) 79 | { 80 | return (void *)1; 81 | } 82 | 83 | void HAL_MutexDestroy(void *mutex) 84 | { 85 | return; 86 | } 87 | 88 | void HAL_MutexLock(void *mutex) 89 | { 90 | return; 91 | } 92 | 93 | void HAL_MutexUnlock(void *mutex) 94 | { 95 | return; 96 | } 97 | -------------------------------------------------------------------------------- /platform/os/nonos/HAL_Timer_nonos.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights 5 | reserved. 6 | 7 | * Licensed under the MIT License (the "License"); you may not use this file 8 | except in 9 | * compliance with the License. You may obtain a copy of the License at 10 | * http://opensource.org/licenses/MIT 11 | 12 | * Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is 14 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, 16 | * either express or implied. See the License for the specific language 17 | governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "qcloud_iot_import.h" 32 | #include "stm32l4xx_hal.h" 33 | 34 | static char now_time_str[20] = {0}; 35 | 36 | uint64_t HAL_GetTimeMs(void) 37 | { 38 | return HAL_GetTick(); 39 | } 40 | 41 | /*Get timestamp*/ 42 | long HAL_Timer_current_sec(void) 43 | { 44 | // return GetTimeStampByAt(NULL); 45 | 46 | return HAL_GetTimeMs() / 1000; 47 | } 48 | 49 | char *HAL_Timer_current(void) 50 | { 51 | long time_sec; 52 | 53 | time_sec = HAL_Timer_current_sec(); 54 | memset(now_time_str, 0, 20); 55 | snprintf(now_time_str, 20, "%ld", time_sec); 56 | 57 | return now_time_str; 58 | } 59 | 60 | bool HAL_Timer_expired(Timer *timer) 61 | { 62 | uint64_t now_ts; 63 | 64 | now_ts = HAL_GetTimeMs(); 65 | 66 | return (now_ts > timer->end_time) ? true : false; 67 | } 68 | 69 | void HAL_Timer_countdown_ms(Timer *timer, unsigned int timeout_ms) 70 | { 71 | timer->end_time = HAL_GetTimeMs(); 72 | timer->end_time += timeout_ms; 73 | } 74 | 75 | void HAL_Timer_countdown(Timer *timer, unsigned int timeout) 76 | { 77 | timer->end_time = HAL_GetTimeMs(); 78 | timer->end_time += timeout * 1000; 79 | } 80 | 81 | int HAL_Timer_remain(Timer *timer) 82 | { 83 | return (int)(timer->end_time - HAL_GetTimeMs()); 84 | } 85 | 86 | void HAL_Timer_init(Timer *timer) 87 | { 88 | timer->end_time = 0; 89 | } 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | -------------------------------------------------------------------------------- /platform/os/rtthread/HAL_Music_freertos.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file HAL_Music_freertos.c 3 | * @author {hubert} ({hubertxxu@tencent.com}) 4 | * @brief 5 | * @version 1.0 6 | * @date 2024-01-17 7 | * 8 | * @copyright 9 | * 10 | * Tencent is pleased to support the open source community by making IoT Hub available. 11 | * Copyright(C) 2018 - 2024 THL A29 Limited, a Tencent company.All rights reserved. 12 | * 13 | * Licensed under the MIT License(the "License"); you may not use this file except in 14 | * compliance with the License. You may obtain a copy of the License at 15 | * http://opensource.org/licenses/MIT 16 | * 17 | * Unless required by applicable law or agreed to in writing, software distributed under the License is 18 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 19 | * either express or implied. See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * 22 | * @par Change Log: 23 | * 24 | * Date Version Author Description 25 | * 2024-01-17 1.0 hubertxxu first commit 26 | *
27 | */ 28 | 29 | #include "qcloud_iot_import.h" 30 | #include "qcloud_iot_export.h" 31 | 32 | #ifdef QQMUSIC_ENABLED 33 | 34 | int HAL_Music_Play(void **player, const char *url, int duration) 35 | { 36 | return 0; 37 | } 38 | 39 | int HAL_Music_Stop(void **player) 40 | { 41 | POINTER_SANITY_CHECK(*player, QCLOUD_ERR_INVAL); 42 | return 0; 43 | } 44 | 45 | bool HAL_Music_PlayPause(void *player, uint8_t playPause) 46 | { 47 | POINTER_SANITY_CHECK(player, false); 48 | return false; 49 | } 50 | 51 | int HAL_Music_SetVolume(void *player, int volume) 52 | { 53 | POINTER_SANITY_CHECK(player, -1); 54 | return 0; 55 | } 56 | 57 | int HAL_Music_GetVolume(void *player) 58 | { 59 | POINTER_SANITY_CHECK(player, -1); 60 | return 0; 61 | } 62 | 63 | bool HAL_Music_PlayEndCheck(void *player) 64 | { 65 | POINTER_SANITY_CHECK(player, true); 66 | return 0; 67 | } 68 | 69 | int HAL_Music_GetPlayPosition(void *player) 70 | { 71 | POINTER_SANITY_CHECK(player, -1); 72 | return 0; 73 | } 74 | 75 | int HAL_Music_SetPlayPosition(void *player, int position) 76 | { 77 | POINTER_SANITY_CHECK(player, -1); 78 | 79 | return 0; 80 | } 81 | 82 | #endif // QQMUSIC_ENABLED 83 | -------------------------------------------------------------------------------- /platform/os/rtthread/HAL_Timer_rtthread.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights 5 | reserved. 6 | 7 | * Licensed under the MIT License (the "License"); you may not use this file 8 | except in 9 | * compliance with the License. You may obtain a copy of the License at 10 | * http://opensource.org/licenses/MIT 11 | 12 | * Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is 14 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, 16 | * either express or implied. See the License for the specific language 17 | governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | #include 27 | #include 28 | 29 | #include "qcloud_iot_import.h" 30 | 31 | static char now_time_str[20] = {0}; 32 | 33 | uint64_t HAL_GetTimeMs(void) 34 | { 35 | #if (RT_TICK_PER_SECOND == 1000) 36 | /* #define RT_TICK_PER_SECOND 1000 */ 37 | return (uint64_t)rt_tick_get(); 38 | #else 39 | uint64_t tick = 0; 40 | 41 | tick = rt_tick_get(); 42 | tick = tick * 1000; 43 | return (uint64_t)((tick + RT_TICK_PER_SECOND - 1) / RT_TICK_PER_SECOND); 44 | #endif 45 | } 46 | 47 | /*Get timestamp*/ 48 | long HAL_Timer_current_sec(void) 49 | { 50 | return HAL_GetTimeMs() / 1000; 51 | } 52 | 53 | char *HAL_Timer_current(void) 54 | { 55 | long time_sec; 56 | 57 | time_sec = HAL_Timer_current_sec(); 58 | memset(now_time_str, 0, 20); 59 | snprintf(now_time_str, 20, "%ld", time_sec); 60 | 61 | return now_time_str; 62 | } 63 | 64 | bool HAL_Timer_expired(Timer *timer) 65 | { 66 | uint64_t now_ts; 67 | 68 | now_ts = HAL_GetTimeMs(); 69 | 70 | return (now_ts > timer->end_time) ? true : false; 71 | } 72 | 73 | void HAL_Timer_countdown_ms(Timer *timer, unsigned int timeout_ms) 74 | { 75 | timer->end_time = HAL_GetTimeMs(); 76 | timer->end_time += timeout_ms; 77 | } 78 | 79 | void HAL_Timer_countdown(Timer *timer, unsigned int timeout) 80 | { 81 | timer->end_time = HAL_GetTimeMs(); 82 | timer->end_time += timeout * 1000; 83 | } 84 | 85 | int HAL_Timer_remain(Timer *timer) 86 | { 87 | return (int)(timer->end_time - HAL_GetTimeMs()); 88 | } 89 | 90 | void HAL_Timer_init(Timer *timer) 91 | { 92 | timer->end_time = 0; 93 | } 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | -------------------------------------------------------------------------------- /platform/os/windows/HAL_AT_UART_win.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights 5 | reserved. 6 | 7 | * Licensed under the MIT License (the "License"); you may not use this file 8 | except in 9 | * compliance with the License. You may obtain a copy of the License at 10 | * http://opensource.org/licenses/MIT 11 | 12 | * Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is 14 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, 16 | * either express or implied. See the License for the specific language 17 | governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | 22 | #include "qcloud_iot_export.h" 23 | #include "qcloud_iot_import.h" 24 | 25 | #ifdef AT_TCP_ENABLED 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include "at_client.h" 33 | #include "utils_ringbuff.h" 34 | 35 | /** 36 | * @brief This function handles AT UART global interrupt,push recv char to 37 | * ringbuff. 38 | */ 39 | void HAL_AT_UART_IRQHandler(void) {} 40 | 41 | /** 42 | *pdata: pointer of data for send 43 | *len: len of data to be sent 44 | *return: the len of data send success 45 | * @brief hal api for at data send 46 | */ 47 | int HAL_AT_Uart_Send(void *data, uint32_t size) 48 | { 49 | return 0; 50 | } 51 | 52 | int HAL_AT_Uart_Init(void) 53 | { 54 | return QCLOUD_RET_SUCCESS; 55 | } 56 | 57 | int HAL_AT_Uart_Deinit(void) 58 | { 59 | return QCLOUD_RET_SUCCESS; 60 | } 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /platform/os/windows/HAL_File_win.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights 5 | reserved. 6 | 7 | * Licensed under the MIT License (the "License"); you may not use this file 8 | except in 9 | * compliance with the License. You may obtain a copy of the License at 10 | * http://opensource.org/licenses/MIT 11 | 12 | * Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is 14 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, 16 | * either express or implied. See the License for the specific language 17 | governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | #include 22 | #include 23 | 24 | void *HAL_FileOpen(const char *filename, const char *mode) 25 | { 26 | return (void *)fopen(filename, mode); 27 | } 28 | 29 | size_t HAL_FileRead(void *ptr, size_t size, size_t nmemb, void *fp) 30 | { 31 | return fread(ptr, size, nmemb, (FILE *)fp); 32 | } 33 | 34 | size_t HAL_FileWrite(const void *ptr, size_t size, size_t nmemb, void *fp) 35 | { 36 | return fwrite(ptr, size, nmemb, (FILE *)fp); 37 | } 38 | 39 | int HAL_FileSeek(void *fp, long int offset, int whence) 40 | { 41 | return fseek((FILE *)fp, offset, whence); 42 | } 43 | 44 | int HAL_FileClose(void *fp) 45 | { 46 | return fclose((FILE *)fp); 47 | } 48 | 49 | int HAL_FileRemove(const char *filename) 50 | { 51 | return remove(filename); 52 | } 53 | 54 | int HAL_FileRewind(void *fp) 55 | { 56 | rewind((FILE *)fp); 57 | 58 | return 0; 59 | } 60 | 61 | long HAL_FileTell(void *fp) 62 | { 63 | return ftell((FILE *)fp); 64 | } 65 | 66 | long HAL_FileSize(void *fp) 67 | { 68 | long size = 0; 69 | 70 | fseek((FILE *)fp, 0, SEEK_END); 71 | size = ftell((FILE *)fp); 72 | rewind((FILE *)fp); 73 | 74 | return size; 75 | } 76 | 77 | char *HAL_FileGets(char *str, int n, void *fp) 78 | { 79 | return fgets(str, n, (FILE *)fp); 80 | } 81 | 82 | int HAL_FileRename(const char *old_filename, const char *new_filename) 83 | { 84 | return rename(old_filename, new_filename); 85 | } 86 | 87 | int HAL_FileEof(void *fp) 88 | { 89 | return feof((FILE *)fp); 90 | } 91 | 92 | int HAL_FileFlush(void *fp) 93 | { 94 | return fflush((FILE *)fp); 95 | } 96 | -------------------------------------------------------------------------------- /platform/os/windows/HAL_Log_win.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights 5 | reserved. 6 | 7 | * Licensed under the MIT License (the "License"); you may not use this file 8 | except in 9 | * compliance with the License. You may obtain a copy of the License at 10 | * http://opensource.org/licenses/MIT 11 | 12 | * Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is 14 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, 16 | * either express or implied. See the License for the specific language 17 | governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | #include "qcloud_iot_export_error.h" 26 | #include "qcloud_iot_export_log.h" 27 | #include "qcloud_iot_import.h" 28 | 29 | #ifdef LOG_UPLOAD 30 | 31 | #define LOG_SAVE_FILE_PATH "upload-fail-save.log" 32 | 33 | size_t HAL_Log_Save(const char *log, size_t wLen) 34 | { 35 | FILE *fp; 36 | size_t len; 37 | 38 | if ((fp = fopen(LOG_SAVE_FILE_PATH, "a+")) == NULL) { 39 | Log_e("fail to open file %s", LOG_SAVE_FILE_PATH); 40 | return 0; 41 | } 42 | 43 | len = fwrite((void *)log, 1, wLen, fp); 44 | Log_d("write %d of %d to log file", len, wLen); 45 | 46 | fclose(fp); 47 | 48 | return len; 49 | } 50 | 51 | size_t HAL_Log_Read(char *buff, size_t rLen) 52 | { 53 | FILE *fp; 54 | size_t len; 55 | 56 | if ((fp = fopen(LOG_SAVE_FILE_PATH, "rb")) == NULL) { 57 | Log_e("fail to open file %s", LOG_SAVE_FILE_PATH); 58 | return 0; 59 | } 60 | 61 | len = fread((void *)buff, 1, rLen, fp); 62 | Log_d("read %d of %d from log file", len, rLen); 63 | 64 | fclose(fp); 65 | 66 | return len; 67 | } 68 | 69 | int HAL_Log_Del(void) 70 | { 71 | return remove(LOG_SAVE_FILE_PATH); 72 | } 73 | 74 | size_t HAL_Log_Get_Size(void) 75 | { 76 | long length; 77 | FILE *fp; 78 | 79 | /* check if file exists */ 80 | if (access(LOG_SAVE_FILE_PATH, 0)) 81 | return 0; 82 | 83 | if ((fp = fopen(LOG_SAVE_FILE_PATH, "r")) == NULL) { 84 | Log_e("fail to open file %s", LOG_SAVE_FILE_PATH); 85 | return 0; 86 | } 87 | 88 | fseek(fp, 0L, SEEK_END); 89 | length = ftell(fp); 90 | fclose(fp); 91 | if (length > 0) 92 | return (size_t)length; 93 | else 94 | return 0; 95 | } 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /platform/os/windows/HAL_Music_freertos.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file HAL_Music_freertos.c 3 | * @author {hubert} ({hubertxxu@tencent.com}) 4 | * @brief 5 | * @version 1.0 6 | * @date 2024-01-17 7 | * 8 | * @copyright 9 | * 10 | * Tencent is pleased to support the open source community by making IoT Hub available. 11 | * Copyright(C) 2018 - 2024 THL A29 Limited, a Tencent company.All rights reserved. 12 | * 13 | * Licensed under the MIT License(the "License"); you may not use this file except in 14 | * compliance with the License. You may obtain a copy of the License at 15 | * http://opensource.org/licenses/MIT 16 | * 17 | * Unless required by applicable law or agreed to in writing, software distributed under the License is 18 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 19 | * either express or implied. See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * 22 | * @par Change Log: 23 | * 24 | * Date Version Author Description 25 | * 2024-01-17 1.0 hubertxxu first commit 26 | *
27 | */ 28 | 29 | #include "qcloud_iot_import.h" 30 | #include "qcloud_iot_export.h" 31 | 32 | #ifdef QQMUSIC_ENABLED 33 | 34 | int HAL_Music_Play(void **player, const char *url, int duration) 35 | { 36 | return 0; 37 | } 38 | 39 | int HAL_Music_Stop(void **player) 40 | { 41 | POINTER_SANITY_CHECK(*player, QCLOUD_ERR_INVAL); 42 | return 0; 43 | } 44 | 45 | bool HAL_Music_PlayPause(void *player, uint8_t playPause) 46 | { 47 | POINTER_SANITY_CHECK(player, false); 48 | return false; 49 | } 50 | 51 | int HAL_Music_SetVolume(void *player, int volume) 52 | { 53 | POINTER_SANITY_CHECK(player, -1); 54 | return 0; 55 | } 56 | 57 | int HAL_Music_GetVolume(void *player) 58 | { 59 | POINTER_SANITY_CHECK(player, -1); 60 | return 0; 61 | } 62 | 63 | bool HAL_Music_PlayEndCheck(void *player) 64 | { 65 | POINTER_SANITY_CHECK(player, true); 66 | return 0; 67 | } 68 | 69 | int HAL_Music_GetPlayPosition(void *player) 70 | { 71 | POINTER_SANITY_CHECK(player, -1); 72 | return 0; 73 | } 74 | 75 | int HAL_Music_SetPlayPosition(void *player, int position) 76 | { 77 | POINTER_SANITY_CHECK(player, -1); 78 | 79 | return 0; 80 | } 81 | 82 | #endif // QQMUSIC_ENABLED 83 | -------------------------------------------------------------------------------- /platform/os/windows/HAL_Timer_win.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights 5 | reserved. 6 | 7 | * Licensed under the MIT License (the "License"); you may not use this file 8 | except in 9 | * compliance with the License. You may obtain a copy of the License at 10 | * http://opensource.org/licenses/MIT 11 | 12 | * Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is 14 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, 16 | * either express or implied. See the License for the specific language 17 | governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | #include 27 | #include 28 | 29 | #include "qcloud_iot_import.h" 30 | 31 | bool HAL_Timer_expired(Timer *timer) 32 | { 33 | if (GetTickCount64() >= timer->end_time) { 34 | return true; 35 | } 36 | 37 | return false; 38 | } 39 | 40 | void HAL_Timer_countdown_ms(Timer *timer, unsigned int timeout_ms) 41 | { 42 | timer->end_time = GetTickCount64() + timeout_ms; 43 | } 44 | 45 | void HAL_Timer_countdown(Timer *timer, unsigned int timeout) 46 | { 47 | timer->end_time = GetTickCount64() + (UINT64)timeout * 1000; 48 | } 49 | 50 | int HAL_Timer_remain(Timer *timer) 51 | { 52 | UINT64 now = GetTickCount64(); 53 | 54 | if (now >= timer->end_time) { 55 | return 0; 56 | } 57 | 58 | return (int)(timer->end_time - now); 59 | } 60 | 61 | void HAL_Timer_init(Timer *timer) 62 | { 63 | timer->end_time = 0; 64 | } 65 | 66 | char *HAL_Timer_current(char *time_str) 67 | { 68 | time_t now; 69 | struct tm tm_val; 70 | 71 | time(&now); 72 | localtime_s(&tm_val, &now); 73 | 74 | snprintf(time_str, TIME_FORMAT_STR_LEN, "%04d/%02d/%02d %02d:%02d:%02d", tm_val.tm_year + 1900, tm_val.tm_mon + 1, 75 | tm_val.tm_mday, tm_val.tm_hour, tm_val.tm_min, tm_val.tm_sec); 76 | 77 | return time_str; 78 | } 79 | 80 | long HAL_Timer_current_sec(void) 81 | { 82 | return (long)time(NULL); 83 | } 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | -------------------------------------------------------------------------------- /platform/wifi_config_adapter/HAL_Wifi_api.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights 5 | reserved. 6 | 7 | * Licensed under the MIT License (the "License"); you may not use this file 8 | except in 9 | * compliance with the License. You may obtain a copy of the License at 10 | * http://opensource.org/licenses/MIT 11 | 12 | * Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is 14 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, 16 | * either express or implied. See the License for the specific language 17 | governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "qcloud_iot_export.h" 27 | #include "qcloud_iot_import.h" 28 | 29 | #include "qcloud_wifi_config.h" 30 | 31 | int HAL_Wifi_StaConnect(const char *ssid, const char *psw, uint8_t channel) 32 | { 33 | Log_i("STA to connect SSID:%s PASSWORD:%s CHANNEL:%d", ssid, psw, channel); 34 | // TO-DO 35 | 36 | return QCLOUD_RET_SUCCESS; 37 | } 38 | 39 | bool HAL_Wifi_IsConnected(void) 40 | { 41 | // TO-DO, Get IP is true 42 | return true; 43 | } 44 | 45 | int HAL_Wifi_GetLocalIP(char *ipv4_buf, int ipv4_buf_len) 46 | { 47 | // TO-DO, return QCLOUD_ERR_FAILURE when invalid ip 48 | // return QCLOUD_RET_SUCCESS when get valid ip 49 | // copy ipv4 string to ipv4_buf 50 | strncpy(ipv4_buf, "255.255.255.255", ipv4_buf_len); 51 | return QCLOUD_ERR_FAILURE; 52 | } 53 | 54 | int HAL_Wifi_GetAP_SSID(char *ssid_buf, int ssid_buf_len) 55 | { 56 | // TO-DO, return connected ap ssid len 57 | // invalid ssid return QCLOUD_ERR_FAILURE 58 | // copy ssid string to ssid_buf 59 | int ssid_len = QCLOUD_ERR_FAILURE; 60 | strncpy(ssid_buf, "test", ssid_buf_len); 61 | return ssid_len; 62 | } 63 | 64 | int HAL_Wifi_GetAP_PWD(char *pwd_buf, int pwd_buf_len) 65 | { 66 | // TO-DO, return connected ap password of ssid len 67 | // invalid password return QCLOUD_ERR_FAILURE 68 | // copy password string to pwd_buf 69 | int password_len = QCLOUD_ERR_FAILURE; 70 | strncpy(pwd_buf, "test", pwd_buf_len); 71 | return password_len; 72 | } 73 | 74 | int HAL_Wifi_read_err_log(uint32_t offset, void *log, size_t log_size) 75 | { 76 | Log_i("HAL_Wifi_read_err_log"); 77 | 78 | return QCLOUD_RET_SUCCESS; 79 | } 80 | 81 | int HAL_Wifi_write_err_log(uint32_t offset, void *log, size_t log_size) 82 | { 83 | Log_i("HAL_Wifi_write_err_log"); 84 | 85 | return QCLOUD_RET_SUCCESS; 86 | } 87 | 88 | int HAL_Wifi_clear_err_log(void) 89 | { 90 | Log_i("HAL_Wifi_clear_err_log"); 91 | 92 | return QCLOUD_RET_SUCCESS; 93 | } 94 | -------------------------------------------------------------------------------- /samples/data_template/action_config.c: -------------------------------------------------------------------------------- 1 | #ifdef ACTION_ENABLED 2 | 3 | #define TOTAL_ACTION_COUNTS (1) 4 | 5 | static TYPE_DEF_TEMPLATE_INT sg_light_blink_in_time = 0; 6 | static TYPE_DEF_TEMPLATE_BOOL sg_light_blink_in_color = 0; 7 | static TYPE_DEF_TEMPLATE_INT sg_light_blink_in_total_time = 0; 8 | static DeviceProperty g_actionInput_light_blink[] = { 9 | 10 | {.key = "time", .data = &sg_light_blink_in_time, .type = TYPE_TEMPLATE_INT}, 11 | {.key = "color", .data = &sg_light_blink_in_color, .type = TYPE_TEMPLATE_BOOL}, 12 | {.key = "total_time", .data = &sg_light_blink_in_total_time, .type = TYPE_TEMPLATE_INT}, 13 | }; 14 | static TYPE_DEF_TEMPLATE_ENUM sg_light_blink_out_err_code = 1; 15 | static DeviceProperty g_actionOutput_light_blink[] = { 16 | 17 | {.key = "err_code", .data = &sg_light_blink_out_err_code, .type = TYPE_TEMPLATE_ENUM}, 18 | }; 19 | 20 | static DeviceAction g_actions[] = { 21 | 22 | { 23 | .pActionId = "light_blink", 24 | .timestamp = 0, 25 | .input_num = sizeof(g_actionInput_light_blink) / sizeof(g_actionInput_light_blink[0]), 26 | .output_num = sizeof(g_actionOutput_light_blink) / sizeof(g_actionOutput_light_blink[0]), 27 | .pInput = g_actionInput_light_blink, 28 | .pOutput = g_actionOutput_light_blink, 29 | }, 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /samples/data_template/events_config.c: -------------------------------------------------------------------------------- 1 | #ifdef EVENT_POST_ENABLED 2 | 3 | #define EVENT_COUNTS (3) 4 | 5 | static TYPE_DEF_TEMPLATE_BOOL sg_status_report_status = 0; 6 | static TYPE_DEF_TEMPLATE_STRING sg_status_report_message[64 + 1] = {0}; 7 | static DeviceProperty g_propertyEvent_status_report[] = { 8 | 9 | {.key = "status", .data = &sg_status_report_status, .type = TYPE_TEMPLATE_BOOL}, 10 | {.key = "message", .data = sg_status_report_message, .type = TYPE_TEMPLATE_STRING}, 11 | }; 12 | 13 | static TYPE_DEF_TEMPLATE_FLOAT sg_low_voltage_voltage = 1; 14 | static DeviceProperty g_propertyEvent_low_voltage[] = { 15 | 16 | {.key = "voltage", .data = &sg_low_voltage_voltage, .type = TYPE_TEMPLATE_FLOAT}, 17 | }; 18 | 19 | static TYPE_DEF_TEMPLATE_STRING sg_hardware_fault_name[64 + 1] = {0}; 20 | static TYPE_DEF_TEMPLATE_INT sg_hardware_fault_error_code = 1; 21 | static DeviceProperty g_propertyEvent_hardware_fault[] = { 22 | 23 | {.key = "name", .data = sg_hardware_fault_name, .type = TYPE_TEMPLATE_STRING}, 24 | {.key = "error_code", .data = &sg_hardware_fault_error_code, .type = TYPE_TEMPLATE_INT}, 25 | }; 26 | 27 | static sEvent g_events[] = { 28 | 29 | { 30 | .event_name = "status_report", 31 | .type = "info", 32 | .timestamp = 0, 33 | .eventDataNum = sizeof(g_propertyEvent_status_report) / sizeof(g_propertyEvent_status_report[0]), 34 | .pEventData = g_propertyEvent_status_report, 35 | }, 36 | { 37 | .event_name = "low_voltage", 38 | .type = "alert", 39 | .timestamp = 0, 40 | .eventDataNum = sizeof(g_propertyEvent_low_voltage) / sizeof(g_propertyEvent_low_voltage[0]), 41 | .pEventData = g_propertyEvent_low_voltage, 42 | }, 43 | { 44 | .event_name = "hardware_fault", 45 | .type = "fault", 46 | .timestamp = 0, 47 | .eventDataNum = sizeof(g_propertyEvent_hardware_fault) / sizeof(g_propertyEvent_hardware_fault[0]), 48 | .pEventData = g_propertyEvent_hardware_fault, 49 | }, 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /samples/kgmusic/action_config.c: -------------------------------------------------------------------------------- 1 | #ifdef ACTION_ENABLED 2 | 3 | #define TOTAL_ACTION_COUNTS (1) 4 | 5 | static TYPE_DEF_TEMPLATE_BOOL sg_fresh_token_in_fresh_token = 0; 6 | static DeviceProperty g_actionInput_fresh_token[] = { 7 | 8 | {.key = "_sys_fresh_token", .data = &sg_fresh_token_in_fresh_token, .type = TYPE_TEMPLATE_BOOL}, 9 | }; 10 | static TYPE_DEF_TEMPLATE_INT sg_fresh_token_out_Code = 0; 11 | static DeviceProperty g_actionOutput_fresh_token[] = { 12 | 13 | {.key = "Code", .data = &sg_fresh_token_out_Code, .type = TYPE_TEMPLATE_INT}, 14 | }; 15 | 16 | 17 | static DeviceAction g_actions[]={ 18 | 19 | { 20 | .pActionId = "_sys_fresh_token", 21 | .timestamp = 0, 22 | .input_num = sizeof(g_actionInput_fresh_token)/sizeof(g_actionInput_fresh_token[0]), 23 | .output_num = sizeof(g_actionOutput_fresh_token)/sizeof(g_actionOutput_fresh_token[0]), 24 | .pInput = g_actionInput_fresh_token, 25 | .pOutput = g_actionOutput_fresh_token, 26 | }, 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /samples/location/data_config.c: -------------------------------------------------------------------------------- 1 | /*-----------------data config start -------------------*/ 2 | 3 | #define TOTAL_PROPERTY_COUNT 1 4 | 5 | static sDataPoint sg_DataTemplate[TOTAL_PROPERTY_COUNT]; 6 | 7 | typedef struct _ProductDataDefine { 8 | TYPE_DEF_TEMPLATE_OBJECT m_GPS_Info; 9 | } ProductDataDefine; 10 | 11 | static ProductDataDefine sg_ProductData; 12 | 13 | #define TOTAL_PROPERTY_STRUCT_GPS_INFO_COUNT 2 14 | 15 | static sDataPoint sg_StructTemplateGps_Info[TOTAL_PROPERTY_STRUCT_GPS_INFO_COUNT]; 16 | 17 | typedef struct _StructDefineGps_Info { 18 | TYPE_DEF_TEMPLATE_FLOAT m_longitude; 19 | TYPE_DEF_TEMPLATE_FLOAT m_latitude; 20 | } StructDefineGps_Info; 21 | 22 | static StructDefineGps_Info sg_StructDataGps_Info; 23 | 24 | static void _init_struct_GPS_Info(void) 25 | { 26 | // WGS84 27 | sg_StructDataGps_Info.m_longitude = 108.884031; 28 | sg_StructTemplateGps_Info[0].data_property.data = &sg_StructDataGps_Info.m_longitude; 29 | sg_StructTemplateGps_Info[0].data_property.key = "longitude"; 30 | sg_StructTemplateGps_Info[0].data_property.type = TYPE_TEMPLATE_FLOAT; 31 | sg_StructTemplateGps_Info[0].state = eCHANGED; 32 | 33 | sg_StructDataGps_Info.m_latitude = 34.212282; 34 | sg_StructTemplateGps_Info[1].data_property.data = &sg_StructDataGps_Info.m_latitude; 35 | sg_StructTemplateGps_Info[1].data_property.key = "latitude"; 36 | sg_StructTemplateGps_Info[1].data_property.type = TYPE_TEMPLATE_FLOAT; 37 | sg_StructTemplateGps_Info[1].state = eCHANGED; 38 | }; 39 | 40 | static void _init_data_template(void) 41 | { 42 | _init_struct_GPS_Info(); 43 | sg_ProductData.m_GPS_Info = (void *)&sg_StructTemplateGps_Info; 44 | sg_DataTemplate[0].data_property.data = sg_ProductData.m_GPS_Info; 45 | sg_DataTemplate[0].data_property.struct_obj_num = TOTAL_PROPERTY_STRUCT_GPS_INFO_COUNT; 46 | sg_DataTemplate[0].data_property.key = "GPS_Info"; 47 | sg_DataTemplate[0].data_property.type = TYPE_TEMPLATE_JOBJECT; 48 | sg_DataTemplate[0].state = eCHANGED; 49 | }; 50 | -------------------------------------------------------------------------------- /samples/qqmusic/action_config.c: -------------------------------------------------------------------------------- 1 | 2 | #define TOTAL_ACTION_COUNTS (1) 3 | 4 | static TYPE_DEF_TEMPLATE_BOOL sg_pre_or_next_in_pre_or_next = 0; 5 | static DeviceProperty g_actionInput_pre_or_next[] = { 6 | 7 | {.key = "pre_or_next", .data = &sg_pre_or_next_in_pre_or_next, .type = TYPE_TEMPLATE_ENUM}, 8 | }; 9 | static TYPE_DEF_TEMPLATE_INT sg_pre_or_next_out_code = 0; 10 | static DeviceProperty g_actionOutput_pre_or_next[] = { 11 | 12 | {.key = "code", .data = &sg_pre_or_next_out_code, .type = TYPE_TEMPLATE_INT}, 13 | }; 14 | 15 | static DeviceAction g_actions[] = { 16 | 17 | { 18 | .pActionId = "_sys_pre_next", 19 | .timestamp = 0, 20 | .input_num = sizeof(g_actionInput_pre_or_next) / sizeof(g_actionInput_pre_or_next[0]), 21 | .output_num = sizeof(g_actionOutput_pre_or_next) / sizeof(g_actionOutput_pre_or_next[0]), 22 | .pInput = g_actionInput_pre_or_next, 23 | .pOutput = g_actionOutput_pre_or_next, 24 | }, 25 | }; 26 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/asr_client.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights 5 | reserved. 6 | 7 | * Licensed under the MIT License (the "License"); you may not use this file 8 | except in 9 | * compliance with the License. You may obtain a copy of the License at 10 | * http://opensource.org/licenses/MIT 11 | 12 | * Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is 14 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, 16 | * either express or implied. See the License for the specific language 17 | governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | 22 | #ifndef __ASR_CLIENT_H__ 23 | #define __ASR_CLIENT_H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #define MAX_ASR_REQUEST (20) 30 | #define DEFAULT_REQ_TIMEOUT_MS (5000) 31 | #define ASR_REQUEST_BUFF_LEN (512) 32 | 33 | typedef enum { 34 | eASR_REQ_IDLE = 0, 35 | eASR_REQ_INIT = 1, 36 | eASR_REQ_DONE = 2, 37 | } eAsrReqState; 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif /* __AT_H__ */ 44 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/at_socket_inf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2021 Tencent Group. All rights reserved. 3 | * License-Identifier: Apache-2.0 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 6 | * not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | 19 | #ifndef _AT_SOCKET_INF_H_ 20 | #define _AT_SOCKET_INF_H_ 21 | 22 | #include 23 | #include 24 | 25 | #include "utils_list.h" 26 | 27 | #define UNUSED_SOCKET (-1) 28 | #define MAX_AT_SOCKET_NUM (5) 29 | #define AT_SOCKET_SEND_TIMEOUT_MS (1000) 30 | #define AT_SOCKET_RECV_TIMEOUT_MS (1000) 31 | #define IPV4_STR_MAX_LEN (16) 32 | 33 | typedef enum { eNET_TCP = 6, eNET_UDP = 17, eNET_DEFAULT = 0xff } eNetProto; 34 | 35 | typedef enum { eSOCKET_ALLOCED = 0, eSOCKET_CONNECTED, eSOCKET_CLOSED } eSocketState; 36 | 37 | /* AT receive package list structure */ 38 | typedef struct at_recv_pkt { 39 | List list; 40 | size_t bfsz_totle; 41 | size_t bfsz_index; 42 | char * buff; 43 | } at_recv_pkt; 44 | 45 | typedef enum { 46 | AT_SOCKET_EVT_RECV = 0, 47 | AT_SOCKET_EVT_CLOSED, 48 | } at_socket_evt_t; 49 | 50 | typedef void (*at_evt_cb_t)(int fd, at_socket_evt_t event, char *buff, size_t bfsz); 51 | 52 | /*at device driver ops, use at_device_op_register register to at socket*/ 53 | typedef struct { 54 | int (*init)(void); 55 | int (*get_local_mac)(char *macbuff, size_t bufflen); 56 | int (*get_local_ip)(char *ip, size_t iplen, char *gw, size_t gwlen, char *mask, size_t masklen); 57 | int (*parse_domain)(const char *host_name, char *host_ip, size_t host_ip_len); 58 | int (*connect)(const char *ip, uint16_t port, eNetProto proto); 59 | int (*send)(int fd, const void *buf, size_t len); 60 | int (*recv_timeout)(int fd, void *buf, size_t len, uint32_t timeout); 61 | int (*close)(int fd); 62 | void (*set_event_cb)(at_socket_evt_t event, at_evt_cb_t cb); 63 | char *deviceName; 64 | } at_device_op_t; 65 | 66 | /*at socket context*/ 67 | typedef struct { 68 | int fd; /** socket fd */ 69 | List * recvpkt_list; 70 | char remote_ip[IPV4_STR_MAX_LEN]; 71 | uint16_t remote_port; 72 | uint32_t send_timeout_ms; 73 | uint32_t recv_timeout_ms; 74 | void * recv_lock; 75 | at_device_op_t *dev_op; 76 | eNetProto net_type; 77 | eSocketState state; 78 | } at_socket_ctx_t; 79 | 80 | // at socket api 81 | int at_device_op_register(at_device_op_t *device_op); 82 | int at_socket_init(void); 83 | int at_socket_parse_domain(const char *host_name, char *host_ip, size_t host_ip_len); 84 | int at_socket_get_local_mac(char *macbuff, size_t bufflen); 85 | int at_socket_get_local_ip(char *ip, size_t iplen, char *gw, size_t gwlen, char *mask, size_t masklen); 86 | int at_socket_connect(const char *host, uint16_t port, eNetProto eProto); 87 | int at_socket_close(int fd); 88 | int at_socket_send(int fd, const void *buf, size_t len); 89 | int at_socket_recv(int fd, void *buf, size_t len); 90 | #endif 91 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/at_uart_hal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef __AT_UART_HAL_H__ 22 | #define __AT_UART_HAL_H__ 23 | 24 | /* 25 | * UART data width 26 | */ 27 | typedef enum { 28 | BAUDRATE_2400 = 2400, 29 | BAUDRATE_4800 = 4800, 30 | BAUDRATE_9600 = 9600, 31 | BAUDRATE_19200 = 19200, 32 | BAUDRATE_115200 = 115200, 33 | BAUDRATE_921600 = 921600, 34 | BAUDRATE_DEFAULT = 115200 35 | } hal_uart_baudr_t; 36 | 37 | /* 38 | * UART data width 39 | */ 40 | typedef enum { 41 | DATA_WIDTH_5BIT, 42 | DATA_WIDTH_6BIT, 43 | DATA_WIDTH_7BIT, 44 | DATA_WIDTH_8BIT, 45 | DATA_WIDTH_9BIT 46 | } hal_uart_data_width_t; 47 | 48 | /* 49 | * UART stop bits 50 | */ 51 | typedef enum { STOP_BITS_1, STOP_BITS_2 } hal_uart_stop_bits_t; 52 | 53 | /* 54 | * UART flow control 55 | */ 56 | typedef enum { 57 | FLOW_CONTROL_DISABLED, 58 | FLOW_CONTROL_CTS, 59 | FLOW_CONTROL_RTS, 60 | FLOW_CONTROL_CTS_RTS 61 | } hal_uart_flow_control_t; 62 | 63 | /* 64 | * UART parity 65 | */ 66 | typedef enum { NO_PARITY, ODD_PARITY, EVEN_PARITY } hal_uart_parity_t; 67 | 68 | /* 69 | * UART mode 70 | */ 71 | typedef enum { MODE_TX, MODE_RX, MODE_TX_RX } hal_uart_mode_t; 72 | 73 | /* 74 | * UART state 75 | */ 76 | typedef enum { 77 | eUNUSED = 0, 78 | eOPENED = 1, 79 | eCLOSED = 2, 80 | } hal_uart_state_t; 81 | 82 | /* 83 | * UART configuration 84 | */ 85 | typedef struct { 86 | uint32_t baud_rate; 87 | hal_uart_data_width_t data_width; 88 | hal_uart_parity_t parity; 89 | hal_uart_stop_bits_t stop_bits; 90 | hal_uart_flow_control_t flow_control; 91 | hal_uart_mode_t mode; 92 | } uart_config_t; 93 | 94 | typedef struct { 95 | #ifdef __linux__ 96 | int fd; /* uart fd */ 97 | #else 98 | void *uart_handle; /* uart handle,like stm32 UART_HandleTypeDef */ 99 | #endif 100 | hal_uart_state_t state; /* uart state */ 101 | uart_config_t config; /* uart config */ 102 | } uart_dev_t; 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | 108 | #endif /* __AT_H__ */ 109 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/at_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2021 Tencent Group. All rights reserved. 3 | * License-Identifier: Apache-2.0 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 6 | * not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | 19 | #ifndef _AT_UTILS_H_ 20 | #define _AT_UTILS_H_ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #define WIDTH_SIZE 32 27 | 28 | #ifndef __INT_MAX__ 29 | #define __INT_MAX__ 2147483647 30 | #endif 31 | 32 | #ifndef INT_MAX 33 | #define INT_MAX (__INT_MAX__) 34 | #endif 35 | 36 | #define AT_CMD_COMMA_MARK ',' 37 | #define AT_CMD_DQUOTES_MARK '"' 38 | 39 | #define __is_print(ch) ((unsigned int)((ch) - ' ') < 127u - ' ') 40 | 41 | int at_vprintfln(const char *format, va_list args); 42 | void at_print_raw_cmd(const char *name, const char *cmd, int size); 43 | const char *at_get_last_cmd(int *cmd_size); 44 | int at_req_parse_args(const char *req_args, const char *req_expr, ...); 45 | int at_sscanf(const char *buf, const char *fmt, va_list args); 46 | void at_strip(char *str, const char patten); 47 | void chr_strip(char *str, const char patten); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/data_template_action.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef _DATA_TEMPLATE_ACTION_H_ 22 | #define _DATA_TEMPLATE_ACTION_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #define ACTION_NAME_MAX_LEN (20) // action name max len 34 | #define ACTION_TOKEN_MAX_LEN (32) // action token max len 35 | 36 | #define MAX_ACTION_WAIT_REPLY (10) 37 | #define ACTION_MAX_DATA_NUM (255) // input or output max data num 38 | 39 | #define REPORT_ACTION "action_reply" 40 | #define CALL_ACTION "action" 41 | 42 | int IOT_Action_Init(void *c); 43 | 44 | int IOT_Action_Register(void *pTemplate, DeviceAction *pAction, OnActionHandleCallback callback); 45 | 46 | int IOT_Action_Remove(void *ptemplate, DeviceAction *pAction); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif //_DATA_TEMPLATE_ACTION_H_ 53 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/data_template_client_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef IOT_DATA_TEMPLATE_CLIENT_COMMON_H_ 22 | #define IOT_DATA_TEMPLATE_CLIENT_COMMON_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include "data_template_client.h" 29 | 30 | /** 31 | * @brief register a device property 32 | * 33 | * @param pTemplate handle to data_template client 34 | * @param pProperty device property 35 | * @param callback callback when property changes 36 | * @return QCLOUD_RET_SUCCESS for success, or err code for failure 37 | */ 38 | 39 | int template_common_register_property_on_delta(Qcloud_IoT_Template *pTemplate, DeviceProperty *pProperty, 40 | OnPropRegCallback callback); 41 | 42 | /** 43 | * @brief remove a device property 44 | * 45 | * @param pTemplate handle to data_template client 46 | * @param pProperty device property 47 | * @return QCLOUD_RET_SUCCESS for success, or err code for failure 48 | */ 49 | int template_common_remove_property(Qcloud_IoT_Template *ptemplate, DeviceProperty *pProperty); 50 | 51 | /** 52 | * @brief check if a device property exists 53 | * 54 | * @param pShadow handle to data_template client 55 | * @param pProperty device property 56 | * @return 0 = not existed 57 | */ 58 | int template_common_check_property_existence(Qcloud_IoT_Template *ptemplate, DeviceProperty *pProperty); 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | #endif // IOT_DATA_TEMPLATE_CLIENT_COMMON_H_ 65 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/data_template_event.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef _DATA_TEMPLATE_EVENT_H_ 22 | #define _DATA_TEMPLATE_EVENT_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #define NAME_MAX_LEN (32) 34 | #define TYPE_MAX_LEN (32) 35 | #define EVENT_TOKEN_MAX_LEN (32) 36 | #define SINGLE_EVENT (1) 37 | #define MUTLTI_EVENTS (2) 38 | 39 | #define MAX_EVENT_WAIT_REPLY (10) 40 | #define EVENT_MAX_DATA_NUM (255) 41 | 42 | #define POST_EVENT "event_post" 43 | #define POST_EVENTS "events_post" 44 | #define REPLY_EVENT "event_reply" 45 | 46 | /** 47 | * @brief event's method, post and reply 48 | */ 49 | typedef enum { 50 | eEVENT_POST, 51 | eEVENT_REPLY, 52 | } eEventMethod; 53 | 54 | typedef enum _eEventDealType_ { 55 | eDEAL_REPLY_CB = 0, 56 | eDEAL_EXPIRED = 1, 57 | } eEventDealType; 58 | 59 | typedef struct _sReply_ { 60 | char client_token[EVENT_TOKEN_MAX_LEN]; // clientToken for this event reply 61 | void *user_context; // user context 62 | Timer timer; // timer for request timeout 63 | 64 | OnEventReplyCallback callback; // callback for this event reply 65 | } sEventReply; 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | #endif //_DATA_TEMPLATE_EVENT_H_ -------------------------------------------------------------------------------- /sdk_src/internal_inc/file_manage_client.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | 5 | * Licensed under the MIT License (the "License"); you may not use this file except in 6 | * compliance with the License. You may obtain a copy of the License at 7 | * http://opensource.org/licenses/MIT 8 | 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is 10 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 11 | * either express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | */ 15 | 16 | #ifndef IOT_FILE_MANAGE_CLIENT_H_ 17 | #define IOT_FILE_MANAGE_CLIENT_H_ 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #include 24 | #include "qcloud_iot_export_file_manage.h" 25 | 26 | #define MAX_FILE_WAIT_POST (10) 27 | 28 | typedef enum { 29 | eFILE_MANAGE_PROGRESS, 30 | eFILE_MANAGE_VERSION, 31 | eFILE_MANAGE_UPGRADE_RESULT, 32 | eFILE_MANAGE_POST_REQ, 33 | eFILE_MANAGE_POST_RESULT 34 | } eFileManageReportType; 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif /* IOT_FILE_MANAGE_CLIENT_H_ */ 41 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/log_upload.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef QCLOUD_IOT_LOG_UPLOAD_H_ 22 | #define QCLOUD_IOT_LOG_UPLOAD_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include "qcloud_iot_export_log.h" 29 | 30 | /** 31 | * @brief init the log upload functions 32 | * 33 | * @param init_params 34 | * @return QCLOUD_RET_SUCCESS when success 35 | */ 36 | int init_log_uploader(LogUploadInitParams *init_params); 37 | 38 | /** 39 | * @brief free log buffer and finish the log upload functions 40 | */ 41 | void fini_log_uploader(void); 42 | 43 | /** 44 | * @brief check if log uploader is init or not 45 | */ 46 | bool is_log_uploader_init(void); 47 | 48 | /** 49 | * @brief append one log item to upload buffer 50 | * 51 | * @param log_content 52 | * @param log_size 53 | * @return 0 when success, -1 when fail 54 | */ 55 | int append_to_upload_buffer(const char *log_content, size_t log_size); 56 | 57 | /** 58 | * @brief clear current upload buffer 59 | * 60 | * @return 61 | */ 62 | void clear_upload_buffer(void); 63 | 64 | /** 65 | * @brief do one upload to server 66 | * 67 | * @param force_upload if true, it will do upload right away, otherwise it will 68 | * check log_level, buffer left and upload interval 69 | * @return QCLOUD_RET_SUCCESS when success or no log to upload or timer is not 70 | * expired 71 | */ 72 | int do_log_upload(bool force_upload); 73 | 74 | /** 75 | * @brief set the log mqtt client to get system time 76 | * 77 | * @param client 78 | */ 79 | void set_log_mqtt_client(void *client); 80 | 81 | /** 82 | * @brief set if only do log upload when communication error with IoT Hub 83 | * 84 | * @param value if true, only do log upload when communication error with IoT 85 | * Hub 86 | */ 87 | void set_log_upload_in_comm_err(bool value); 88 | 89 | /** 90 | * @brief get current upload log_level from IoT Hub 91 | * 92 | * @param log_level 93 | * @return QCLOUD_RET_SUCCESS when success 94 | */ 95 | int qcloud_get_log_level(int *log_level); 96 | 97 | /** 98 | * @brief get the log mqtt client 99 | * 100 | * @return log mqtt client 101 | */ 102 | void *get_log_mqtt_client(void); 103 | 104 | /** 105 | * @brief get the device info of log client 106 | * 107 | * @return device info pointer of log client 108 | */ 109 | void *get_log_dev_info(void); 110 | 111 | #ifdef __cplusplus 112 | } 113 | #endif 114 | 115 | #endif // QCLOUD_IOT_LOG_UPLOAD_H_ 116 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/mqtt_client_net.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef IOT_MQTT_CLIENT_NET_H_ 22 | #define IOT_MQTT_CLIENT_NET_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include "network_interface.h" 29 | 30 | /** 31 | * @brief Init network stack 32 | * 33 | * @param pNetwork 34 | * @param pConnectParams 35 | * @return 0 for success 36 | */ 37 | int qcloud_iot_mqtt_network_init(Network *pNetwork); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif // IOT_MQTT_CLIENT_NET_H_ 44 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/ota_client.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef IOT_OTA_CLIENT_H_ 22 | #define IOT_OTA_CLIENT_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include 29 | 30 | /* Specify the maximum characters of version */ 31 | #define OTA_MAX_TOPIC_LEN (128) 32 | 33 | #define TYPE_FIELD "type" 34 | #define MD5_FIELD "md5sum" 35 | #define VERSION_FIELD "version" 36 | #define URL_FIELD "url" 37 | #define FILESIZE_FIELD "file_size" 38 | #define RESULT_FIELD "result_code" 39 | #define USER_DEFINED "user_defined" 40 | 41 | #define REPORT_VERSION_RSP "report_version_rsp" 42 | #define UPDATE_FIRMWARE "update_firmware" 43 | 44 | enum { MQTT_CHANNEL, COAP_CHANNEL }; 45 | 46 | typedef void (*OnOTAMessageCallback)(void *pcontext, const char *msg, uint32_t msgLen); 47 | 48 | void *qcloud_osc_init(const char *productId, const char *deviceName, void *channel, OnOTAMessageCallback callback, 49 | void *context); 50 | 51 | int qcloud_osc_deinit(void *handle); 52 | 53 | int qcloud_osc_report_progress(void *handle, const char *msg); 54 | 55 | int qcloud_osc_report_version(void *handle, const char *msg); 56 | 57 | int qcloud_osc_report_upgrade_result(void *handle, const char *msg); 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif /* IOT_OTA_CLIENT_H_ */ 64 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/ota_fetch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef IOT_OTA_FETCH_H_ 22 | #define IOT_OTA_FETCH_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include 29 | 30 | void *ofc_Init(const char *url, uint32_t offset, uint32_t file_size, uint32_t segment_size); 31 | 32 | int32_t qcloud_ofc_connect(void *handle); 33 | 34 | int32_t qcloud_ofc_fetch(void *handle, char *buf, uint32_t buf_len, uint32_t timeout_s); 35 | 36 | int qcloud_ofc_deinit(void *handle); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* IOT_OTA_FETCH_H_ */ 43 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/ota_lib.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef IOT_OTA_LIB_H_ 22 | #define IOT_OTA_LIB_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include 29 | 30 | #include "qcloud_iot_export_ota.h" 31 | 32 | void *qcloud_otalib_md5_init(void); 33 | 34 | void qcloud_otalib_md5_update(void *md5, const char *buf, size_t buf_len); 35 | 36 | void qcloud_otalib_md5_finalize(void *md5, char *output_str); 37 | 38 | void qcloud_otalib_md5_deinit(void *md5); 39 | 40 | int qcloud_otalib_get_firmware_type(const char *json, char **type); 41 | 42 | int qcloud_otalib_get_report_version_result(const char *json); 43 | 44 | /** 45 | * @brief Parse firmware info from JSON string 46 | * 47 | * @param json source JSON string 48 | * @param type parsed type 49 | * @param url parsed url 50 | * @param version parsed version 51 | * @param md5 parsed MD5 52 | * @param fileSize parsed file size 53 | * @param type parsed type 54 | * @param usr_defined_info parsed user defined information 55 | * @return QCLOUD_RET_SUCCESS for success, or err code for failure 56 | */ 57 | int qcloud_otalib_get_params(const char *json, char **type, char **url, char **version, char *md5, uint32_t *fileSize, 58 | char **usr_defined_info); 59 | 60 | /** 61 | * @brief Generate firmware info from id and version 62 | * 63 | * @param buf output buffer 64 | * @param bufLen size of buffer 65 | * @param id firmware id 66 | * @param version firmware version 67 | * @return QCLOUD_RET_SUCCESS for success, or err code for failure 68 | */ 69 | int qcloud_otalib_gen_info_msg(char *buf, size_t bufLen, uint32_t id, const char *version); 70 | 71 | /** 72 | * @brief Generate firmware report 73 | * 74 | * @param buf output buffer 75 | * @param bufLen size of buffer 76 | * @param id firmware id 77 | * @param version firmware version 78 | * @param progress download progress 79 | * @return QCLOUD_RET_SUCCESS for success, or err code for failure 80 | */ 81 | int qcloud_otalib_gen_report_msg(char *buf, size_t bufLen, uint32_t id, const char *version, int progress, 82 | IOT_OTAReportType reportType); 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif /* IOT_OTA_LIB_H_ */ 89 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/qcloud_iot_ca.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef IOT_CA_H_ 22 | #define IOT_CA_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | const char *iot_ca_get(void); 29 | 30 | const char *iot_https_ca_get(void); 31 | 32 | const char *iot_get_mqtt_domain(const char *region); 33 | 34 | const char *iot_get_dyn_reg_domain(const char *region); 35 | 36 | const char *iot_get_log_domain(const char *region); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* IOT_CA_H_ */ 43 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/qcloud_iot_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef QCLOUD_IOT_COMMON_H_ 22 | #define QCLOUD_IOT_COMMON_H_ 23 | 24 | /* IoT C-SDK APPID */ 25 | #define QCLOUD_IOT_DEVICE_SDK_APPID "21010406" 26 | #define QCLOUD_IOT_DEVICE_SDK_APPID_LEN (sizeof(QCLOUD_IOT_DEVICE_SDK_APPID) - 1) 27 | 28 | /* MQTT server domain */ 29 | #define QCLOUD_IOT_MQTT_DIRECT_DOMAIN "iotcloud.tencentdevices.com" 30 | #define QCLOUD_IOT_MQTT_US_EAST_DOMAIN "us-east.iotcloud.tencentdevices.com" 31 | #define QCLOUD_IOT_MQTT_EUROPE_DOMAIN "europe.iothub.tencentdevices.com" 32 | #define QCLOUD_IOT_MQTT_AP_BANGKOK_DOMAIN "ap-bangkok.iothub.tencentdevices.com" 33 | 34 | #define MQTT_SERVER_PORT_TLS 8883 35 | #define MQTT_SERVER_PORT_NOTLS 1883 36 | 37 | /* CoAP server domain */ 38 | #define QCLOUD_IOT_COAP_DIRECT_DOMAIN "iotcloud.tencentdevices.com" 39 | #define QCLOUD_IOT_COAP_US_EAST_DOMAIN "us-east.iotcloud.tencentdevices.com" 40 | #define QCLOUD_IOT_COAP_EUROPE_DOMAIN "europe.iothub.tencentdevices.com" 41 | #define QCLOUD_IOT_COAP_AP_BANGKOK_DOMAIN "ap-bangkok.iothub.tencentdevices.com" 42 | 43 | #define COAP_SERVER_PORT 5684 44 | 45 | /* server domain for dynamic registering device */ 46 | #define DYN_REG_SERVER_URL "gateway.tencentdevices.com" 47 | #define DYN_REG_SERVER_US_EAST_URL "us-east.gateway.tencentdevices.com" 48 | #define DYN_REG_SERVER_EUROPE_URL "europe.gateway.tencentdevices.com" 49 | #define DYN_REG_SERVER_AP_BANGKOK_URL "ap-bangkok.gateway.tencentdevices.com" 50 | 51 | #define DYN_REG_SERVER_PORT 80 52 | #define DYN_REG_SERVER_PORT_TLS 443 53 | 54 | /* URL for doing log upload */ 55 | #define LOG_UPLOAD_SERVER_DOMAIN "http://devicelog.iot.cloud.tencent.com/cgi-bin/report-log" 56 | #define LOG_UPLOAD_SERVER_US_EAST_DOMAIN "http://us-east.devicelog.iot.cloud.tencent.com/cgi-bin/report-log" 57 | #define LOG_UPLOAD_SERVER_EUROPE_DOMAIN "http://europe.devicelog.iot.cloud.tencent.com/cgi-bin/report-log" 58 | #define LOG_UPLOAD_SERVER_AP_BANGKOK_DOMAIN "http://ap-bangkok.devicelog.iot.cloud.tencent.com/cgi-bin/report-log" 59 | #define LOG_UPLOAD_SERVER_PATTEN "devicelog.iot.cloud.tencent.com" 60 | 61 | #define LOG_UPLOAD_SERVER_PORT 80 62 | 63 | /* Max size of a host name */ 64 | #define HOST_STR_LENGTH 64 65 | 66 | /* Max size of base64 encoded PSK = 64, after decode: 64/4*3 = 48*/ 67 | #define DECODE_PSK_LENGTH 48 68 | 69 | #endif /* QCLOUD_IOT_COMMON_H_ */ 70 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/qcloud_iot_device.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef IOT_DEVICE_H_ 22 | #define IOT_DEVICE_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include "qcloud_iot_export.h" 29 | #include "qcloud_iot_import.h" 30 | 31 | int iot_device_info_set(DeviceInfo *device_info, const char *product_id, const char *device_name); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif /* IOT_DEVICE_H_ */ 38 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/resource_client.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub available. 3 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights reserved. 4 | 5 | * Licensed under the MIT License (the "License"); you may not use this file except in 6 | * compliance with the License. You may obtain a copy of the License at 7 | * http://opensource.org/licenses/MIT 8 | 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is 10 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 11 | * either express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | */ 15 | 16 | #ifndef IOT_RESOURCE_CLIENT_H_ 17 | #define IOT_RESOURCE_CLIENT_H_ 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #include 24 | 25 | #include "qcloud_iot_export_resource.h" 26 | 27 | enum { MQTT_CHANNEL }; 28 | 29 | typedef struct qcloud_resource_upload_request { 30 | int resource_size; 31 | char *resource_name; 32 | char *resource_md5sum; 33 | } QCLOUD_RESOURCE_UPLOAD_REQUEST_S; 34 | 35 | typedef void (*OnResourceMessageCallback)(void *pcontext, char *msg, uint32_t msgLen); 36 | 37 | void *qcloud_resource_mqtt_init(const char *productId, const char *deviceName, void *channel, 38 | OnResourceMessageCallback callback, void *context); 39 | 40 | int qcloud_resource_mqtt_deinit(void *resource_mqtt); 41 | 42 | int qcloud_resource_mqtt_yield(void *resource_mqtt); 43 | 44 | int qcloud_resource_mqtt_upload_request(void *resource_mqtt, void *request_data); 45 | 46 | int qcloud_resource_mqtt_download_get(void *resource_mqtt); 47 | 48 | int qcloud_resource_mqtt_report_progress(void *resource_mqtt, QCLOUD_RESOURCE_REPORT_E state, 49 | QCLOUD_RESOURCE_RESULTCODE_E resultcode, int percent, char *resource_name, 50 | bool download); 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif /* IOT_RESOURCE_CLIENT_H_ */ 57 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/resource_lib.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub available. 3 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights reserved. 4 | 5 | * Licensed under the MIT License (the "License"); you may not use this file except in 6 | * compliance with the License. You may obtain a copy of the License at 7 | * http://opensource.org/licenses/MIT 8 | 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is 10 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 11 | * either express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | */ 15 | 16 | #ifndef IOT_RESOURCE_LIB_H_ 17 | #define IOT_RESOURCE_LIB_H_ 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #include 24 | #include 25 | 26 | void qcloud_lib_md5_init(void *ctx_md5); 27 | 28 | void qcloud_lib_md5_update(void *md5, const char *buf, size_t buf_len); 29 | 30 | void qcloud_lib_md5_finish_tolowercasehex(void *md5, char *output_str); 31 | 32 | void qcloud_lib_md5_deinit(void *md5); 33 | 34 | int qcloud_lib_get_json_key_value(char *json_obj, char *json_key, char **value); 35 | 36 | int qcloud_lib_base64encode_md5sum(char *md5sumhex, char *outbase64, int outbase64len); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* IOT_RESOURCE_LIB_H_ */ 43 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/resource_upload.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub available. 3 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights reserved. 4 | 5 | * Licensed under the MIT License (the "License"); you may not use this file except in 6 | * compliance with the License. You may obtain a copy of the License at 7 | * http://opensource.org/licenses/MIT 8 | 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is 10 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 11 | * either express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | */ 15 | 16 | #ifndef IOT_RESOURCE_UPLOAD_H_ 17 | #define IOT_RESOURCE_UPLOAD_H_ 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #include 24 | 25 | void *qcloud_resource_upload_http_init(const char *url, char *md5sum, int upload_len); 26 | 27 | int32_t qcloud_resource_upload_http_connect(void *handle); 28 | 29 | int32_t qcloud_resource_upload_http_send_body(void *handle, char *buf, uint32_t buf_len, uint32_t timeout_s); 30 | 31 | int32_t qcloud_resource_upload_http_recv(void *handle, char *buf, uint32_t bufLen, uint32_t timeout_s); 32 | 33 | int qcloud_resource_upload_http_deinit(void *handle); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif /* IOT_RESOURCE_UPLOAD_H_ */ 40 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/utils_base64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef QCLOUD_IOT_UTILS_BASE64_H_ 22 | #define QCLOUD_IOT_UTILS_BASE64_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include 29 | 30 | #include "qcloud_iot_export_error.h" 31 | #include "qcloud_iot_export_log.h" 32 | 33 | int qcloud_iot_utils_base64encode(unsigned char *dst, size_t dlen, size_t *olen, const unsigned char *src, size_t slen); 34 | 35 | int qcloud_iot_utils_base64decode(unsigned char *dst, size_t dlen, size_t *olen, const unsigned char *src, size_t slen); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | #endif /* QCLOUD_IOT_UTILS_BASE64_H_ */ 41 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/utils_hmac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef QCLOUD_IOT_UTILS_HMAC_H_ 22 | #define QCLOUD_IOT_UTILS_HMAC_H_ 23 | 24 | #include 25 | 26 | void utils_hmac_md5(const char *msg, int msg_len, char *digest, const char *key, int key_len); 27 | 28 | void utils_hmac_sha1(const char *msg, int msg_len, char *digest, const char *key, int key_len); 29 | 30 | int utils_hmac_sha1_hex(const char *msg, int msg_len, char *digest, const char *key, int key_len); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/utils_httpc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef QCLOUD_IOT_UTILS_HTTPC_H_ 22 | #define QCLOUD_IOT_UTILS_HTTPC_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include 29 | 30 | #include "network_interface.h" 31 | 32 | #define HTTP_PREFIX ("http://") 33 | #define HTTPS_PREFIX ("https://") 34 | #define HTTP_PORT 80 35 | #define HTTPS_PORT 443 36 | 37 | typedef enum { HTTP_GET, HTTP_POST, HTTP_PUT, HTTP_DELETE, HTTP_HEAD } HttpMethod; 38 | 39 | typedef struct { 40 | int remote_port; 41 | int response_code; 42 | char * header; 43 | char * auth_user; 44 | char * auth_password; 45 | Network network_stack; 46 | } HTTPClient; 47 | 48 | typedef struct { 49 | bool is_more; // if more data to check 50 | bool is_chunked; // if response in chunked data 51 | int retrieve_len; // length of retrieve 52 | int response_content_len; // length of resposne content 53 | int post_buf_len; // post data length 54 | int response_buf_len; // length of response data buffer 55 | char *post_content_type; // type of post content 56 | char *post_buf; // post data buffer 57 | char *response_buf; // response data buffer 58 | } HTTPClientData; 59 | 60 | /** 61 | * @brief do one http request 62 | * 63 | * @param client http client 64 | * @param url server url 65 | * @param port server port 66 | * @param ca_crt_dir ca path 67 | * @param method type of request 68 | * @param client_data http data 69 | * @return QCLOUD_RET_SUCCESS for success, or err code for failure 70 | */ 71 | int qcloud_http_client_common(HTTPClient *client, const char *url, int port, const char *ca_crt, HttpMethod method, 72 | HTTPClientData *client_data); 73 | 74 | int qcloud_http_recv_data(HTTPClient *client, uint32_t timeout_ms, HTTPClientData *client_data); 75 | 76 | int qcloud_http_send_data(HTTPClient *client, HttpMethod method, uint32_t timeout_ms, HTTPClientData *client_data); 77 | 78 | int qcloud_http_client_connect(HTTPClient *client, const char *url, int port, const char *ca_crt); 79 | 80 | void qcloud_http_client_close(HTTPClient *client); 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | #endif /* QCLOUD_IOT_UTILS_HTTPC_H_ */ 86 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/utils_list.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef QCLOUD_IOT_UTILS_LIST_H_ 22 | #define QCLOUD_IOT_UTILS_LIST_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include 29 | 30 | /* 31 | * ListNode iterator direction 32 | */ 33 | typedef enum { LIST_HEAD, LIST_TAIL } ListDirection; 34 | 35 | /* 36 | * define list node 37 | */ 38 | typedef struct ListNode { 39 | struct ListNode *prev; 40 | struct ListNode *next; 41 | void * val; 42 | } ListNode; 43 | 44 | /* 45 | * Double Linked List 46 | */ 47 | typedef struct { 48 | ListNode * head; 49 | ListNode * tail; 50 | unsigned int len; 51 | void (*free)(void *val); 52 | int (*match)(void *a, void *b); 53 | } List; 54 | 55 | /* 56 | * list iterator 57 | */ 58 | typedef struct { 59 | ListNode * next; 60 | ListDirection direction; 61 | } ListIterator; 62 | 63 | /* create node */ 64 | ListNode *list_node_new(void *val); 65 | 66 | /* create list */ 67 | List *qcloud_list_new(void); 68 | 69 | ListNode *qcloud_list_rpush(List *self, ListNode *node); 70 | 71 | ListNode *qcloud_list_lpush(List *self, ListNode *node); 72 | 73 | ListNode *qcloud_list_find(List *self, void *val); 74 | 75 | ListNode *qcloud_list_at(List *self, int index); 76 | 77 | ListNode *qcloud_list_rpop(List *self); 78 | 79 | ListNode *qcloud_list_lpop(List *self); 80 | 81 | void qcloud_list_remove(List *self, ListNode *node); 82 | 83 | void qcloud_list_destroy(List *self); 84 | 85 | /* create iterator */ 86 | ListIterator *qcloud_list_iterator_new(List *list, ListDirection direction); 87 | 88 | ListIterator *qcloud_list_iterator_new_from_node(ListNode *node, ListDirection direction); 89 | 90 | ListNode *qcloud_list_iterator_next(ListIterator *self); 91 | 92 | void qcloud_list_iterator_destroy(ListIterator *self); 93 | 94 | #ifdef __cplusplus 95 | } 96 | #endif 97 | #endif // QCLOUD_IOT_UTILS_LIST_H_ 98 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/utils_ringbuff.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef __AT_RING_BUFF_H__ 22 | #define __AT_RING_BUFF_H__ 23 | 24 | #include "stdbool.h" 25 | #include "stdint.h" 26 | 27 | #define RINGBUFF_OK 0 /* No error, everything OK. */ 28 | #define RINGBUFF_ERR -1 /* Out of memory error. */ 29 | #define RINGBUFF_EMPTY -3 /* Timeout. */ 30 | #define RINGBUFF_FULL -4 /* Routing problem. */ 31 | #define RINGBUFF_TOO_SHORT -5 32 | 33 | typedef struct _ring_buff_ { 34 | uint32_t size; 35 | uint32_t readpoint; 36 | uint32_t writepoint; 37 | char * buffer; 38 | bool full; 39 | } sRingbuff; 40 | 41 | typedef sRingbuff *ring_buff_t; 42 | 43 | int ring_buff_init(sRingbuff *ring_buff, char *buff, uint32_t size); 44 | int ring_buff_flush(sRingbuff *ring_buff); 45 | int ring_buff_push_data(sRingbuff *ring_buff, uint8_t *pData, int len); 46 | int ring_buff_pop_data(sRingbuff *ring_buff, uint8_t *pData, int len); 47 | #endif // __ringbuff_h__ 48 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/utils_sha1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef QCLOUD_IOT_UTILS_SHA1_H_ 22 | #define QCLOUD_IOT_UTILS_SHA1_H_ 23 | 24 | #include "qcloud_iot_import.h" 25 | 26 | /** 27 | * \brief SHA-1 context structure 28 | */ 29 | typedef struct { 30 | uint32_t total[2]; /*!< number of bytes processed */ 31 | uint32_t state[5]; /*!< intermediate digest state */ 32 | unsigned char buffer[64]; /*!< data block being processed */ 33 | } iot_sha1_context; 34 | 35 | /** 36 | * \brief Initialize SHA-1 context 37 | * 38 | * \param ctx SHA-1 context to be initialized 39 | */ 40 | void utils_sha1_init(iot_sha1_context *ctx); 41 | 42 | /** 43 | * \brief Clear SHA-1 context 44 | * 45 | * \param ctx SHA-1 context to be cleared 46 | */ 47 | void utils_sha1_free(iot_sha1_context *ctx); 48 | 49 | /** 50 | * \brief Clone (the state of) a SHA-1 context 51 | * 52 | * \param dst The destination context 53 | * \param src The context to be cloned 54 | */ 55 | void utils_sha1_clone(iot_sha1_context *dst, const iot_sha1_context *src); 56 | 57 | /** 58 | * \brief SHA-1 context setup 59 | * 60 | * \param ctx context to be initialized 61 | */ 62 | void utils_sha1_starts(iot_sha1_context *ctx); 63 | 64 | /** 65 | * \brief SHA-1 process buffer 66 | * 67 | * \param ctx SHA-1 context 68 | * \param input buffer holding the data 69 | * \param ilen length of the input data 70 | */ 71 | void utils_sha1_update(iot_sha1_context *ctx, const unsigned char *input, size_t ilen); 72 | 73 | /** 74 | * \brief SHA-1 final digest 75 | * 76 | * \param ctx SHA-1 context 77 | * \param output SHA-1 checksum result 78 | */ 79 | void utils_sha1_finish(iot_sha1_context *ctx, unsigned char output[20]); 80 | 81 | /* Internal use */ 82 | void utils_sha1_process(iot_sha1_context *ctx, const unsigned char data[64]); 83 | 84 | /** 85 | * \brief Output = SHA-1( input buffer ) 86 | * 87 | * \param input buffer holding the data 88 | * \param ilen length of the input data 89 | * \param output SHA-1 checksum result 90 | */ 91 | void utils_sha1(const unsigned char *input, size_t ilen, unsigned char output[20]); 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/utils_timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef QCLOUD_IOT_UTILS_TIMER_H_ 22 | #define QCLOUD_IOT_UTILS_TIMER_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | // Add the platform specific timer includes to define the Timer struct 29 | #include "qcloud_iot_import.h" 30 | 31 | /** 32 | * @brief Check if a timer is expired 33 | * 34 | * Call this function passing in a timer to check if that timer has expired. 35 | * 36 | * @param timer - pointer to the timer to be checked for expiration 37 | * @return bool - true = timer expired, false = timer not expired 38 | */ 39 | bool expired(Timer *timer); 40 | 41 | /** 42 | * @brief Create a timer (milliseconds) 43 | * 44 | * Sets the timer to expire in a specified number of milliseconds. 45 | * 46 | * @param timer - pointer to the timer to be set to expire in milliseconds 47 | * @param timeout_ms - set the timer to expire in this number of milliseconds 48 | */ 49 | void countdown_ms(Timer *timer, unsigned int timeout_ms); 50 | 51 | /** 52 | * @brief Create a timer (seconds) 53 | * 54 | * Sets the timer to expire in a specified number of seconds. 55 | * 56 | * @param timer - pointer to the timer to be set to expire in seconds 57 | * @param timeout - set the timer to expire in this number of seconds 58 | */ 59 | void countdown(Timer *timer, unsigned int timeout); 60 | 61 | /** 62 | * @brief Check the time remaining on a give timer 63 | * 64 | * Checks the input timer and returns the number of milliseconds remaining on 65 | * the timer. 66 | * 67 | * @param timer - pointer to the timer to be set to checked 68 | * @return int - milliseconds left on the countdown timer 69 | */ 70 | int left_ms(Timer *timer); 71 | 72 | /** 73 | * @brief Initialize a timer 74 | * 75 | * Performs any initialization required to the timer passed in. 76 | * 77 | * @param timer - pointer to the timer to be initialized 78 | */ 79 | void InitTimer(Timer *timer); 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif // QCLOUD_IOT_UTILS_TIMER_H_ 86 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/utils_url_download.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef UTILS_URL_DOWNLOAD_H_ 22 | #define UTILS_URL_DOWNLOAD_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include 29 | 30 | void *qcloud_url_download_init(const char *url, uint32_t offset, uint32_t file_size, uint32_t segment_size); 31 | 32 | int32_t qcloud_url_download_connect(void *handle, int https_enabled); 33 | 34 | int32_t qcloud_url_download_fetch(void *handle, char *buf, uint32_t bufLen, uint32_t timeout_s); 35 | 36 | int qcloud_url_download_deinit(void *handle); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* UTILS_URL_DOWNLOAD_H_ */ 43 | -------------------------------------------------------------------------------- /sdk_src/internal_inc/utils_url_upload.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef UTILS_URL_UPLOAD_H_ 22 | #define UTILS_URL_UPLOAD_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include 29 | 30 | void *qcloud_url_upload_init(const char *url, uint32_t content_len, char *custom_header); 31 | 32 | int32_t qcloud_url_upload_connect(void *handle, int method); 33 | 34 | int32_t qcloud_url_upload_body(void *handle, char *data_buf, uint32_t data_Len, uint32_t timeout_ms); 35 | 36 | int32_t qcloud_url_upload_recv_response(void *handle, char *response_buf, uint32_t bufLen, uint32_t timeout_ms); 37 | 38 | int qcloud_url_upload_deinit(void *handle); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif /* UTILS_URL_DOWNLOAD_H_ */ 45 | -------------------------------------------------------------------------------- /sdk_src/protocol/mqtt/mqtt_client_net.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights 5 | reserved. 6 | 7 | * Licensed under the MIT License (the "License"); you may not use this file 8 | except in 9 | * compliance with the License. You may obtain a copy of the License at 10 | * http://opensource.org/licenses/MIT 11 | 12 | * Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is 14 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, 16 | * either express or implied. See the License for the specific language 17 | governing permissions and 18 | * limitations under the License. 19 | * 20 | */ 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | #include "mqtt_client_net.h" 27 | 28 | // TODO: how to implement 29 | /** 30 | * @brief Check if TLS connection is valid 31 | * 32 | * @param pNetwork 33 | * @return 34 | */ 35 | int qcloud_iot_mqtt_tls_is_connected(Network *pNetwork) 36 | { 37 | return 1; 38 | } 39 | 40 | /** 41 | * @brief Init network stack 42 | * 43 | * @param pNetwork 44 | * @param pConnectParams 45 | * @return 46 | */ 47 | int qcloud_iot_mqtt_network_init(Network *pNetwork) 48 | { 49 | int rc; 50 | 51 | /* first choice: TLS */ 52 | pNetwork->type = NETWORK_TLS; 53 | 54 | #ifdef AUTH_WITH_NOTLS 55 | pNetwork->type = NETWORK_TCP; 56 | #endif 57 | 58 | rc = qcloud_iot_network_init(pNetwork); 59 | pNetwork->is_connected = qcloud_iot_mqtt_tls_is_connected; 60 | 61 | return rc; 62 | } 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | -------------------------------------------------------------------------------- /sdk_src/services/location/location.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Tencent is pleased to support the open source community by making IoT Hub available. 3 | * Copyright(C) 2018 - 2021 THL A29 Limited, a Tencent company.All rights reserved. 4 | * 5 | * Licensed under the MIT License(the "License"); you may not use this file except in 6 | * compliance with the License. You may obtain a copy of the License at 7 | * http://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is 10 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 11 | * either express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | */ 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include 21 | 22 | #include "qcloud_iot_export.h" 23 | #include "qcloud_iot_import.h" 24 | #include "mqtt_client.h" 25 | #include "service_mqtt.h" 26 | #include "json_parser.h" 27 | 28 | int IOT_Location_Capture_Fence_Aleart_Register(void *mqtt_client, void *callback, void *context) 29 | { 30 | int rc = -1; 31 | POINTER_SANITY_CHECK(mqtt_client, QCLOUD_ERR_INVAL); 32 | Qcloud_IoT_Client *m_client = (Qcloud_IoT_Client *)mqtt_client; 33 | rc = qcloud_service_mqtt_init(m_client->device_info.product_id, m_client->device_info.device_name, mqtt_client); 34 | if (rc < 0) { 35 | Log_e("service init failed: %d", rc); 36 | return rc; 37 | } 38 | return qcloud_service_mqtt_event_register(eSERVICE_LOCATION, callback, context); 39 | } 40 | 41 | int IOT_Location_Fence_Aleart_Reply(void *mqtt_client, char *client_token, int reply_code, char *reply_msg) 42 | { 43 | int rc; 44 | char message[256] = {0}; 45 | POINTER_SANITY_CHECK(mqtt_client, QCLOUD_ERR_INVAL); 46 | HAL_Snprintf(message, sizeof(message), 47 | "{\"method\":\"alert_fence_event_reply\", \"clientToken\":\"%s\", \"timestamp\":\"%ld\", " 48 | "\"code\":\"%d\", \"status\":\"%s\"}", 49 | client_token, HAL_Timer_current_sec(), reply_code, reply_msg); 50 | rc = qcloud_service_mqtt_post_msg(mqtt_client, message, QOS0); 51 | if (QCLOUD_RET_SUCCESS > rc) { 52 | Log_e("location fence aleart reply failed."); 53 | } 54 | return rc; 55 | } 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | -------------------------------------------------------------------------------- /sdk_src/services/ota/ota_fetch.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | #include "ota_fetch.h" 26 | 27 | #include 28 | 29 | #include "qcloud_iot_ca.h" 30 | #include "qcloud_iot_export.h" 31 | #include "qcloud_iot_import.h" 32 | #include "utils_url_download.h" 33 | 34 | void *ofc_Init(const char *url, uint32_t offset, uint32_t file_size, uint32_t segment_size) 35 | { 36 | return qcloud_url_download_init(url, offset, file_size, segment_size); 37 | } 38 | 39 | int32_t qcloud_ofc_connect(void *handle) 40 | { 41 | #ifdef OTA_USE_HTTPS 42 | return qcloud_url_download_connect(handle, 1); 43 | #endif 44 | return qcloud_url_download_connect(handle, 0); 45 | } 46 | 47 | int32_t qcloud_ofc_fetch(void *handle, char *buf, uint32_t bufLen, uint32_t timeout_s) 48 | { 49 | int rc = qcloud_url_download_fetch(handle, buf, bufLen, timeout_s); 50 | if (QCLOUD_RET_SUCCESS != rc) { 51 | if (rc == QCLOUD_ERR_HTTP_NOT_FOUND) 52 | IOT_FUNC_EXIT_RC(IOT_OTA_ERR_FETCH_NOT_EXIST); 53 | 54 | if (rc == QCLOUD_ERR_HTTP_AUTH) 55 | IOT_FUNC_EXIT_RC(IOT_OTA_ERR_FETCH_AUTH_FAIL); 56 | 57 | if (rc == QCLOUD_ERR_HTTP_TIMEOUT) 58 | IOT_FUNC_EXIT_RC(IOT_OTA_ERR_FETCH_TIMEOUT); 59 | } 60 | IOT_FUNC_EXIT_RC(rc); 61 | } 62 | 63 | int qcloud_ofc_deinit(void *handle) 64 | { 65 | return qcloud_url_download_deinit(handle); 66 | } 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | -------------------------------------------------------------------------------- /sdk_src/services/resource/resource_lib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub available. 3 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights reserved. 4 | 5 | * Licensed under the MIT License (the "License"); you may not use this file except in 6 | * compliance with the License. You may obtain a copy of the License at 7 | * http://opensource.org/licenses/MIT 8 | 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is 10 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 11 | * either express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | */ 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "resource_lib.h" 21 | 22 | #include 23 | #include 24 | 25 | #include "lite-utils.h" 26 | #include "ota_client.h" 27 | #include "qcloud_iot_export.h" 28 | #include "qcloud_iot_import.h" 29 | #include "utils_md5.h" 30 | #include "utils_base64.h" 31 | 32 | int qcloud_lib_get_json_key_value(char *json_obj, char *json_key, char **value) 33 | { 34 | *value = LITE_json_value_of(json_key, json_obj); 35 | if (NULL == *value) { 36 | Log_e("Not '%s' key in json doc", STRING_PTR_PRINT_SANITY_CHECK(json_key)); 37 | return QCLOUD_RESOURCE_ERRCODE_FAIL_E; 38 | } 39 | 40 | return QCLOUD_RET_SUCCESS; 41 | } 42 | 43 | void qcloud_lib_md5_init(void *ctx_md5) 44 | { 45 | iot_md5_context *ctx = (iot_md5_context *)ctx_md5; 46 | if (NULL == ctx) { 47 | return; 48 | } 49 | 50 | utils_md5_init(ctx); 51 | utils_md5_starts(ctx); 52 | 53 | return; 54 | } 55 | 56 | void qcloud_lib_md5_update(void *md5, const char *buf, size_t buf_len) 57 | { 58 | utils_md5_update(md5, (unsigned char *)buf, buf_len); 59 | } 60 | 61 | void qcloud_lib_md5_finish_tolowercasehex(void *md5, char *output_str) 62 | { 63 | int i; 64 | unsigned char buf_out[16]; 65 | utils_md5_finish(md5, buf_out); 66 | 67 | for (i = 0; i < 16; ++i) { 68 | output_str[i * 2] = utils_hb2hex(buf_out[i] >> 4); 69 | output_str[i * 2 + 1] = utils_hb2hex(buf_out[i]); 70 | } 71 | output_str[32] = '\0'; 72 | } 73 | 74 | int qcloud_lib_base64encode_md5sum(char *md5sumhex, char *outbase64, int outbase64len) 75 | { 76 | char md5[17]; 77 | size_t olen; 78 | 79 | for (int index = 0; index < 16; index++) { 80 | if (md5sumhex[index * 2] < 'a') { 81 | md5[index] = ((md5sumhex[index * 2] - '0') << 4); 82 | } else { 83 | md5[index] = ((10 + (md5sumhex[index * 2] - 'a')) << 4); 84 | } 85 | 86 | if (md5sumhex[index * 2 + 1] < 'a') { 87 | md5[index] += ((md5sumhex[index * 2 + 1] - '0')); 88 | } else { 89 | md5[index] += (10 + (md5sumhex[index * 2 + 1] - 'a')); 90 | } 91 | } 92 | 93 | qcloud_iot_utils_base64encode((unsigned char *)outbase64, outbase64len, &olen, (unsigned char *)md5, 16); 94 | 95 | return (olen > outbase64len) ? QCLOUD_ERR_FAILURE : QCLOUD_RET_SUCCESS; 96 | } 97 | 98 | void qcloud_lib_md5_deinit(void *md5) 99 | { 100 | if (NULL != md5) { 101 | memset(md5, 0, sizeof(iot_md5_context)); 102 | } 103 | } 104 | 105 | #ifdef __cplusplus 106 | } 107 | #endif 108 | -------------------------------------------------------------------------------- /sdk_src/services/resource/resource_upload.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub available. 3 | * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights reserved. 4 | 5 | * Licensed under the MIT License (the "License"); you may not use this file except in 6 | * compliance with the License. You may obtain a copy of the License at 7 | * http://opensource.org/licenses/MIT 8 | 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is 10 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 11 | * either express or implied. See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | */ 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "resource_upload.h" 21 | #include "utils_url_upload.h" 22 | #include 23 | 24 | #include "qcloud_iot_ca.h" 25 | #include "qcloud_iot_export.h" 26 | #include "qcloud_iot_import.h" 27 | #include "utils_httpc.h" 28 | #include "resource_lib.h" 29 | 30 | #define RESOURCE_HTTP_HEAD_CONTENT_LEN 256 31 | 32 | void *qcloud_resource_upload_http_init(const char *url, char *md5sum, int upload_len) 33 | { 34 | char base64md5[33] = {0}; 35 | char header[RESOURCE_HTTP_HEAD_CONTENT_LEN]; 36 | qcloud_lib_base64encode_md5sum(md5sum, base64md5, sizeof(base64md5)); 37 | 38 | HAL_Snprintf(header, RESOURCE_HTTP_HEAD_CONTENT_LEN, 39 | "Content-MD5:%s\r\n" 40 | "Content-Type: application/x-www-form-urlencoded\r\n" 41 | "Content-Length: %d\r\n", 42 | base64md5, upload_len); 43 | 44 | return qcloud_url_upload_init(url, 0, header); 45 | } 46 | 47 | int32_t qcloud_resource_upload_http_connect(void *handle) 48 | { 49 | return qcloud_url_upload_connect(handle, HTTP_PUT); 50 | } 51 | 52 | int32_t qcloud_resource_upload_http_send_body(void *handle, char *buf, uint32_t buf_len, uint32_t timeout_s) 53 | { 54 | return qcloud_url_upload_body(handle, buf, buf_len, timeout_s); 55 | } 56 | 57 | int32_t qcloud_resource_upload_http_recv(void *handle, char *buf, uint32_t bufLen, uint32_t timeout_s) 58 | { 59 | IOT_FUNC_ENTRY; 60 | int rc; 61 | rc = qcloud_url_upload_recv_response(handle, buf, bufLen, timeout_s * 1000); 62 | 63 | if (QCLOUD_RET_SUCCESS != rc) { 64 | if (rc == QCLOUD_ERR_HTTP_NOT_FOUND) 65 | IOT_FUNC_EXIT_RC(QCLOUD_RESOURCE_ERRCODE_FETCH_NOT_EXIST_E); 66 | 67 | if (rc == QCLOUD_ERR_HTTP_AUTH) 68 | IOT_FUNC_EXIT_RC(QCLOUD_RESOURCE_ERRCODE_FETCH_AUTH_FAIL_E); 69 | 70 | if (rc == QCLOUD_ERR_HTTP_TIMEOUT) 71 | IOT_FUNC_EXIT_RC(QCLOUD_RESOURCE_ERRCODE_FETCH_TIMEOUT_E); 72 | } 73 | 74 | IOT_FUNC_EXIT_RC(rc); 75 | } 76 | 77 | int qcloud_resource_upload_http_deinit(void *handle) 78 | { 79 | return qcloud_url_upload_deinit(handle); 80 | } 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | -------------------------------------------------------------------------------- /sdk_src/utils/qcloud_iot_device.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | #include "qcloud_iot_device.h" 25 | 26 | #include 27 | #include 28 | 29 | #include "qcloud_iot_export.h" 30 | 31 | int iot_device_info_set(DeviceInfo *device_info, const char *product_id, const char *device_name) 32 | { 33 | memset(device_info, 0x0, sizeof(DeviceInfo)); 34 | if ((MAX_SIZE_OF_PRODUCT_ID) < strlen(product_id)) { 35 | Log_e("product name(%s) length:(%lu) exceeding limitation", product_id, strlen(product_id)); 36 | return QCLOUD_ERR_FAILURE; 37 | } 38 | if ((MAX_SIZE_OF_DEVICE_NAME) < strlen(device_name)) { 39 | Log_e("device name(%s) length:(%lu) exceeding limitation", device_name, strlen(device_name)); 40 | return QCLOUD_ERR_FAILURE; 41 | } 42 | 43 | strncpy(device_info->product_id, product_id, MAX_SIZE_OF_PRODUCT_ID); 44 | strncpy(device_info->device_name, device_name, MAX_SIZE_OF_DEVICE_NAME); 45 | 46 | /* construct device-id(@product_id+@device_name) */ 47 | memset(device_info->client_id, 0x0, MAX_SIZE_OF_CLIENT_ID); 48 | int ret = HAL_Snprintf(device_info->client_id, MAX_SIZE_OF_CLIENT_ID, "%s%s", 49 | STRING_PTR_PRINT_SANITY_CHECK(product_id), STRING_PTR_PRINT_SANITY_CHECK(device_name)); 50 | if ((ret < 0) || (ret >= MAX_SIZE_OF_CLIENT_ID)) { 51 | Log_e("set device info failed"); 52 | return QCLOUD_ERR_FAILURE; 53 | } 54 | 55 | Log_i("SDK_Ver: %s, Product_ID: %s, Device_Name: %s", QCLOUD_IOT_DEVICE_SDK_VERSION, device_info->product_id, 56 | device_info->device_name); 57 | return QCLOUD_RET_SUCCESS; 58 | } 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | -------------------------------------------------------------------------------- /sdk_src/utils/utils_getopt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2019 Tencent Group. All rights reserved. 3 | * License-Identifier: Apache-2.0 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 6 | * not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | 19 | #include "utils_getopt.h" 20 | 21 | #include 22 | #include 23 | 24 | #include "qcloud_iot_import.h" 25 | 26 | static int utils_opterr = 1; /* if error message should be printed */ 27 | static int utils_optind = 1; /* index into parent argv vector */ 28 | static int utils_optopt; /* character checked for validity */ 29 | static int utils_optreset = 1; /* reset getopt */ 30 | 31 | char *utils_optarg; /* argument associated with option */ 32 | 33 | int utils_getopt(int nargc, char *const *nargv, const char *options) 34 | { 35 | #define BADCH (int)'?' 36 | #define BADARG (int)':' 37 | #define EMSG "" 38 | 39 | static char *place = EMSG; /* option letter processing */ 40 | const char * oli; /* option letter list index */ 41 | 42 | if (utils_optreset || !*place) { /* update scanning pointer */ 43 | utils_optreset = 0; 44 | 45 | if (utils_optind >= nargc || *(place = nargv[utils_optind]) != '-') { 46 | utils_optind = 1; 47 | utils_optreset = 1; 48 | place = EMSG; 49 | return (-1); 50 | } 51 | 52 | place++; 53 | } 54 | 55 | /* option letter okay? */ 56 | if ((utils_optopt = (int)*place++) == (int)':' || !(oli = strchr(options, utils_optopt))) { 57 | /* 58 | * if the user didn't specify '-' as an option, 59 | * assume it means -1. 60 | */ 61 | if (utils_optopt == (int)'-') 62 | return (-1); 63 | 64 | if (!*place) 65 | ++utils_optind; 66 | 67 | if (utils_opterr && *options != ':') 68 | HAL_Printf("illegal option - %c\n", utils_optopt); 69 | 70 | return (BADCH); 71 | } 72 | 73 | if (*++oli != ':') { /* don't need argument */ 74 | utils_optarg = NULL; 75 | if (!*place) 76 | ++utils_optind; 77 | } else { 78 | /* need an argument */ 79 | if (*place) /* no white space */ 80 | utils_optarg = place; 81 | else if (nargc <= ++utils_optind) { /* no arg */ 82 | place = EMSG; 83 | if (*options == ':') 84 | return (BADARG); 85 | if (utils_opterr) 86 | HAL_Printf("option requires an argument - %c\n", utils_optopt); 87 | return (BADCH); 88 | } else /* white space */ 89 | utils_optarg = nargv[utils_optind]; 90 | 91 | place = EMSG; 92 | ++utils_optind; 93 | } 94 | 95 | /* dump back option letter */ 96 | return (utils_optopt); 97 | } 98 | -------------------------------------------------------------------------------- /sdk_src/utils/utils_ringbuff.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #include "utils_ringbuff.h" 22 | 23 | #include 24 | #include 25 | 26 | int ring_buff_init(sRingbuff *ring_buff, char *buff, uint32_t size) 27 | { 28 | ring_buff->buffer = buff; 29 | ring_buff->size = size; 30 | ring_buff->readpoint = 0; 31 | ring_buff->writepoint = 0; 32 | memset(ring_buff->buffer, 0, ring_buff->size); 33 | ring_buff->full = false; 34 | 35 | return RINGBUFF_OK; 36 | } 37 | 38 | int ring_buff_flush(sRingbuff *ring_buff) 39 | { 40 | ring_buff->readpoint = 0; 41 | ring_buff->writepoint = 0; 42 | memset(ring_buff->buffer, 0, ring_buff->size); 43 | ring_buff->full = false; 44 | 45 | return RINGBUFF_OK; 46 | } 47 | 48 | int ring_buff_push_data(sRingbuff *ring_buff, uint8_t *pData, int len) 49 | { 50 | int i; 51 | 52 | if (len > ring_buff->size) { 53 | return RINGBUFF_TOO_SHORT; 54 | } 55 | 56 | for (i = 0; i < len; i++) { 57 | if (((ring_buff->writepoint + 1) % ring_buff->size) == ring_buff->readpoint) { 58 | ring_buff->full = true; 59 | return RINGBUFF_FULL; 60 | } else { 61 | if (ring_buff->writepoint < (ring_buff->size - 1)) { 62 | ring_buff->writepoint++; 63 | } else { 64 | ring_buff->writepoint = 0; 65 | } 66 | ring_buff->buffer[ring_buff->writepoint] = pData[i]; 67 | } 68 | } 69 | 70 | return RINGBUFF_OK; 71 | } 72 | 73 | int ring_buff_pop_data(sRingbuff *ring_buff, uint8_t *pData, int len) 74 | { 75 | int i; 76 | 77 | if (len > ring_buff->size) { 78 | return RINGBUFF_TOO_SHORT; 79 | } 80 | 81 | for (i = 0; i < len; i++) { 82 | if (ring_buff->writepoint == ring_buff->readpoint) { 83 | break; 84 | } else { 85 | if (ring_buff->readpoint == (ring_buff->size - 1)) { 86 | ring_buff->readpoint = 0; 87 | } 88 | 89 | else { 90 | ring_buff->readpoint++; 91 | } 92 | pData[i] = ring_buff->buffer[ring_buff->readpoint]; 93 | } 94 | } 95 | 96 | return i; 97 | } 98 | -------------------------------------------------------------------------------- /sdk_src/utils/utils_timer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making IoT Hub 3 | available. 4 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 5 | 6 | * Licensed under the MIT License (the "License"); you may not use this file 7 | except in 8 | * compliance with the License. You may obtain a copy of the License at 9 | * http://opensource.org/licenses/MIT 10 | 11 | * Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, 15 | * either express or implied. See the License for the specific language 16 | governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | #include "utils_timer.h" 26 | 27 | bool expired(Timer *timer) 28 | { 29 | return HAL_Timer_expired(timer); 30 | } 31 | 32 | void countdown_ms(Timer *timer, unsigned int timeout_ms) 33 | { 34 | HAL_Timer_countdown_ms(timer, timeout_ms); 35 | } 36 | 37 | void countdown(Timer *timer, unsigned int timeout) 38 | { 39 | HAL_Timer_countdown(timer, timeout); 40 | } 41 | 42 | int left_ms(Timer *timer) 43 | { 44 | return HAL_Timer_remain(timer); 45 | } 46 | 47 | void InitTimer(Timer *timer) 48 | { 49 | HAL_Timer_init(timer); 50 | } 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | -------------------------------------------------------------------------------- /tools/build_scripts/function_rename.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # C-SDK函数和外部函数命名冲突时使用此脚本对C-SDK函数重命名 3 | CUR_FOLDER=$(dirname "$0") 4 | 5 | if [ $# != 2 ];then 6 | echo "USAGE: $0 old_name new_name" 7 | exit 8 | fi 9 | 10 | cd $CUR_FOLDER || exit 11 | echo "Replace $1 with $2 in C-SDK" 12 | sed -i "s/$1/$2/g" `grep -rwl $1 ../../*` 13 | -------------------------------------------------------------------------------- /tools/build_scripts/rules-tests.mk: -------------------------------------------------------------------------------- 1 | .PHONY: run_demo_test demo_test_clean run_unit_test run_multi_thread_test \ 2 | coap_run_demo_test coap_demo_test_clean 3 | 4 | tests: run_demo_test run_unit_test run_multi_thread_test coap_run_demo_test 5 | -------------------------------------------------------------------------------- /tools/build_scripts/stats_static_lib.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | TARGET=$1 4 | TEMPD=$(mktemp -d -t STATD-XXXX) 5 | TEMPF=$(mktemp -t STATF-XXXX) 6 | 7 | #echo "TARGET = ${TARGET}" 8 | #echo "STAGED = ${STAGED}" 9 | #echo "TEMPD = ${TEMPD}" 10 | 11 | if [ ! -f ${TARGET} ] || [ ! -d ${STAGED} ]; then 12 | echo "Invalid Env" 13 | exit 1 14 | fi 15 | 16 | cp ${TARGET} ${TEMPD} 17 | cd ${TEMPD} 18 | ar xf $(basename ${TARGET}) 19 | rm -f $(basename ${TARGET}) 20 | ${STRIP} *.o > /dev/null 2>&1 21 | 22 | NAME=$1 23 | for obj in $(ls *.o); do 24 | dir=$(find ${STAGED} -name ${obj}|xargs dirname|xargs basename) 25 | printf "%-12s %-32s %s\n" $(basename $1) ${obj} $(du -b ${obj}|awk '{ print $1 }') 26 | done | sort > ${TEMPF} 27 | 28 | MODS=$(cat ${TEMPF}|awk '{ print $1 }'|sort -u) 29 | 30 | TOTAL=$(cat ${TEMPF}|awk '{ sum += $3 } END { print sum }') 31 | # echo "TOTAL = ${TOTAL}" 32 | 33 | SMODS=$( \ 34 | for mod in ${MODS}; do \ 35 | MSIZE=$(grep "^${mod}" ${TEMPF}|awk '{ sum += $3 } END { print sum }'); \ 36 | printf "%-8s %s\n" \ 37 | $(awk -v a=${MSIZE} -v b=${TOTAL} 'BEGIN { printf("%.2f%%\n", a/b*100); }') \ 38 | "${mod}"; \ 39 | done | sort -nr | awk '{ print $2 }' \ 40 | ) 41 | 42 | echo "" 43 | for mod in ${SMODS}; do 44 | MSIZE=$(grep "^${mod}" ${TEMPF}|awk '{ sum += $3 } END { print sum }') 45 | OBJS=$(grep "^${mod}" ${TEMPF}|awk '{ print $2 }') 46 | for obj in ${OBJS}; do 47 | FSIZE=$(grep "\<${obj}\>" ${TEMPF}|awk '{ print $3 }') 48 | printf " %-8s %28s | %-8s %8s %-8s\n" \ 49 | $(awk -v a=${FSIZE} -v b=${MSIZE} 'BEGIN { printf("%.2f%%\n", a/b*100); }') \ 50 | "${obj}" "${mod}" "${FSIZE} /" "${MSIZE}" 51 | done | sort -nr 52 | echo " -----------------------------------------------------------------" 53 | done 54 | 55 | echo "" 56 | for mod in ${MODS}; do 57 | MSIZE=$(grep "^${mod}" ${TEMPF}|awk '{ sum += $3 } END { print sum }') 58 | printf " %-8s %-12s %16s\n" \ 59 | $(awk -v a=${MSIZE} -v b=${TOTAL} 'BEGIN { printf("%.2f%%\n", a/b*100); }') \ 60 | "[ ${mod} ]" "${MSIZE} Bytes" 61 | done | sort -nr 62 | 63 | cd "${OLDPWD}" 64 | rm -rf ${TEMPD} 65 | rm -f ${TEMPF} 66 | -------------------------------------------------------------------------------- /tools/build_scripts/update_gtest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | GOOGLE_TEST="external_libs/googletest" 4 | 5 | if [ ! -d ${GOOGLE_TEST} ]; then 6 | git clone -q packages/gtest_module.git ${GOOGLE_TEST} 7 | else 8 | cd ${GOOGLE_TEST} 9 | git pull -q 10 | cd - 11 | fi -------------------------------------------------------------------------------- /tools/build_scripts/update_mbedtls.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | MBEDTLS_DIR="external_libs/mbedtls" 4 | 5 | if [ ! -d ${MBEDTLS_DIR} ]; then 6 | git clone -q packages/mbedtls_module.git ${MBEDTLS_DIR} 7 | else 8 | cd ${MBEDTLS_DIR} 9 | git pull -q 10 | cd - 11 | fi 12 | -------------------------------------------------------------------------------- /tools/cmake_scripts/config.h.in: -------------------------------------------------------------------------------- 1 | #cmakedefine AUTH_MODE_CERT 2 | #cmakedefine AUTH_MODE_KEY 3 | #cmakedefine AUTH_WITH_NOTLS 4 | #cmakedefine GATEWAY_ENABLED 5 | #cmakedefine GATEWAY_AUTOMATION_ENABLED 6 | #cmakedefine GATEWAY_SCENE_ENABLED 7 | #cmakedefine GATEWAY_GROUP_ENABLED 8 | #cmakedefine COAP_COMM_ENABLED 9 | #cmakedefine OTA_MQTT_CHANNEL 10 | #cmakedefine SYSTEM_COMM 11 | #cmakedefine EVENT_POST_ENABLED 12 | #cmakedefine ACTION_ENABLED 13 | #cmakedefine DEV_DYN_REG_ENABLED 14 | #cmakedefine LOG_UPLOAD 15 | #cmakedefine IOT_DEBUG 16 | #cmakedefine DEBUG_DEV_INFO_USED 17 | #cmakedefine AT_TCP_ENABLED 18 | #cmakedefine AT_UART_RECV_IRQ 19 | #cmakedefine AT_OS_USED 20 | #cmakedefine AT_DEBUG 21 | #cmakedefine OTA_USE_HTTPS 22 | #cmakedefine GATEWAY_ENABLED 23 | #cmakedefine MULTITHREAD_ENABLED 24 | #cmakedefine GATEWAY_DYN_BIND_SUBDEV_ENABLED 25 | #cmakedefine ASR_ENABLED 26 | #cmakedefine RESOURCE_UPDATE_ENABLED 27 | #cmakedefine WIFI_CONFIG_ENABLED 28 | #cmakedefine KGMUSIC_ENABLED 29 | #cmakedefine QQMUSIC_ENABLED -------------------------------------------------------------------------------- /tools/cmake_scripts/convert.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $1 == "linux" ]; then 4 | find $2 -type f -name "*.h" -print -o -name "*.c" -print | xargs -i sed -i '1 s/^\xef\xbb\xbf//' {} 5 | echo "Convert source files to Unix format!!!" 6 | elif [ $1 == "windows" ]; then 7 | find $2 -type f -name "*.h" -print -o -name "*.c" -print | xargs -i sed -i '1 s/^/\xef\xbb\xbf&/' {} 8 | echo "Convert source files to Windows format!!!" 9 | else 10 | echo "Invaild argument!" 11 | echo "Please choose windows or linux !!!" 12 | fi 13 | -------------------------------------------------------------------------------- /tools/test_file/test.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TencentCloud/tencentcloud-iot-explorer-sdk-embedded-c/48d928ceb9c8350d29ef0f87f125ce1292a0111c/tools/test_file/test.wav --------------------------------------------------------------------------------