/** * @copyright * * Tencent is pleased to support the open source community by making IoT Hub available. * Copyright(C) 2018 - 2021 THL A29 Limited, a Tencent company.All rights reserved. * * Licensed under the MIT License(the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://opensource.org/licenses/MIT * * Unless required by applicable law or agreed to in writing, software distributed under the License is * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language governing permissions and * limitations under the License. * * @file cos_download_sample.c * @brief * @author fancyxu (fancyxu@tencent.com) * @version 1.0 * @date 2021-10-27 * * @par Change Log: * *
Date Version Author Description *
2021-10-27 1.0 fancyxu first commit *
*/ #include #include #include #include #include "qcloud_iot_common.h" #include "utils_log.h" // ---------------------------------------------------------------------------- // Main // ---------------------------------------------------------------------------- static int sg_main_exit = 0; #ifdef __linux__ #include #include #include static void _main_exit(int sig) { Log_e("demo exit by signal:%d\n", sig); sg_main_exit = 1; } #endif int main(int argc, char **argv) { #ifdef __linux__ signal(SIGINT, _main_exit); #endif int rc = 0; // init log level LogHandleFunc func = {0}; func.log_malloc = HAL_Malloc; func.log_free = HAL_Free; func.log_get_current_time_str = HAL_Timer_Current; func.log_printf = HAL_Printf; utils_log_init(func, LOG_LEVEL_DEBUG, 2048); DeviceInfo device_info; // 1. get device info rc = HAL_GetDevInfo((void *)&device_info); if (rc) { Log_e("get device info failed: %d", rc); return rc; } // 2. do dynreg rc = IOT_DynReg_Device(&device_info); if (rc) { Log_e("dynreg error"); goto exit; } // 3. get device secret just save it. then you can do mqtt HAL_SetDevInfo(&device_info); Log_i("device secret : %s", device_info.device_secret); exit: utils_log_deinit(); return rc; }