fix: move IOT to capteur subfolder
This commit is contained in:
7
IOT/Capteur/.clang-tidy
Normal file
7
IOT/Capteur/.clang-tidy
Normal file
@ -0,0 +1,7 @@
|
||||
# Clangtidy configuration file (not used until PIO 6)
|
||||
---
|
||||
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'
|
||||
WarningsAsErrors: false
|
||||
HeaderFilterRegex: ''
|
||||
AnalyzeTemporaryDtors: false
|
||||
FormatStyle: google
|
39
IOT/Capteur/.editorconfig
Normal file
39
IOT/Capteur/.editorconfig
Normal file
@ -0,0 +1,39 @@
|
||||
root = true
|
||||
|
||||
# Base Configuration
|
||||
[*]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
max_line_length = 120
|
||||
end_of_line = lf
|
||||
|
||||
# Yaml Standard
|
||||
[*.{yaml,yml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
# Markdown Standards
|
||||
[*.md]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
# Java, Kotlin, Gradle, XML Standards
|
||||
[*.{java,kt,kts,gradle,xml,pro}]
|
||||
indent_style = space
|
||||
|
||||
|
||||
# C++ Files
|
||||
[*.{cpp,h,ino}]
|
||||
indent_style = space
|
||||
|
||||
# PHP files
|
||||
[*.php]
|
||||
indent_style = space
|
||||
|
||||
# INI Files
|
||||
[*.ini]
|
||||
indent_style = space
|
12
IOT/Capteur/.gitignore
vendored
Normal file
12
IOT/Capteur/.gitignore
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
# macOS
|
||||
.DS_Store
|
||||
|
||||
# Platformio specifics
|
||||
.pio
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
|
||||
# Aptatio/Platformio specifics
|
||||
secrets.ini
|
10
IOT/Capteur/.vscode/extensions.json
vendored
Normal file
10
IOT/Capteur/.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"platformio.platformio-ide"
|
||||
],
|
||||
"unwantedRecommendations": [
|
||||
"ms-vscode.cpptools-extension-pack"
|
||||
]
|
||||
}
|
6
IOT/Capteur/.vscode/settings.json
vendored
Normal file
6
IOT/Capteur/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"*.html": "html",
|
||||
"cmath": "cpp"
|
||||
}
|
||||
}
|
19
IOT/Capteur/config.cppcheck
Normal file
19
IOT/Capteur/config.cppcheck
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- CPP Check configuation file -->
|
||||
<project version="1">
|
||||
<builddir>.cppcheck-build</builddir>
|
||||
<platform>Unspecified</platform>
|
||||
<analyze-all-vs-configs>false</analyze-all-vs-configs>
|
||||
<check-headers>true</check-headers>
|
||||
<check-unused-templates>false</check-unused-templates>
|
||||
<max-ctu-depth>10</max-ctu-depth>
|
||||
<exclude>
|
||||
<path name=".pio/"/>
|
||||
</exclude>
|
||||
<suppressions>
|
||||
<suppression>noCopyConstructor</suppression>
|
||||
<suppression>noExplicitConstructor</suppression>
|
||||
<suppression>unusedFunction</suppression>
|
||||
<suppression>noOperatorEq</suppression>
|
||||
</suppressions>
|
||||
</project>
|
19
IOT/Capteur/config.ini
Normal file
19
IOT/Capteur/config.ini
Normal file
@ -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\"
|
18
IOT/Capteur/docs/README.md
Normal file
18
IOT/Capteur/docs/README.md
Normal file
@ -0,0 +1,18 @@
|
||||
# Docs
|
||||
|
||||
Documentation Technique du projet
|
||||
|
||||
## fichiers .puml
|
||||
|
||||
Les fichiers en .puml sont des fichiers UMLs sous forme de code
|
||||
|
||||
Afin d'en avoir le résultat graphique :
|
||||
|
||||
1. Ouvrez un navigateur
|
||||
2. lancer le lien suivant [https://www.plantuml.com/plantuml/uml/](https://www.plantuml.com/plantuml/uml/)
|
||||
3. Copiez/Collez le contenu du fichier .puml dans le voite de texte
|
||||
4. Cliquez sur `Submit`
|
||||
|
||||
ou si vous utilisez `VSCode`:
|
||||
1. installez l'extensions [PlantUML](https://marketplace.visualstudio.com/items?itemName=jebbs.plantuml) _jebbs.plantuml_
|
||||
2. `ALT+D` lorsque vous êtes dans un fichier .puml
|
15
IOT/Capteur/envs.ini
Normal file
15
IOT/Capteur/envs.ini
Normal file
@ -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
|
26
IOT/Capteur/include/Program.h
Normal file
26
IOT/Capteur/include/Program.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef PROGRAM_H
|
||||
#define PROGRAM_H
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "Capteur.h"
|
||||
#include "HumiTemp.h"
|
||||
|
||||
class Program {
|
||||
public:
|
||||
/**
|
||||
* Program startup
|
||||
*/
|
||||
Program();
|
||||
|
||||
/**
|
||||
* Program main loop
|
||||
*/
|
||||
void loop();
|
||||
private:
|
||||
|
||||
//TODO: faire commentaire
|
||||
Capteur* DHT;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
39
IOT/Capteur/include/README
Normal file
39
IOT/Capteur/include/README
Normal file
@ -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
|
49
IOT/Capteur/lib/Capteur/include/Capteur.h
Normal file
49
IOT/Capteur/lib/Capteur/include/Capteur.h
Normal file
@ -0,0 +1,49 @@
|
||||
#ifndef CAPTEUR_H
|
||||
#define CAPTEUR_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
class Capteur{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Construct a new Capteur object
|
||||
*
|
||||
* @param[in] type type de mesure lue (T/H, W, D,...)
|
||||
*/
|
||||
Capteur(String type);
|
||||
|
||||
/**
|
||||
* @brief tar le capteur si il a besoins d'être tarré
|
||||
*
|
||||
* @param[in] val *opt* si le capteur a besoins d'une valeur de ref pour être tarré
|
||||
* @return true si la tarre a bien réussi (ou si il n'a pas besoins de tarre)
|
||||
* @return false erreur durrant la tar
|
||||
*/
|
||||
virtual bool tar(int val = 0);
|
||||
|
||||
/**
|
||||
* @brief lit la valeur du capteur
|
||||
*
|
||||
* @return String retour la valeur
|
||||
*/
|
||||
virtual String read() = 0;
|
||||
|
||||
/**
|
||||
* @brief retourne le type de valeur lue
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String getValType();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief type de mesure lue (T/H, W, D,...)
|
||||
*
|
||||
*/
|
||||
String type;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // CAPTEUR_H
|
38
IOT/Capteur/lib/Capteur/include/HumiTemp.h
Normal file
38
IOT/Capteur/lib/Capteur/include/HumiTemp.h
Normal file
@ -0,0 +1,38 @@
|
||||
#ifndef HUMI_TEMP_H
|
||||
#define HUMI_TEMP_H
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <DHT.h>
|
||||
#include "Capteur.h"
|
||||
|
||||
class HumiTemp : public Capteur{
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Construct a new Humi Temp object
|
||||
*
|
||||
* @param pin pin du capteur dht
|
||||
* @param type type de capteur dht (11,22,...)
|
||||
*/
|
||||
HumiTemp(int pin, uint8_t type);
|
||||
|
||||
/**
|
||||
* @brief lit le capteur d'humi/temp
|
||||
*
|
||||
* @return String valeur format "XX/YY" X% et Y°C
|
||||
*/
|
||||
String read();
|
||||
|
||||
//TODO: faire commentaire
|
||||
int getTemp();
|
||||
int getHumi();
|
||||
|
||||
private:
|
||||
|
||||
DHT* capteur;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //HUMI_TEMP_H
|
13
IOT/Capteur/lib/Capteur/src/Capteur.cpp
Normal file
13
IOT/Capteur/lib/Capteur/src/Capteur.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "../include/Capteur.h"
|
||||
|
||||
Capteur::Capteur(String type){
|
||||
this->type = type;
|
||||
}
|
||||
|
||||
bool Capteur::tar(int val){
|
||||
return true;
|
||||
}
|
||||
|
||||
String Capteur::getValType(){
|
||||
return this->type;
|
||||
}
|
34
IOT/Capteur/lib/Capteur/src/HumiTemp.cpp
Normal file
34
IOT/Capteur/lib/Capteur/src/HumiTemp.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include "../include/HumiTemp.h"
|
||||
|
||||
HumiTemp::HumiTemp(int pin, uint8_t type):
|
||||
Capteur("H/T"){
|
||||
this->capteur = new DHT(pin, type);
|
||||
this->capteur->begin();
|
||||
}
|
||||
|
||||
int HumiTemp::getTemp(){
|
||||
int temp = this->capteur->readTemperature();
|
||||
if(isnan(temp)){
|
||||
Serial.println(" DHT reading failed ");
|
||||
return -1;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
int HumiTemp::getHumi(){
|
||||
int hum = this->capteur->readHumidity();
|
||||
if(isnan(hum)){
|
||||
Serial.println(" DHT reading failed ");
|
||||
return -1;
|
||||
}
|
||||
return hum;
|
||||
}
|
||||
|
||||
String HumiTemp::read(){
|
||||
String sortie = "";
|
||||
|
||||
sortie += String(this->getHumi());
|
||||
sortie += "/";
|
||||
sortie += String(this->getTemp());
|
||||
return sortie;
|
||||
}
|
46
IOT/Capteur/lib/README
Normal file
46
IOT/Capteur/lib/README
Normal file
@ -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 <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
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
|
75
IOT/Capteur/platformio.ini
Normal file
75
IOT/Capteur/platformio.ini
Normal file
@ -0,0 +1,75 @@
|
||||
; PlatformIO Project Configuration File
|
||||
|
||||
; WARNING: Items containing version number MUST be the version NOT A RANGE
|
||||
|
||||
; Additionnal files
|
||||
; `secrets.ini`: Secret Build Flags that will be ignored in git (content: `[secrets]\nbuild_flags = `)
|
||||
; `envs.ini`: Build environments
|
||||
; `config.ini`: Global Configuration File
|
||||
|
||||
; Defaults
|
||||
[secrets]
|
||||
build_flags =
|
||||
|
||||
[platformio]
|
||||
default_envs = debug
|
||||
extra_configs =
|
||||
secrets.ini
|
||||
config.ini
|
||||
envs.ini
|
||||
|
||||
; Cache folder
|
||||
build_cache_dir = ./.pio/cache
|
||||
|
||||
[env]
|
||||
; build Envs
|
||||
build_flags = ${config.build_flags} ${secrets.build_flags}
|
||||
|
||||
; Add scripts for more functionnalities
|
||||
; see individual scripts for more informations
|
||||
extra_scripts = pre:scripts/get_additionnal_envs.py
|
||||
|
||||
; Device Settings (make sure to fix versions where possible!)
|
||||
platform = espressif8266
|
||||
board = d1_mini
|
||||
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, time, send_on_enter, default ;, log2file
|
||||
|
||||
; Ask the monitor to echo the content written
|
||||
monitor_echo = yes
|
||||
|
||||
; upload settings
|
||||
; upload_port = COM1
|
||||
|
||||
upload_speed = 921600
|
||||
|
||||
; librairies (make sure to fix versions where possible!)
|
||||
lib_deps =
|
||||
; example:
|
||||
; erropix/ESP32 AnalogWrite@0.2
|
||||
adafruit/DHT sensor library@^1.4.4
|
||||
adafruit/Adafruit Unified Sensor@^1.1.9 ; required by DHT
|
||||
|
||||
; Checker settings
|
||||
check_tool = clangtidy, cppcheck
|
||||
|
||||
; Filters for checkers
|
||||
check_src_filters =
|
||||
+<src/>
|
||||
+<include/>
|
||||
+<lib/>
|
||||
+<test/>
|
||||
-<.pio/>
|
||||
|
||||
; Ask pio to not scan `./.pio` files
|
||||
check_skip_packages = yes
|
||||
|
||||
; use config files for clangtidy and cppcheck
|
||||
check_flags =
|
||||
clangtidy: --config-file=.clang-tidy
|
||||
cppcheck: --project=config.cppcheck --inline-suppr -i=".pio"
|
41
IOT/Capteur/scripts/get_additionnal_envs.py
Normal file
41
IOT/Capteur/scripts/get_additionnal_envs.py
Normal file
@ -0,0 +1,41 @@
|
||||
"""
|
||||
Add additionnal ENVs to the program
|
||||
|
||||
GIT_COMMIT: the git commit ID
|
||||
GIT_BRANCH: the current git branch
|
||||
GIT_TAG: the current git tag or "dev"
|
||||
|
||||
_note: to get the full list of env at build time run: `pio run -t envdump > pouet.log` and look at "BUILD_FLAGS_
|
||||
"""
|
||||
|
||||
import subprocess
|
||||
|
||||
Import("env")
|
||||
|
||||
def run_command(command):
|
||||
"""
|
||||
run a command on the system
|
||||
"""
|
||||
return subprocess.run(command, stdout=subprocess.PIPE, text=True).stdout
|
||||
|
||||
def get_additionnal_envs():
|
||||
"""
|
||||
get the git commit/branch/tag of the project and return them
|
||||
"""
|
||||
commit = run_command(["git", "rev-parse", "HEAD"])[:7]
|
||||
branch = run_command(["git", "rev-parse", "--abbrev-ref", "HEAD"])
|
||||
tag = run_command(["git", "tag", "-l", "--points-at", "HEAD"])
|
||||
|
||||
items = [
|
||||
f"-D GIT_COMMIT=\\\"{commit}\\\"",
|
||||
f"-D GIT_BRANCH=\\\"{branch.strip()}\\\""
|
||||
]
|
||||
if tag != "":
|
||||
items.append(f"-D GIT_TAG=\\\"{tag.strip()}\\\"")
|
||||
else:
|
||||
items.append("-D GIT_TAG=\\\"dev\\\"")
|
||||
return items
|
||||
|
||||
env.Append(
|
||||
BUILD_FLAGS=get_additionnal_envs()
|
||||
)
|
6
IOT/Capteur/secrets.ini.example
Normal file
6
IOT/Capteur/secrets.ini.example
Normal file
@ -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 =
|
13
IOT/Capteur/src/Program.cpp
Normal file
13
IOT/Capteur/src/Program.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "Program.h"
|
||||
|
||||
Program::Program() {
|
||||
// Startup
|
||||
Serial.begin(MONITOR_SPEED);
|
||||
this->DHT = new HumiTemp(D4, DHT22);
|
||||
}
|
||||
|
||||
void Program::loop() {
|
||||
// Loop
|
||||
delay(2000);
|
||||
Serial.println(this->DHT->read());
|
||||
}
|
11
IOT/Capteur/src/main.cpp
Normal file
11
IOT/Capteur/src/main.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "Program.h"
|
||||
|
||||
Program* program;
|
||||
|
||||
void setup() {
|
||||
program = new Program();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
program->loop();
|
||||
}
|
11
IOT/Capteur/test/README
Normal file
11
IOT/Capteur/test/README
Normal file
@ -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
|
Reference in New Issue
Block a user