tos_kernel_sig_init

tos_kernel_sig_init
This commit is contained in:
Supowang
2022-06-28 13:02:03 +08:00
parent c18f082949
commit 2be1169b0b
8376 changed files with 0 additions and 7963023 deletions

View File

@@ -1,104 +0,0 @@
/**
* @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 utils_downloader.h
* @brief
* @author fancyxu (fancyxu@tencent.com)
* @version 1.0
* @date 2021-10-20
*
* @par Change Log:
* <table>
* <tr><th>Date <th>Version <th>Author <th>Description
* <tr><td>2021-10-20 <td>1.0 <td>fancyxu <td>first commit
* </table>
*/
#ifndef IOT_HUB_DEVICE_C_SDK_COMMON_UTILS_INC_UTILS_DOWNLOADER_H_
#define IOT_HUB_DEVICE_C_SDK_COMMON_UTILS_INC_UTILS_DOWNLOADER_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
/**
* @brief Downloader status.
*
*/
typedef enum {
UTILS_DOWNLOADER_STATUS_SUCCESS = 0,
UTILS_DOWNLOADER_STATUS_BREAK_POINT_FAILED,
UTILS_DOWNLOADER_STATUS_DATA_DOWNLOAD_FAILED,
UTILS_DOWNLOADER_STATUS_NETWORK_FAILED
} UtilsDownloaderStatus;
/**
* @brief Downloader function.
*
*/
typedef struct {
// memory
void* (*downloader_malloc)(size_t len); /**< user malloc */
void (*downloader_free)(void* val); /**< user free */
// break point
int (*break_point_init)(void* usr_data); /**< init break point, read from flash or file */
void (*break_point_deinit)(void* usr_data); /**< deinit break point */
int (*break_point_set)(void* usr_data); /**< set break point structure */
int (*break_point_save)(void* usr_data); /**< save break point in flash or file */
int (*break_point_check)(void* usr_data); /**< check break point valid */
int (*break_point_restore)(void* usr_data); /**< restore break point */
// data download
int (*data_download_init)(void* usr_data); /**< init data download, such as http connect */
void (*data_download_deinit)(void* usr_data); /**< deinit data download, such as http disconnect */
int (*data_download_is_over)(void* usr_data); /**< check if download finish */
int (*data_download_recv)(void* usr_data); /**< recv data, such as http recv */
int (*data_download_save)(void* usr_data); /**< save data, such as write firmware to flash */
int (*data_download_finish)(void* usr_data, UtilsDownloaderStatus status); /**< process result */
} UtilsDownloaderFunction;
/**
* @brief Init downloader.
*
* @param[in] func download function should implement
* @param[in] usr_data user data using in function
* @return pointer to downloader
*/
void* utils_downloader_init(UtilsDownloaderFunction func, void* usr_data);
/**
* @brief Process download using function.
*
* @param[in,out] handle pointer to downloader
* @return -1 for fail, others see data_download_finish
*/
int utils_downloader_process(void* handle);
/**
* @brief Deinit downloader.
*
* @param[in,out] handle pointer to downloader
*/
void utils_downloader_deinit(void* handle);
#ifdef __cplusplus
}
#endif
#endif // IOT_HUB_DEVICE_C_SDK_COMMON_UTILS_INC_UTILS_DOWNLOADER_H_

View File

@@ -1,108 +0,0 @@
/**
* @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 utils_json.h
* @brief
* @author fancyxu (fancyxu@tencent.com)
* @version 1.0
* @date 2021-07-24
*
* @par Change Log:
* <table>
* <tr><th>Date <th>Version <th>Author <th>Description
* <tr><td>2021-07-24 <td>1.0 <td>fancyxu <td>first commit
* <tr><td>2021-07-29 <td>1.1 <td>fancyxu <td>fix bug and add utils_json_value_data_get
* </table>
*/
#ifndef IOT_HUB_DEVICE_C_SDK_COMMON_UTILS_INC_UTILS_JSON_H_
#define IOT_HUB_DEVICE_C_SDK_COMMON_UTILS_INC_UTILS_JSON_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <inttypes.h>
/**
* @brief Json value type
*
*/
typedef enum {
UTILS_JSON_VALUE_TYPE_INT32 = 0,
UTILS_JSON_VALUE_TYPE_INT64,
UTILS_JSON_VALUE_TYPE_UINT32,
UTILS_JSON_VALUE_TYPE_UINT64,
UTILS_JSON_VALUE_TYPE_FLOAT,
UTILS_JSON_VALUE_TYPE_DOUBLE,
UTILS_JSON_VALUE_TYPE_BOOLEAN,
} UtilsJsonValueType;
/**
* @brief Json value
*
*/
typedef struct {
const char *value;
int value_len;
} UtilsJsonValue;
/**
* @brief Get value from json string. Not strict, just for iot scene, we suppose all the string is valid json.
*
* @param[in] key key in json, support nesting with '.'
* @param[in] key_len key len
* @param[in] src json string
* @param[in] src_len src length
* @param[out] value value
* @return 0 for success
*/
int utils_json_value_get(const char *key, int key_len, const char *src, int src_len, UtilsJsonValue *value);
/**
* @brief Get data of value with type.
*
* @param[in] value @see UtilsJsonValue
* @param[in] type value type, string can use value directly @see UtilsJsonValueType
* @param[out] data data pointer, user should match the type
* @return 0 for success
*/
int utils_json_value_data_get(UtilsJsonValue value, UtilsJsonValueType type, void *data);
/**
* @brief Return unsigned int value of key in json.
*
* @return 0 for success
*/
int utils_json_get_uint32(const char *key, int key_len, const char *src, int src_len, uint32_t *data);
/**
* @brief Remove '\\' in json string.
*
* @param[in,out] src string to transfer
* @param[in] src_len string len
* @return length after transfer
*/
int utils_json_strip_transfer(char *src, int src_len);
#ifdef __cplusplus
}
#endif
#endif // IOT_HUB_DEVICE_C_SDK_COMMON_UTILS_INC_UTILS_JSON_H_

View File

@@ -1,140 +0,0 @@
/**
* @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 utils_list.h
* @brief header file for utils list
* @author fancyxu (fancyxu@tencent.com)
* @version 1.0
* @date 2021-05-25
*
* @par Change Log:
* <table>
* <tr><th>Date <th>Version <th>Author <th>Description
* <tr><td>2021-05-25 <td>1.0 <td>fancyxu <td>first commit
* </table>
*/
#ifndef IOT_HUB_DEVICE_C_SDK_COMMON_UTILS_INC_UTILS_LIST_H_
#define IOT_HUB_DEVICE_C_SDK_COMMON_UTILS_INC_UTILS_LIST_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <string.h>
/**
* @brief ListNode iterator direction.
*
*/
typedef enum {
LIST_HEAD,
LIST_TAIL,
} UtilsListDirection;
/**
* @brief ListNode process result of OnNodeProcessHandle.
*
*/
typedef enum {
LIST_TRAVERSE_CONTINUE,
LIST_TRAVERSE_BREAK,
} UtilsListResult;
/**
* @brief Utils list function.
*
*/
typedef struct {
void *(*list_malloc)(size_t len);
void (*list_free)(void *val);
void *(*list_lock_init)(void);
void (*list_lock)(void *lock);
void (*list_unlock)(void *lock);
void (*list_lock_deinit)(void *lock);
} UtilsListFunc;
/**
* @brief Node process handle called by utils_list_process.
*
*/
typedef UtilsListResult (*OnNodeProcessHandle)(void *list, void *node, void *val, void *usr_data);
/**
* @brief Create list with max len, return NULL if fail.
*
* @param[in] func function needed by list
* @param[in] max_len max_len of list
* @return pointer to list, NULL for failed
*/
void *utils_list_create(UtilsListFunc func, int max_len);
/**
* @brief Destroy list.
*
* @param[in] list pointer to list
*/
void utils_list_destroy(void *list);
/**
* @brief Get list len.
*
* @param[in] list pointer to list
* @return len of list
*/
int utils_list_len_get(void *list);
/**
* @brief Push the node to list tail, return NULL if node invalid.
*
* @param[in] list pointer to list
* @param[in] val value needed to push to list
* @return pointer to node, NULL for failed
*/
void *utils_list_push(void *list, void *val);
/**
* @brief Pop the val from list head, return NULL if list empty.
*
* @param[in] list pointer to list
* @return val in the head node
*/
void *utils_list_pop(void *list);
/**
* @brief Delete the node in list and release the resource.
*
* @param[in] list pointer to list
* @param[in] node pointer to node needed remove
*/
void utils_list_remove(void *list, void *node);
/**
* @brief Process list using handle function.
*
* @param[in] list pointer to list
* @param[in] direction direction to traverse
* @param[in] handle process function @see OnNodeProcessHandle
* @param[in,out] usr_data usr data to pass to OnNodeProcessHandle
*/
void utils_list_process(void *list, uint8_t direction, OnNodeProcessHandle handle, void *usr_data);
#ifdef __cplusplus
}
#endif
#endif // IOT_HUB_DEVICE_C_SDK_COMMON_UTILS_INC_UTILS_LIST_H_

View File

@@ -1,121 +0,0 @@
/**
* @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 utils_log.h
* @brief header file for utils log
* @author fancyxu (fancyxu@tencent.com)
* @version 1.0
* @date 2021-05-28
*
* @par Change Log:
* <table>
* <tr><th>Date <th>Version <th>Author <th>Description
* <tr><td>2021-05-28 <td>1.0 <td>fancyxu <td>first commit
* </table>
*/
#ifndef IOT_HUB_DEVICE_C_SDK_COMMON_UTILS_INC_UTILS_LOG_H_
#define IOT_HUB_DEVICE_C_SDK_COMMON_UTILS_INC_UTILS_LOG_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stdarg.h>
#include <stdint.h>
#include <string.h>
/**
* @brief SDK log print/upload level.
*
*/
typedef enum {
LOG_LEVEL_DISABLE = 0, /**< disable log print/upload */
LOG_LEVEL_ERROR = 1, /**< error log level */
LOG_LEVEL_WARN = 2, /**< warning log level */
LOG_LEVEL_INFO = 3, /**< info log level */
LOG_LEVEL_DEBUG = 4, /**< debug log level */
} LogLevel;
/**
* @brief User's self defined log handler callback.
*
*/
typedef struct {
void *(*log_malloc)(size_t len);
void (*log_free)(void *val);
void (*log_handle)(const char *message);
void (*log_upload)(int log_level, const char *message);
void (*log_printf)(const char *fmt, ...);
char *(*log_get_current_time_str)(void);
void *(*log_mutex_create)(void);
void (*log_mutex_lock)(void *mutex);
void (*log_mutex_unlock)(void *mutex);
void (*log_mutex_destroy)(void *mutex);
} LogHandleFunc;
/**
* @brief Init log with func, log level, max log size.
*
* @param[in] func function should be implement for utils log
* @param[in] log_level @see LogLevel
* @param[in] max_log_size max size of log to print
* @return 0 for success
*/
int utils_log_init(LogHandleFunc func, LogLevel log_level, int max_log_size);
/**
* @brief Deinit log.
*
*/
void utils_log_deinit(void);
/**
* @brief Set log level.
*
* @param log_level @see LogLevel
*/
void utils_log_set_level(LogLevel log_level);
/**
* @brief Get log level.
*
* @return @see LogLevel
*/
LogLevel utils_log_get_level(void);
/**
* @brief Generate log if level higher than set.
*
* @param[in] file file path
* @param[in] func function where generate log
* @param[in] line line of source file where genertate log
* @param[in] level @see LogLevel
* @param[in] fmt format of log content
*/
void utils_log_gen(const char *file, const char *func, const int line, const int level, const char *fmt, ...);
// Simple APIs for log generation in different level
#define Log_d(fmt, ...) utils_log_gen(__FILE__, __FUNCTION__, __LINE__, LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
#define Log_i(fmt, ...) utils_log_gen(__FILE__, __FUNCTION__, __LINE__, LOG_LEVEL_INFO, fmt, ##__VA_ARGS__)
#define Log_w(fmt, ...) utils_log_gen(__FILE__, __FUNCTION__, __LINE__, LOG_LEVEL_WARN, fmt, ##__VA_ARGS__)
#define Log_e(fmt, ...) utils_log_gen(__FILE__, __FUNCTION__, __LINE__, LOG_LEVEL_ERROR, fmt, ##__VA_ARGS__)
#ifdef __cplusplus
}
#endif
#endif // IOT_HUB_DEVICE_C_SDK_COMMON_UTILS_INC_UTILS_LOG_H_