From 30a198b3b5f0228605566114b1f1c9876c3bcf13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Boesmier?= Date: Mon, 6 Mar 2023 15:15:14 +0100 Subject: [PATCH] add initial IOT project --- IOT/.gitignore | 4 ++++ IOT/config.ini | 19 +++++++++++++++ IOT/envs.ini | 15 ++++++++++++ IOT/include/README | 39 +++++++++++++++++++++++++++++++ IOT/lib/README | 46 +++++++++++++++++++++++++++++++++++++ IOT/platformio.ini | 51 +++++++++++++++++++++++++++++++++++++++++ IOT/secrets.ini.example | 6 +++++ IOT/src/main.cpp | 9 ++++++++ IOT/test/README | 11 +++++++++ 9 files changed, 200 insertions(+) create mode 100644 IOT/.gitignore create mode 100644 IOT/config.ini create mode 100644 IOT/envs.ini create mode 100644 IOT/include/README create mode 100644 IOT/lib/README create mode 100644 IOT/platformio.ini create mode 100644 IOT/secrets.ini.example create mode 100644 IOT/src/main.cpp create mode 100644 IOT/test/README diff --git a/IOT/.gitignore b/IOT/.gitignore new file mode 100644 index 0000000..746d273 --- /dev/null +++ b/IOT/.gitignore @@ -0,0 +1,4 @@ +.pio +.vscode/* + +secrets.ini \ No newline at end of file diff --git a/IOT/config.ini b/IOT/config.ini new file mode 100644 index 0000000..3ffeff4 --- /dev/null +++ b/IOT/config.ini @@ -0,0 +1,19 @@ +; Project configuration file + +[config] +; Hardware Serial baud rate +; Also available in the code as `MONITOR_SPEED` +monitor_speed = 115200 + +; Software Config +; note: additionnal flags are added by Platform.io (see total amount in `.vscode/c_cpp_properties.json` in the `defines` section) +; notworthy ones: +; __PLATFORMIO_BUILD_DEBUG__ = debug mode +build_flags = +; DO NOT TOUCH --- START + -D MONITOR_SPEED=${config.monitor_speed} +; DO NOT TOUCH --- END + + -D EXAMPLE_NUMBER=69 + + -D EXAMPLE_STRING=\"Pouet\" \ No newline at end of file diff --git a/IOT/envs.ini b/IOT/envs.ini new file mode 100644 index 0000000..b3db1a7 --- /dev/null +++ b/IOT/envs.ini @@ -0,0 +1,15 @@ +; Add additionnal environments in this file + +; Default production environment +[env:prod] + +; Debug environemnt +[env:debug] +build_type = debug + + +; Example additionnal env +; [env:example] +; ; note: keep the `${env.build_flags}` to includes others build flags +; build_flags = ${env.build_flags} +; -D POUET \ No newline at end of file diff --git a/IOT/include/README b/IOT/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/IOT/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/IOT/lib/README b/IOT/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/IOT/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/IOT/platformio.ini b/IOT/platformio.ini new file mode 100644 index 0000000..82e4637 --- /dev/null +++ b/IOT/platformio.ini @@ -0,0 +1,51 @@ +; PlatformIO Project Configuration File + +; Additionnal files +; `secrets.ini`: Secret Build Flags that will be ignored in git (content: `[secrets]\nbuild_flags = `) +; `envs.ini`: Build environments + +; Defaults +[secrets] +build_flags = + +[platformio] +default_envs = debug +extra_configs = + secrets.ini + config.ini + envs.ini + +[env] +; build Envs +build_flags = ${config.build_flags} ${secrets.build_flags} + +; Device Settings +platform = atmelavr +board = megaatmega2560 +framework = arduino + +; Monitoring settings +monitor_speed = ${config.monitor_speed} +; note: make sure to rebuild after changing it (log2file add a .log file containing the monitor logs) +monitor_filters = esp32_exception_decoder, default ;, log2file +monitor_flags = + --echo + +; upload settings +; upload_port = COM1 + +; librairies +lib_deps = +; example: +; erropix/ESP32 AnalogWrite@^0.2 + +; Checker settings +check_tool = clangtidy, cppcheck +check_patterns = + src/ + include/ + lib/ +check_skip_packages = yes +check_flags = + clangtidy: --checks=abseil-*,boost-*,bugprone-*,cert-*,cppcoreguidelines-*,clang-analyzer-*,google-*,hicpp-*,modernize-*,performance-*,portability-*,readability-*,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-modernize-use-trailing-return-type,-cppcoreguidelines-init-variables + cppcheck: --project=config.cppcheck diff --git a/IOT/secrets.ini.example b/IOT/secrets.ini.example new file mode 100644 index 0000000..a3afda8 --- /dev/null +++ b/IOT/secrets.ini.example @@ -0,0 +1,6 @@ +; Add secrets token/logins/etc `secrets.ini` +; Add the sames values as blank in `secrets.ini.example +; To be able to reproduce it + +[secrets] +build_flags = \ No newline at end of file diff --git a/IOT/src/main.cpp b/IOT/src/main.cpp new file mode 100644 index 0000000..58b344c --- /dev/null +++ b/IOT/src/main.cpp @@ -0,0 +1,9 @@ +#include + +void setup() { + // put your setup code here, to run once: +} + +void loop() { + // put your main code here, to run repeatedly: +} \ No newline at end of file diff --git a/IOT/test/README b/IOT/test/README new file mode 100644 index 0000000..9b1e87b --- /dev/null +++ b/IOT/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html