From f72629d9ad401ed3f45d6999e135410a0503aa53 Mon Sep 17 00:00:00 2001 From: wesley-santos <53940899+WesleyJoseSantos@users.noreply.github.com> Date: Tue, 24 Oct 2023 09:00:32 -0300 Subject: [PATCH] feat: change to library --- CMakeLists.txt | 2 +- main/main.c | 85 -------------------------------------------------- 2 files changed, 1 insertion(+), 86 deletions(-) delete mode 100644 main/main.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 461649e..886fa70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ else() ${CMAKE_SOURCE_DIR}/main ) - add_executable(${PROJECT_NAME} ${infa_src} + add_library(${PROJECT_NAME} ${infa_src} ${ifaces_src} ${mg_src} ${app_src}) diff --git a/main/main.c b/main/main.c deleted file mode 100644 index d5b8568..0000000 --- a/main/main.c +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @file main.c - * @author your name (you@domain.com) - * @brief - * @version 0.1 - * @date 2023-10-10 - * - * @copyright Copyright (c) 2023 - * - */ - -#include - -#include "ciot.h" - -#include "ciot_https.h" -#include "ciot_httpc.h" -#include "ciot_mqttc.h" - -static void test(ciot_httpc_t httpc); - -#ifdef _WIN32 - -#include "mongoose.h" - -#define CIOT_HANDLE &mg - -struct mg_mgr mg; - -int app_main(); - -int main(char **args) -{ - mg_mgr_init(&mg); - return app_main(); -} - -#else - -#define CIOT_HANDLE NULL - -#endif //_WIN32 - -int app_main(void) -{ - ciot_https_t https = ciot_https_new(CIOT_HANDLE); - ciot_httpc_t httpc = ciot_httpc_new(CIOT_HANDLE); - ciot_mqttc_t mqtt = ciot_mqttc_new(CIOT_HANDLE); - - ciot_t ciot = ciot_new(); - - ciot_https_cfg_t https_cfg = { - .address = "http://0.0.0.0:4444", - .route = "/", - }; - ciot_https_start(https, &https_cfg); - - ciot_httpc_cfg_t httpc_cfg = { - .url = "http://localhost:4444", - .method = CIOT_HTTPC_METHOD_POST, - .timeout = 50000 - }; - ciot_httpc_start(httpc, &httpc_cfg); - - ciot_iface_t *ifaces[] = { - (ciot_iface_t*)https, - (ciot_iface_t*)httpc, - (ciot_iface_t*)mqtt - }; - ciot_set_iface_list(ciot, ifaces, 2); - - test(httpc); - - return 0; -} - -static void test(ciot_httpc_t httpc) -{ - ciot_msg_t msg = { - .iface.id = 1, - .iface.type = CIOT_IFACE_TYPE_HTTP_CLIENT, - .type = CIOT_MSG_TYPE_GET_STATUS, - }; - ciot_httpc_send_data(httpc, (uint8_t*)&msg, CIOT_MSG_SIZE - sizeof(msg.error)); -}