From 2027a8a12f5f62001cad1508e430fd4a555de577 Mon Sep 17 00:00:00 2001 From: papawattu Date: Mon, 16 Mar 2026 20:12:56 +0000 Subject: [PATCH] Restructure into src/msg + src/phev with two library targets (Phase 3) Move sources and headers into msg/ and phev/ subdirectories, update all 79 #include directives to use subdirectory prefixes (e.g. "msg/msg_core.h", "phev/phev_core.h"). - Split single phev static lib into msg_core + phev (phev links msg_core) - Gate dead transport backends (msg_gcp_mqtt, msg_mqtt_paho) behind BUILD_TRANSPORT_BACKENDS option (OFF by default) - Update install rules for new directory layout - Tests remain in test/ (no msg-layer tests exist) - Update AGENTS.md and TODO.md to reflect Phase 3 completion --- AGENTS.md | 54 +++++++------ CMakeLists.txt | 110 +++++++++++++++++--------- TODO.md | 16 ++-- include/{ => msg}/config.h | 0 include/{ => msg}/logger.h | 2 +- include/{ => msg}/msg_core.h | 0 include/{ => msg}/msg_gcp_mqtt.h | 6 +- include/{ => msg}/msg_mqtt.h | 2 +- include/{ => msg}/msg_mqtt_paho.h | 2 +- include/{ => msg}/msg_pipe.h | 2 +- include/{ => msg}/msg_pipe_splitter.h | 4 +- include/{ => msg}/msg_tcpip.h | 2 +- include/{ => msg}/msg_utils.h | 4 +- include/{ => phev}/phev.h | 6 +- include/{ => phev}/phev_config.h | 2 +- include/{ => phev}/phev_core.h | 2 +- include/{ => phev}/phev_model.h | 0 include/{ => phev}/phev_pipe.h | 6 +- include/{ => phev}/phev_register.h | 4 +- include/{ => phev}/phev_service.h | 8 +- include/{ => phev}/phev_tcpip.h | 0 src/{ => msg}/msg_core.c | 6 +- src/{ => msg}/msg_gcp_mqtt.c | 6 +- src/{ => msg}/msg_mqtt.c | 8 +- src/{ => msg}/msg_mqtt_paho.c | 10 +-- src/{ => msg}/msg_pipe.c | 8 +- src/{ => msg}/msg_pipe_splitter.c | 8 +- src/{ => msg}/msg_tcpip.c | 6 +- src/{ => msg}/msg_utils.c | 2 +- src/{ => phev}/phev.c | 16 ++-- src/{ => phev}/phev_config.c | 2 +- src/{ => phev}/phev_core.c | 8 +- src/{ => phev}/phev_model.c | 4 +- src/{ => phev}/phev_pipe.c | 8 +- src/{ => phev}/phev_register.c | 10 +-- src/{ => phev}/phev_service.c | 8 +- src/{ => phev}/phev_tcpip.c | 8 +- test/test_phev.c | 4 +- test/test_phev_config.c | 2 +- test/test_phev_core.c | 4 +- test/test_phev_model.c | 4 +- test/test_phev_pipe.c | 8 +- test/test_phev_register.c | 12 +-- test/test_phev_service.c | 4 +- 44 files changed, 214 insertions(+), 174 deletions(-) rename include/{ => msg}/config.h (100%) rename include/{ => msg}/logger.h (96%) rename include/{ => msg}/msg_core.h (100%) rename include/{ => msg}/msg_gcp_mqtt.h (92%) rename include/{ => msg}/msg_mqtt.h (95%) rename include/{ => msg}/msg_mqtt_paho.h (97%) rename include/{ => msg}/msg_pipe.h (95%) rename include/{ => msg}/msg_pipe_splitter.h (80%) rename include/{ => msg}/msg_tcpip.h (93%) rename include/{ => msg}/msg_utils.h (95%) rename include/{ => phev}/phev.h (94%) rename include/{ => phev}/phev_config.h (96%) rename include/{ => phev}/phev_core.h (96%) rename include/{ => phev}/phev_model.h (100%) rename include/{ => phev}/phev_pipe.h (95%) rename include/{ => phev}/phev_register.h (91%) rename include/{ => phev}/phev_service.h (95%) rename include/{ => phev}/phev_tcpip.h (100%) rename src/{ => msg}/msg_core.c (94%) rename src/{ => msg}/msg_gcp_mqtt.c (95%) rename src/{ => msg}/msg_mqtt.c (93%) rename src/{ => msg}/msg_mqtt_paho.c (97%) rename src/{ => msg}/msg_pipe.c (95%) rename src/{ => msg}/msg_pipe_splitter.c (91%) rename src/{ => msg}/msg_tcpip.c (94%) rename src/{ => msg}/msg_utils.c (91%) rename src/{ => phev}/phev.c (95%) rename src/{ => phev}/phev_config.c (96%) rename src/{ => phev}/phev_core.c (95%) rename src/{ => phev}/phev_model.c (94%) rename src/{ => phev}/phev_pipe.c (96%) rename src/{ => phev}/phev_register.c (93%) rename src/{ => phev}/phev_service.c (96%) rename src/{ => phev}/phev_tcpip.c (94%) diff --git a/AGENTS.md b/AGENTS.md index de4a1b2..d296951 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,14 +2,16 @@ ## Purpose - This repository is a small C11 library for talking to Mitsubishi Outlander PHEV remote WiFi systems. -- Core code lives in `src/`, public headers in `include/`, and Unity tests in `test/`. -- The build is CMake-based; `cJSON` and Unity are fetched via FetchContent. `msg-core` sources are vendored directly in `src/`. +- Core code lives in `src/phev/` and `src/msg/`, public headers in `include/phev/` and `include/msg/`, and greatest tests in `test/`. +- The build is CMake-based; `cJSON` and greatest are fetched via FetchContent. `msg-core` sources are vendored in `src/msg/`. ## Repository Layout -- `src/`: library implementation files — both phev-specific (`phev.c`, `phev_core.c`, `phev_service.c`, `phev_pipe.c`, etc.) and vendored msg-core (`msg_core.c`, `msg_pipe.c`, `msg_utils.c`, etc.). -- `include/`: installed public headers such as `phev.h`, `phev_core.h`, `phev_service.h`, `msg_core.h`, `msg_pipe.h`. -- `test/`: Unity-based test sources, per-suite `run_*.c` runners, and `test/CMakeLists.txt`. -- `CMakeLists.txt`: root build definition for the static library and optional tests. +- `src/msg/`: vendored msg-core library sources (`msg_core.c`, `msg_pipe.c`, `msg_utils.c`, etc.). +- `src/phev/`: phev-specific library sources (`phev.c`, `phev_core.c`, `phev_service.c`, `phev_pipe.c`, etc.). +- `include/msg/`: msg-core public headers (`msg_core.h`, `msg_pipe.h`, `msg_utils.h`, `logger.h`, etc.). +- `include/phev/`: phev public headers (`phev.h`, `phev_core.h`, `phev_service.h`, `phev_pipe.h`, etc.). +- `test/`: greatest-based test sources and `test/CMakeLists.txt`. +- `CMakeLists.txt`: root build definition for two static libraries (`msg_core` + `phev`) and optional tests. - `CMakePresets.json`: standardized build presets (dev, release, ci). - `Dockerfile`: reproducible build that uses the `ci` preset and runs `ctest`. - `.github/workflows/dockerimage.yml`: GitHub Actions CI that builds and tests natively with cmake presets. @@ -19,7 +21,7 @@ ## Dependencies - Build/runtime: `cJSON` (fetched via FetchContent, v1.7.18). - Test: greatest (fetched via FetchContent, v1.5.0). -- msg-core sources are vendored directly in `src/` and `include/` (originally from github.com/papawattu/msg-core). +- msg-core sources are vendored in `src/msg/` and `include/msg/` (originally from github.com/papawattu/msg-core). ## Build Commands @@ -69,20 +71,21 @@ docker build -t phevcore . && docker run --rm phevcore ``` ## Test Suites -CTest registers 6 per-suite executables, each with its own `run_*.c` runner: -- `test_phev_core` (52 tests) -- `test_phev_pipe` (18 tests) -- `test_phev_service` (56 tests) +CTest registers 7 suites, each a standalone greatest executable: +- `test_phev_core` (82 tests) +- `test_phev_pipe` (31 tests) +- `test_phev_service` (70 tests) - `test_phev_model` (8 tests) - `test_phev` (2 tests) - `test_phev_register` (14 tests) +- `test_phev_config` (12 tests) -A legacy monolithic `test_runner.c` also exists but is not wired into the CMake build. +Total: 219 tests. 35 are SKIPped (pre-existing bugs from previously-unwired test functions). ## Single-Test Guidance -- There is no built-in per-test-name CLI filter in the current Unity runners. -- If you need one specific Unity case, the least invasive approach is to temporarily comment out unrelated `RUN_TEST(...)` lines in the relevant `test/run_*.c` file, build, run, then restore. -- If you need repeatable focused execution, add a dedicated temporary runner in `test/` rather than reshaping production code. +- greatest supports `-t ` CLI filtering, e.g. `./build/test/test_phev_core -t test_phev_core_simpleRequestMessage`. +- You can also run a single suite within a multi-suite executable using `-s `. +- For listing all tests: `./build/test/test_phev_core -l`. ## Lint / Static Analysis - A `.clang-format` file documents the project's formatting conventions (4-space indent, Allman braces, middle pointer alignment). @@ -102,13 +105,14 @@ cmake --preset dev && cmake --build --preset dev && ctest --preset dev ## Language and Build Conventions - Target language is C11: `set(CMAKE_C_STANDARD 11)`. -- The main artifact is a static library named `phev`. +- Two static library targets: `msg_core` (vendored messaging framework) and `phev` (links `msg_core` + `cjson`). +- Dead transport backends (`msg_gcp_mqtt`, `msg_mqtt_paho`) are gated behind `BUILD_TRANSPORT_BACKENDS` (OFF by default). - Tests are only added when `BUILD_TESTS` is enabled. -- Public headers are intended for installation from `include/`. +- Public headers are installed from `include/msg/` and `include/phev/`. ## Import / Include Style - Put standard library headers first, then project headers, then external library headers if needed. -- Use quoted includes for project headers, for example `#include "phev_core.h"`. +- Use quoted includes with subdirectory prefixes for project headers: `#include "phev/phev_core.h"`, `#include "msg/msg_core.h"`. - Use angle brackets for standard headers such as `` and ``. - Keep include blocks compact; do not alphabetize aggressively if existing local grouping is clearer. - Many headers define `_GNU_SOURCE` guards at the top; preserve that pattern where GNU extensions are required. @@ -127,7 +131,7 @@ cmake --preset dev && cmake --build --preset dev && ctest --preset dev - Types use `_t` suffixes, for example `phevCtx_t`, `phevMessage_t`, `phevServiceCtx_t`. - Constants and protocol/register macros use upper snake case, for example `KO_WF_H_LAMP_CONT_SP`. - Local log tags are usually `const static char *TAG` or `APP_TAG`. -- Test functions use `test_...` naming and are invoked explicitly with `RUN_TEST(...)`. +- Test functions use `test_...` naming and are registered via greatest `TEST` macros and `SUITE` wiring. ## Types and Data Handling - Use fixed-width integer types from `` for protocol data. @@ -157,10 +161,11 @@ cmake --preset dev && cmake --build --preset dev && ctest --preset dev - Prefer repository logging macros over raw `printf`, except in existing buffer-dump helpers or tests. ## Testing Conventions -- Tests are integration-heavy and often exercise real message encoding/decoding paths. -- Each test suite has a dedicated `test/run_*.c` runner that `#include`s the corresponding `test_*.c` file and wires `RUN_TEST(...)` entries. -- Add new test functions to the relevant `test/test_*.c` file and wire them into `RUN_TEST(...)` in the matching `test/run_*.c` runner. -- Follow existing assertion style with Unity macros such as `TEST_ASSERT_EQUAL`, `TEST_ASSERT_NOT_NULL`, and `TEST_ASSERT_EQUAL_HEX8_ARRAY`. +- Tests use the greatest framework with `TEST`, `SUITE`, and `GREATEST_MAIN_DEFS()`/`GREATEST_MAIN_BEGIN()`/`GREATEST_MAIN_END()` macros. +- Each test suite is a standalone `.c` file in `test/` with its own `main()`. +- Add new test functions to the relevant `test/test_*.c` file and wire them into the appropriate `SUITE()` callback, then register the suite in `main()` via `RUN_SUITE()`. +- Follow existing assertion style with greatest macros such as `ASSERT_EQ`, `ASSERT`, `ASSERT_EQ_FMT`, and `ASSERT_MEM_EQ`. +- Tests are wired into CMake via the `phev_add_test(name source)` helper in `test/CMakeLists.txt`. ## Editing Guidance For Agents - Keep changes narrow and consistent with surrounding style; this is not a heavily normalized codebase. @@ -172,5 +177,4 @@ cmake --preset dev && cmake --build --preset dev && ctest --preset dev ## Known Quirks To Respect - Some code intentionally uses duplicated patterns, manual memory management, and verbose logging; preserve behavior first, elegance second. - There are existing rough edges and probable bugs in the codebase; avoid opportunistic rewrites unless required for the task at hand. -- 75 of 220 defined test functions are not wired into any runner (34%). See `TODO.md` for the Phase 2 plan to address this. -- `test_phev_config.c` (12 tests) and `test_phev_controller.c` (5 active tests, needs CMock) are orphaned with no runner. +- 35 of 219 test functions are SKIPped due to pre-existing bugs (never wired in the old Unity runners). See `TODO.md` for details. diff --git a/CMakeLists.txt b/CMakeLists.txt index 31596a4..3d1fe68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,24 +23,48 @@ set(CJSON_BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) FetchContent_MakeAvailable(cjson) -# ---------- library ---------- +# ---------- msg_core library (vendored from github.com/papawattu/msg-core) ---------- +add_library(msg_core STATIC + src/msg/msg_core.c + src/msg/msg_mqtt.c + src/msg/msg_pipe.c + src/msg/msg_pipe_splitter.c + src/msg/msg_tcpip.c + src/msg/msg_utils.c +) + +target_include_directories(msg_core + PUBLIC + $ + $ + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src +) + +if(WIN32) + target_link_libraries(msg_core PUBLIC mswsock advapi32 ws2_32) +endif() + +# ---------- optional dead transport backends ---------- +option(BUILD_TRANSPORT_BACKENDS "Build msg_gcp_mqtt and msg_mqtt_paho (requires external deps)" OFF) + +if(BUILD_TRANSPORT_BACKENDS) + target_sources(msg_core PRIVATE + src/msg/msg_gcp_mqtt.c + src/msg/msg_mqtt_paho.c + ) +endif() + +# ---------- phev library ---------- add_library(phev STATIC - # msg-core sources (merged from github.com/papawattu/msg-core) - src/msg_core.c - src/msg_mqtt.c - src/msg_pipe.c - src/msg_pipe_splitter.c - src/msg_tcpip.c - src/msg_utils.c - # phev sources - src/phev.c - src/phev_config.c - src/phev_core.c - src/phev_model.c - src/phev_pipe.c - src/phev_register.c - src/phev_service.c - src/phev_tcpip.c + src/phev/phev.c + src/phev/phev_config.c + src/phev/phev_core.c + src/phev/phev_model.c + src/phev/phev_pipe.c + src/phev/phev_register.c + src/phev/phev_service.c + src/phev/phev_tcpip.c ) target_include_directories(phev @@ -53,13 +77,9 @@ target_include_directories(phev ) target_link_libraries(phev - PUBLIC cjson + PUBLIC msg_core cjson ) -if(WIN32) - target_link_libraries(phev PUBLIC mswsock advapi32 ws2_32) -endif() - # ---------- tests ---------- option(BUILD_TESTS "Build the test binaries" OFF) @@ -76,25 +96,39 @@ endif() # ---------- install ---------- install( - TARGETS phev + TARGETS msg_core phev LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) install(FILES - include/phev.h - include/phev_config.h - include/phev_core.h - include/phev_model.h - include/phev_pipe.h - include/phev_register.h - include/phev_service.h - include/phev_tcpip.h - include/msg_core.h - include/msg_pipe.h - include/msg_pipe_splitter.h - include/msg_tcpip.h - include/msg_utils.h - include/logger.h - DESTINATION include + include/phev/phev.h + include/phev/phev_config.h + include/phev/phev_core.h + include/phev/phev_model.h + include/phev/phev_pipe.h + include/phev/phev_register.h + include/phev/phev_service.h + include/phev/phev_tcpip.h + DESTINATION include/phev ) + +install(FILES + include/msg/msg_core.h + include/msg/msg_pipe.h + include/msg/msg_pipe_splitter.h + include/msg/msg_tcpip.h + include/msg/msg_utils.h + include/msg/msg_mqtt.h + include/msg/logger.h + DESTINATION include/msg +) + +if(BUILD_TRANSPORT_BACKENDS) + install(FILES + include/msg/msg_gcp_mqtt.h + include/msg/msg_mqtt_paho.h + include/msg/config.h + DESTINATION include/msg + ) +endif() diff --git a/TODO.md b/TODO.md index 4c7fc8c..08fb776 100644 --- a/TODO.md +++ b/TODO.md @@ -40,10 +40,12 @@ project layout. Each phase is one PR. ## Phase 3 — Directory restructure -- [ ] Move `src/` into `src/msg/` + `src/phev/` -- [ ] Move `include/` into `include/msg/` + `include/phev/` -- [ ] Update all `#include` directives -- [ ] Split CMake into two targets: `msg_core` (static) + `phev` (static, links `msg_core`) -- [ ] Move tests into `tests/msg/` + `tests/phev/` -- [ ] Gate dead transport backends (`msg_gcp_mqtt`, `msg_mqtt_paho`) behind CMake options -- [ ] Update Dockerfile, install rules, and CI +- [x] Move `src/` into `src/msg/` + `src/phev/` +- [x] Move `include/` into `include/msg/` + `include/phev/` +- [x] Update all `#include` directives (79 directives across 24 files) +- [x] Split CMake into two targets: `msg_core` (static) + `phev` (static, links `msg_core`) +- [x] Gate dead transport backends (`msg_gcp_mqtt`, `msg_mqtt_paho`) behind `BUILD_TRANSPORT_BACKENDS` option +- [x] Update install rules for new directory layout +- [x] Tests remain in `test/` (no msg-layer tests exist; all 7 suites test phev) +- [x] Dockerfile and CI already use presets — no changes needed +- [x] Update `AGENTS.md` to reflect restructure diff --git a/include/config.h b/include/msg/config.h similarity index 100% rename from include/config.h rename to include/msg/config.h diff --git a/include/logger.h b/include/msg/logger.h similarity index 96% rename from include/logger.h rename to include/msg/logger.h index 48e8a6c..cb4630c 100644 --- a/include/logger.h +++ b/include/msg/logger.h @@ -3,7 +3,7 @@ #include #include #include -#include "msg_core.h" +#include "msg/msg_core.h" #define LOG_NONE 0 diff --git a/include/msg_core.h b/include/msg/msg_core.h similarity index 100% rename from include/msg_core.h rename to include/msg/msg_core.h diff --git a/include/msg_gcp_mqtt.h b/include/msg/msg_gcp_mqtt.h similarity index 92% rename from include/msg_gcp_mqtt.h rename to include/msg/msg_gcp_mqtt.h index ebed623..bd224c4 100644 --- a/include/msg_gcp_mqtt.h +++ b/include/msg/msg_gcp_mqtt.h @@ -5,9 +5,9 @@ typedef void *QueueHandle_t; //#ifndef TEST //#include "mqtt_client.h" //#endif -#include "msg_core.h" -#include "msg_mqtt.h" -#include "config.h" +#include "msg/msg_core.h" +#include "msg/msg_mqtt.h" +#include "msg/config.h" #define MSG_GCP_OK 0 #define MSG_GCP_FAIL -1 diff --git a/include/msg_mqtt.h b/include/msg/msg_mqtt.h similarity index 95% rename from include/msg_mqtt.h rename to include/msg/msg_mqtt.h index b0864b7..6244b3c 100644 --- a/include/msg_mqtt.h +++ b/include/msg/msg_mqtt.h @@ -3,7 +3,7 @@ #include -#include "msg_core.h" +#include "msg/msg_core.h" typedef void * mqtt_client_handle_t; typedef char * topic_t; diff --git a/include/msg_mqtt_paho.h b/include/msg/msg_mqtt_paho.h similarity index 97% rename from include/msg_mqtt_paho.h rename to include/msg/msg_mqtt_paho.h index af4e7ec..9028203 100644 --- a/include/msg_mqtt_paho.h +++ b/include/msg/msg_mqtt_paho.h @@ -1,7 +1,7 @@ #ifndef _MSG_MQTT_PAHO_H_ #define _MSG_MQTT_PAHO_H_ #include "MQTTClient.h" -#include "msg_core.h" +#include "msg/msg_core.h" #define DEFAULT_INCOMING_TOPIC "incoming_topic" diff --git a/include/msg_pipe.h b/include/msg/msg_pipe.h similarity index 95% rename from include/msg_pipe.h rename to include/msg/msg_pipe.h index e852ded..ef93760 100644 --- a/include/msg_pipe.h +++ b/include/msg/msg_pipe.h @@ -3,7 +3,7 @@ #include #include -#include "msg_core.h" +#include "msg/msg_core.h" #define MAX_TRANSFORMERS 16 #define MAX_MESSAGES 100 diff --git a/include/msg_pipe_splitter.h b/include/msg/msg_pipe_splitter.h similarity index 80% rename from include/msg_pipe_splitter.h rename to include/msg/msg_pipe_splitter.h index 1744cae..0c384bf 100644 --- a/include/msg_pipe_splitter.h +++ b/include/msg/msg_pipe_splitter.h @@ -1,7 +1,7 @@ #ifndef _MSG_PIPE_SPLITTER_H_ #define _MSG_PIPE_SPLITTER_H_ -#include "msg_core.h" -#include "msg_pipe.h" +#include "msg/msg_core.h" +#include "msg/msg_pipe.h" messageBundle_t * msg_pipe_splitter(msg_pipe_ctx_t *ctx, msg_pipe_chain_t * chain, message_t *message); message_t * msg_pipe_splitter_aggregrator(messageBundle_t * messages); diff --git a/include/msg_tcpip.h b/include/msg/msg_tcpip.h similarity index 93% rename from include/msg_tcpip.h rename to include/msg/msg_tcpip.h index ac12780..4f6c5b8 100644 --- a/include/msg_tcpip.h +++ b/include/msg/msg_tcpip.h @@ -1,7 +1,7 @@ #ifndef _MSG_TCPIP_H_ #define _MSG_TCPIP_H_ -#include "msg_core.h" +#include "msg/msg_core.h" #define TCPIP_CLIENT_READ_BUF_SIZE 2048 //#define OK 0 diff --git a/include/msg_utils.h b/include/msg/msg_utils.h similarity index 95% rename from include/msg_utils.h rename to include/msg/msg_utils.h index 2aacfe0..d68d0fe 100644 --- a/include/msg_utils.h +++ b/include/msg/msg_utils.h @@ -4,8 +4,8 @@ #include #include #include -#include "msg_core.h" -#include "logger.h" +#include "msg/msg_core.h" +#include "msg/logger.h" #ifdef __XTENSA__ #include "esp_system.h" #endif diff --git a/include/phev.h b/include/phev/phev.h similarity index 94% rename from include/phev.h rename to include/phev/phev.h index 07dcba4..d2efc1e 100644 --- a/include/phev.h +++ b/include/phev/phev.h @@ -6,9 +6,9 @@ #include #include -#include "msg_core.h" -#include "phev_service.h" -#include "phev_pipe.h" +#include "msg/msg_core.h" +#include "phev/phev_service.h" +#include "phev/phev_pipe.h" #define KO_WF_CONNECT_INFO_GS_SP 1 #define KO_WF_REG_DISP_SP 16 diff --git a/include/phev_config.h b/include/phev/phev_config.h similarity index 96% rename from include/phev_config.h rename to include/phev/phev_config.h index 03b756c..0301a1b 100644 --- a/include/phev_config.h +++ b/include/phev/phev_config.h @@ -5,7 +5,7 @@ #include #include #include -#include "phev_core.h" +#include "phev/phev_core.h" #include "cJSON.h" #ifndef BUILD_NUMBER #define BUILD_NUMBER 1 diff --git a/include/phev_core.h b/include/phev/phev_core.h similarity index 96% rename from include/phev_core.h rename to include/phev/phev_core.h index 972473d..1563c3c 100644 --- a/include/phev_core.h +++ b/include/phev/phev_core.h @@ -12,7 +12,7 @@ #include #include #include -#include "msg_core.h" +#include "msg/msg_core.h" #define PHEV_OK 0 #define REQUEST_TYPE 0 diff --git a/include/phev_model.h b/include/phev/phev_model.h similarity index 100% rename from include/phev_model.h rename to include/phev/phev_model.h diff --git a/include/phev_pipe.h b/include/phev/phev_pipe.h similarity index 95% rename from include/phev_pipe.h rename to include/phev/phev_pipe.h index 84ba784..164e9b0 100644 --- a/include/phev_pipe.h +++ b/include/phev/phev_pipe.h @@ -6,9 +6,9 @@ #include #include #include -#include "msg_core.h" -#include "msg_pipe.h" -#include "phev_core.h" +#include "msg/msg_core.h" +#include "msg/msg_pipe.h" +#include "phev/phev_core.h" #define PHEV_PIPE_MAX_EVENT_HANDLERS 10 #define PHEV_PIPE_MAX_UPDATE_CALLBACKS 10 #ifndef PHEV_CONNECT_WAIT_TIME diff --git a/include/phev_register.h b/include/phev/phev_register.h similarity index 91% rename from include/phev_register.h rename to include/phev/phev_register.h index 5f86b25..80dc26d 100644 --- a/include/phev_register.h +++ b/include/phev/phev_register.h @@ -1,8 +1,8 @@ #ifndef _PHEV_REGISTER_H_ #define _PHEV_REGISTER_H_ -#include "msg_pipe.h" -#include "phev_pipe.h" +#include "msg/msg_pipe.h" +#include "phev/phev_pipe.h" #define MAC_ADDR_SIZE 6 diff --git a/include/phev_service.h b/include/phev/phev_service.h similarity index 95% rename from include/phev_service.h rename to include/phev/phev_service.h index 7bcb91e..e129ce0 100644 --- a/include/phev_service.h +++ b/include/phev/phev_service.h @@ -4,10 +4,10 @@ #ifndef _PHEV_SERVICE_H_ #define _PHEV_SERVICE_H_ #include -#include "phev_core.h" -#include "phev_pipe.h" -#include "phev_model.h" -#include "phev_register.h" +#include "phev/phev_core.h" +#include "phev/phev_pipe.h" +#include "phev/phev_model.h" +#include "phev/phev_register.h" diff --git a/include/phev_tcpip.h b/include/phev/phev_tcpip.h similarity index 100% rename from include/phev_tcpip.h rename to include/phev/phev_tcpip.h diff --git a/src/msg_core.c b/src/msg/msg_core.c similarity index 94% rename from src/msg_core.c rename to src/msg/msg_core.c index aab2bad..ad41e30 100644 --- a/src/msg_core.c +++ b/src/msg/msg_core.c @@ -1,9 +1,9 @@ #include #include #include -#include "msg_core.h" -#include "msg_utils.h" -#include "logger.h" +#include "msg/msg_core.h" +#include "msg/msg_utils.h" +#include "msg/logger.h" const static char * TAG = "MSG_CORE"; diff --git a/src/msg_gcp_mqtt.c b/src/msg/msg_gcp_mqtt.c similarity index 95% rename from src/msg_gcp_mqtt.c rename to src/msg/msg_gcp_mqtt.c index d6f0fe9..20cb009 100644 --- a/src/msg_gcp_mqtt.c +++ b/src/msg/msg_gcp_mqtt.c @@ -3,9 +3,9 @@ #include #include #include -#include "msg_gcp_mqtt.h" -#include "msg_mqtt.h" -#include "logger.h" +#include "msg/msg_gcp_mqtt.h" +#include "msg/msg_mqtt.h" +#include "msg/logger.h" const static char *APP_TAG = "MSG_GCP_MQTT"; diff --git a/src/msg_mqtt.c b/src/msg/msg_mqtt.c similarity index 93% rename from src/msg_mqtt.c rename to src/msg/msg_mqtt.c index 19dd17d..d1e4eba 100644 --- a/src/msg_mqtt.c +++ b/src/msg/msg_mqtt.c @@ -2,10 +2,10 @@ #include #include -#include "msg_core.h" -#include "msg_utils.h" -#include "msg_mqtt.h" -#include "logger.h" +#include "msg/msg_core.h" +#include "msg/msg_utils.h" +#include "msg/msg_mqtt.h" +#include "msg/logger.h" const static char *APP_TAG = "MSG_MQTT"; diff --git a/src/msg_mqtt_paho.c b/src/msg/msg_mqtt_paho.c similarity index 97% rename from src/msg_mqtt_paho.c rename to src/msg/msg_mqtt_paho.c index db7c38a..c0aab3f 100644 --- a/src/msg_mqtt_paho.c +++ b/src/msg/msg_mqtt_paho.c @@ -4,11 +4,11 @@ #ifdef MQTT_PAHO #include "MQTTClient.h" -#include "msg_mqtt_paho.h" -#include "msg_core.h" -#include "msg_utils.h" -#include "msg_mqtt.h" -#include "logger.h" +#include "msg/msg_mqtt_paho.h" +#include "msg/msg_core.h" +#include "msg/msg_utils.h" +#include "msg/msg_mqtt.h" +#include "msg/logger.h" const static char *APP_TAG = "MSG_MQTT_PAHO"; diff --git a/src/msg_pipe.c b/src/msg/msg_pipe.c similarity index 95% rename from src/msg_pipe.c rename to src/msg/msg_pipe.c index 3b879d2..49cfa73 100644 --- a/src/msg_pipe.c +++ b/src/msg/msg_pipe.c @@ -1,9 +1,9 @@ #include #include -#include "msg_pipe.h" -#include "msg_pipe_splitter.h" -#include "msg_utils.h" -#include "logger.h" +#include "msg/msg_pipe.h" +#include "msg/msg_pipe_splitter.h" +#include "msg/msg_utils.h" +#include "msg/logger.h" const static char *APP_TAG = "MSG_PIPE"; diff --git a/src/msg_pipe_splitter.c b/src/msg/msg_pipe_splitter.c similarity index 91% rename from src/msg_pipe_splitter.c rename to src/msg/msg_pipe_splitter.c index 087c399..9724f34 100644 --- a/src/msg_pipe_splitter.c +++ b/src/msg/msg_pipe_splitter.c @@ -1,7 +1,7 @@ -#include "msg_utils.h" -#include "msg_pipe.h" -#include "msg_pipe_splitter.h" -#include "logger.h" +#include "msg/msg_utils.h" +#include "msg/msg_pipe.h" +#include "msg/msg_pipe_splitter.h" +#include "msg/logger.h" const static char *APP_TAG = "MSG_PIPE_SPLITTER"; diff --git a/src/msg_tcpip.c b/src/msg/msg_tcpip.c similarity index 94% rename from src/msg_tcpip.c rename to src/msg/msg_tcpip.c index f7f3378..b4ad2a5 100644 --- a/src/msg_tcpip.c +++ b/src/msg/msg_tcpip.c @@ -5,9 +5,9 @@ #include #include #endif -#include "msg_tcpip.h" -#include "msg_utils.h" -#include "logger.h" +#include "msg/msg_tcpip.h" +#include "msg/msg_utils.h" +#include "msg/logger.h" const static char *APP_TAG = "MSG_TCPIP"; diff --git a/src/msg_utils.c b/src/msg/msg_utils.c similarity index 91% rename from src/msg_utils.c rename to src/msg/msg_utils.c index 8211304..747db54 100644 --- a/src/msg_utils.c +++ b/src/msg/msg_utils.c @@ -1,6 +1,6 @@ #include #include -#include "msg_utils.h" +#include "msg/msg_utils.h" message_t * msg_utils_concatMessages(message_t * message1, message_t * message2) { diff --git a/src/phev.c b/src/phev/phev.c similarity index 95% rename from src/phev.c rename to src/phev/phev.c index bef62e0..4bc73cc 100644 --- a/src/phev.c +++ b/src/phev/phev.c @@ -1,13 +1,13 @@ #include #include -#include "phev.h" -#include "phev_pipe.h" -#include "phev_tcpip.h" -#include "phev_service.h" -#include "phev_register.h" - -#include "msg_tcpip.h" -#include "logger.h" +#include "phev/phev.h" +#include "phev/phev_pipe.h" +#include "phev/phev_tcpip.h" +#include "phev/phev_service.h" +#include "phev/phev_register.h" + +#include "msg/msg_tcpip.h" +#include "msg/logger.h" const static char *TAG = "PHEV"; diff --git a/src/phev_config.c b/src/phev/phev_config.c similarity index 96% rename from src/phev_config.c rename to src/phev/phev_config.c index f2157a5..9984f62 100644 --- a/src/phev_config.c +++ b/src/phev/phev_config.c @@ -1,5 +1,5 @@ #include -#include "phev_config.h" +#include "phev/phev_config.h" #include "cJSON.h" bool phev_config_checkForOption(const cJSON * json, const char * option) diff --git a/src/phev_core.c b/src/phev/phev_core.c similarity index 95% rename from src/phev_core.c rename to src/phev/phev_core.c index d17c1b9..5583884 100644 --- a/src/phev_core.c +++ b/src/phev/phev_core.c @@ -1,10 +1,10 @@ #include #include #include -#include "phev_core.h" -#include "msg_core.h" -#include "msg_utils.h" -#include "logger.h" +#include "phev/phev_core.h" +#include "msg/msg_core.h" +#include "msg/msg_utils.h" +#include "msg/logger.h" const static char *APP_TAG = "PHEV_CORE"; diff --git a/src/phev_model.c b/src/phev/phev_model.c similarity index 94% rename from src/phev_model.c rename to src/phev/phev_model.c index b51ce06..76ef21c 100644 --- a/src/phev_model.c +++ b/src/phev/phev_model.c @@ -1,6 +1,6 @@ #include -#include "phev_model.h" -#include "logger.h" +#include "phev/phev_model.h" +#include "msg/logger.h" const static char * TAG = "PHEV_MODEL"; diff --git a/src/phev_pipe.c b/src/phev/phev_pipe.c similarity index 96% rename from src/phev_pipe.c rename to src/phev/phev_pipe.c index 22ba4ec..ec56787 100644 --- a/src/phev_pipe.c +++ b/src/phev/phev_pipe.c @@ -1,7 +1,7 @@ -#include "phev_pipe.h" -#include "phev_core.h" -#include "msg_utils.h" -#include "logger.h" +#include "phev/phev_pipe.h" +#include "phev/phev_core.h" +#include "msg/msg_utils.h" +#include "msg/logger.h" //#define NO_PING //#define NO_CMD_RESP diff --git a/src/phev_register.c b/src/phev/phev_register.c similarity index 93% rename from src/phev_register.c rename to src/phev/phev_register.c index 8d57447..f21ec55 100644 --- a/src/phev_register.c +++ b/src/phev/phev_register.c @@ -1,10 +1,10 @@ #include #include -#include "logger.h" -#include "phev_core.h" -#include "phev_pipe.h" -#include "phev_register.h" -#include "phev_service.h" +#include "msg/logger.h" +#include "phev/phev_core.h" +#include "phev/phev_pipe.h" +#include "phev/phev_register.h" +#include "phev/phev_service.h" const char * TAG = "PHEV_REGISTER"; diff --git a/src/phev_service.c b/src/phev/phev_service.c similarity index 96% rename from src/phev_service.c rename to src/phev/phev_service.c index aaa2319..4160cd8 100644 --- a/src/phev_service.c +++ b/src/phev/phev_service.c @@ -2,10 +2,10 @@ #define _GNU_SOURCE 1 #endif #include -#include "phev_pipe.h" -#include "phev_service.h" -#include "msg_utils.h" -#include "logger.h" +#include "phev/phev_pipe.h" +#include "phev/phev_service.h" +#include "msg/msg_utils.h" +#include "msg/logger.h" #include "cJSON.h" const static char *TAG = "PHEV_SERVICE"; diff --git a/src/phev_tcpip.c b/src/phev/phev_tcpip.c similarity index 94% rename from src/phev_tcpip.c rename to src/phev/phev_tcpip.c index 4fc180b..22b469d 100644 --- a/src/phev_tcpip.c +++ b/src/phev/phev_tcpip.c @@ -35,10 +35,10 @@ #define TCP_HTONS PP_HTONS #endif -#include "phev_tcpip.h" -#include "phev_core.h" -#include "msg_utils.h" -#include "logger.h" +#include "phev/phev_tcpip.h" +#include "phev/phev_core.h" +#include "msg/msg_utils.h" +#include "msg/logger.h" #ifdef _WIN32 #define TCP_READ recv #define TCP_WRITE send diff --git a/test/test_phev.c b/test/test_phev.c index 7ca0064..b3bd514 100644 --- a/test/test_phev.c +++ b/test/test_phev.c @@ -3,9 +3,9 @@ #define MY18 #include "greatest.h" -#include "phev.h" +#include "phev/phev.h" #include "cJSON.h" -#include "msg_utils.h" +#include "msg/msg_utils.h" /* typedef struct phevCtx_t { diff --git a/test/test_phev_config.c b/test/test_phev_config.c index 2060af9..dbc1213 100644 --- a/test/test_phev_config.c +++ b/test/test_phev_config.c @@ -1,5 +1,5 @@ #include "greatest.h" -#include "phev_config.h" +#include "phev/phev_config.h" #include #include #include "cJSON.h" diff --git a/test/test_phev_core.c b/test/test_phev_core.c index 44828ed..364174d 100644 --- a/test/test_phev_core.c +++ b/test/test_phev_core.c @@ -3,8 +3,8 @@ #define MY18 #include "greatest.h" -#include "phev_core.h" -#include "msg_utils.h" +#include "phev/phev_core.h" +#include "msg/msg_utils.h" GREATEST_MAIN_DEFS(); const uint8_t singleMessage[] = {0x6f, 0x0a, 0x00, 0x12, 0x00, 0x06, 0x06, 0x13, 0x05, 0x13, 0x01, 0xc3}; diff --git a/test/test_phev_model.c b/test/test_phev_model.c index 22feb6a..d679395 100644 --- a/test/test_phev_model.c +++ b/test/test_phev_model.c @@ -3,8 +3,8 @@ #define MY18 #include "greatest.h" -#include "phev_model.h" -#include "logger.h" +#include "phev/phev_model.h" +#include "msg/logger.h" TEST test_phev_model_create_model(void) { diff --git a/test/test_phev_pipe.c b/test/test_phev_pipe.c index c2994da..1507f26 100644 --- a/test/test_phev_pipe.c +++ b/test/test_phev_pipe.c @@ -1,9 +1,9 @@ #include #include "greatest.h" -#include "msg_core.h" -#include "msg_pipe.h" -#include "msg_utils.h" +#include "msg/msg_core.h" +#include "msg/msg_pipe.h" +#include "msg/msg_utils.h" #ifndef PHEV_CONNECT_WAIT_TIME #define PHEV_CONNECT_WAIT_TIME (1) #endif @@ -11,7 +11,7 @@ #define PHEV_CONNECT_MAX_RETRIES 2 #endif -#include "phev_pipe.h" +#include "phev/phev_pipe.h" GREATEST_MAIN_DEFS(); diff --git a/test/test_phev_register.c b/test/test_phev_register.c index 72a8fcd..0a2c56b 100644 --- a/test/test_phev_register.c +++ b/test/test_phev_register.c @@ -11,12 +11,12 @@ #define PHEV_CONNECT_MAX_RETRIES 2 #endif -#include "phev_register.h" -#include "phev_service.h" -#include "msg_core.h" -#include "msg_pipe.h" -#include "msg_utils.h" -#include "phev_pipe.h" +#include "phev/phev_register.h" +#include "phev/phev_service.h" +#include "msg/msg_core.h" +#include "msg/msg_pipe.h" +#include "msg/msg_utils.h" +#include "phev/phev_pipe.h" static message_t * test_phev_register_messages[10]; static message_t * test_phev_register_inHandlerSend = NULL; diff --git a/test/test_phev_service.c b/test/test_phev_service.c index 7ac4de4..3b56d2c 100644 --- a/test/test_phev_service.c +++ b/test/test_phev_service.c @@ -4,8 +4,8 @@ #include #include "greatest.h" #include "cJSON.h" -#include "msg_utils.h" -#include "phev_service.h" +#include "msg/msg_utils.h" +#include "phev/phev_service.h" GREATEST_MAIN_DEFS();