From 67b97b33960d1c0b1b1e8111b797fd71fa5c119b Mon Sep 17 00:00:00 2001 From: kerms Date: Wed, 3 Jul 2024 20:44:08 +0800 Subject: [PATCH] feat(dap_proxy): copy corsacOTA.h from https://github.com/windowsair/corsacOTA --- components/dap_proxy/corsacOTA.h | 79 ++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 components/dap_proxy/corsacOTA.h diff --git a/components/dap_proxy/corsacOTA.h b/components/dap_proxy/corsacOTA.h new file mode 100644 index 0000000..a3e7521 --- /dev/null +++ b/components/dap_proxy/corsacOTA.h @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2021 windowsair + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * 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. + */ +#ifndef _CORSACOTA_H_ +#define _CORSACOTA_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef signed int co_err_t; + +#define CO_OK 0 +#define CO_FAIL -1 +#define CO_ERROR_IO_PENDING -2 +#define CO_ERROR_NO_MEM 0x101 +#define CO_ERROR_INVALID_ARG 0x102 +#define CO_ERROR_INVALID_SIZE 0x104 +#define CO_ERROR_INVALID_OTA_PTN -3 + +#define CO_RES_SUCCESS 0 +#define CO_RES_SYSTEM_ERROR 1 +#define CO_RES_INVALID_ARG 2 +#define CO_RES_INVALID_SIZE 3 +#define CO_RES_INVALID_STATUS 4 + +/** + * @brief corsacOTA instance handle. Only one instance is allowed. + * + */ +typedef void *co_handle_t; + +typedef struct co_config { + char *thread_name; // corsacOTA thread name + int stack_size; // corsacOTA thread stack size + int thread_prio; // corsacOTA thread priority + + int listen_port; // corsacOTA server listen port + int max_listen_num; // Maximum number of connections. In fact, after the handshake is complete, there is only one connection to provide services. + + int wait_timeout_sec; // Timeout (in seconds) + int wait_timeout_usec; // Timeout (in microseconds) + +} co_config_t; + +/** + * @brief Start the corsacOTA server + * + * @param config Configuration for new instance of the server + * @return + * - ESP_OK : Server Init successfully + * - ESP_ERR_INVALID_ARG : Null argument + * - ESP_ERR_NO_MEM : Failed to allocate memory for instance + */ +int corsacOTA_init(co_handle_t *handle, co_config_t *config); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file