26 Commits

Author SHA1 Message Date
b1728b0509 feat: intégration DHT capteur 2023-04-04 11:22:24 +02:00
a6abcd4fe1 Merge pull request 'feat(IOT): LibAPI' (#21) from feat/LibAPI into master
Reviewed-on: https://gitea.cb85.software/Epitech-T-DEV-811/T-DEV-811/pulls/21
Reviewed-by: nico <nicolas.sansd@gmail.com>
2023-04-03 16:55:12 +02:00
4bde578c35 update config 2023-04-03 16:30:44 +02:00
60bb2911f4 remove(iot): test in main programme 2023-04-03 16:30:34 +02:00
97ae6c6977 docs(iot): documentation de la lib api client 2023-04-03 16:23:59 +02:00
789cab74a9 refactor(iot): change type of connect on api 2023-04-03 16:19:32 +02:00
59728b9694 feat(iot): API Client OK 2023-04-03 16:07:57 +02:00
7861cfae51 feat: connection OK 2023-04-03 12:06:39 +02:00
3208c2ff6b feat(WIP): test main API lib 2023-04-03 11:10:12 +02:00
89ecb3bf17 feat: commentaire 2023-04-03 11:09:44 +02:00
c57225c1f3 feat(iot): connection wifi and API *UNTESTED* 2023-03-28 17:28:55 +02:00
98e0342fe1 feat(iot): constructeur API 2023-03-28 16:05:36 +02:00
bcfe0a07f8 Merge pull request 'feat: CAO link in readme' (#22) from clement-patch-1 into master
Reviewed-on: https://gitea.cb85.software/Epitech-T-DEV-811/T-DEV-811/pulls/22
2023-03-28 07:39:17 +00:00
ad524cfc68 feat: CAO link in readme 2023-03-28 07:38:39 +00:00
e8ebe48128 feat: init api lib 2023-03-27 17:42:17 +02:00
31dfa751a3 feat: add deps 2023-03-27 17:41:53 +02:00
e56b92aa7b Merge pull request 'docs/diagram-API' (#10) from docs/diagram-API into master
Reviewed-on: https://gitea.cb85.software/Epitech-T-DEV-811/T-DEV-811/pulls/10
Reviewed-by: MDeghaud <michel.deghaud@epitech.eu>
Reviewed-by: nico <nicolas.sansd@gmail.com>
2023-03-21 11:03:46 +00:00
d2a89b5a2c fix: rm useless field 2023-03-21 12:02:15 +01:00
c5576c2c63 fix: rename iot folder to IOT 2023-03-21 11:58:57 +01:00
ab70befc0c fix little issue on API diagram 2023-03-21 11:42:48 +01:00
2e40495cc1 class data 2023-03-21 09:56:42 +01:00
2b91951a27 docs: mouve api diagram to rigt place 2023-03-20 12:57:41 +01:00
d6c473982e folders api/docs 2023-03-20 12:11:46 +01:00
25c5dd0b82 relation 2023-03-20 11:56:10 +01:00
94aad21613 relation and primary key 2023-03-20 11:06:45 +01:00
65b0befcc0 implémentation du diagramme de séquence 2023-03-20 10:03:46 +01:00
31 changed files with 264 additions and 868 deletions

81
.gitignore vendored
View File

@ -1,81 +0,0 @@
.idea
# Created by https://www.toptal.com/developers/gitignore/api/unity
# Edit at https://www.toptal.com/developers/gitignore?templates=unity
### Unity ###
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Uu]ser[Ss]ettings/
# MemoryCaptures can get excessive in size.
# They also could contain extremely sensitive data
/[Mm]emoryCaptures/
# Recordings can get excessive in size
/[Rr]ecordings/
# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*
# Autogenerated Jetbrains Rider plugin
/[Aa]ssets/Plugins/Editor/JetBrains*
# Visual Studio cache directory
.vs/
# Gradle cache directory
.gradle/
# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db
# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta
# Unity3D generated file on crash reports
sysinfo.txt
# Builds
*.apk
*.aab
*.unitypackage
*.app
# Crashlytics generated file
crashlytics-build.properties
# Packed Addressables
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*
# End of https://www.toptal.com/developers/gitignore/api/unity
IOT/docs/doxygen output/*

View File

@ -1,29 +0,0 @@
@startuml diagram
class users {
id: text
username: text
email: email
name: text
image: file
created: date
updated: date
}
class trashs{
id: text
value: text
author: users
created: date
updated: date
}
class data {
id: text
value: number
poubelle_id: trashs
unit: text
status: bool
created: date
updated: date
}
users "1" <-- trashs
trashs "1" <-- data
@enduml

View File

@ -1,29 +0,0 @@
@startuml diagram
class users {
id: text
username: text
email: email
name: text
image: file
created: date
updated: date
}
class trashs{
id: text
value: text
author: users
created: date
updated: date
}
class data {
id: text
value: number
trashs_id: trashs
unit: text
status: bool
created: date
updated: date
}
users "1" <-- trashs
trashs "1" <-- data
@enduml

View File

@ -1,29 +0,0 @@
@startuml diagram
class users {
id: text
username: text
email: email
name: text
image: file
created: date
updated: date
}
class trashs{
id: text
owner: users
number: text
created: date
updated: date
}
class data {
id: text
value: number
trashs_id: trashs
unit: text
status: bool
created: date
updated: date
}
users "1" <-- trashs
trashs "1" <-- data
@enduml

View File

@ -1,29 +0,0 @@
@startuml diagram
class users {
id: text
username: text
email: email
name: text
image: file
created: date
updated: date
}
class trashs{
id: text
owner: users
number: text
created: date
updated: date
}
class data {
id: text
trashs_id: trashs
unit: text
status: bool
value: number
created: date
updated: date
}
users "1" <-- trashs
trashs "1" <-- data
@enduml

View File

@ -1,3 +0,0 @@
{
"C_Cpp.errorSquiggles": "disabled"
}

View File

@ -10,17 +10,17 @@ class users {
}
class trashs{
id: text
owner: users
number: text
value: text
author: users
created: date
updated: date
}
class data {
id: text
trashs_id: trashs
value: number
poubelle_id: trashs
unit: text
status: bool
value: number
created: date
updated: date
}

View File

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 19cf999df50c445ba3c964510468fb8d
timeCreated: 1679395580

View File

@ -1,3 +0,0 @@
API_URL=https://helloworld.com
API_USER=hello
API_PASSWORD=world

55
AR/.gitattributes vendored
View File

@ -1,55 +0,0 @@
# 3D models
*.3dm filter=lfs diff=lfs merge=lfs -text
*.3ds filter=lfs diff=lfs merge=lfs -text
*.blend filter=lfs diff=lfs merge=lfs -text
*.c4d filter=lfs diff=lfs merge=lfs -text
*.collada filter=lfs diff=lfs merge=lfs -text
*.dae filter=lfs diff=lfs merge=lfs -text
*.dxf filter=lfs diff=lfs merge=lfs -text
*.fbx filter=lfs diff=lfs merge=lfs -text
*.jas filter=lfs diff=lfs merge=lfs -text
*.lws filter=lfs diff=lfs merge=lfs -text
*.lxo filter=lfs diff=lfs merge=lfs -text
*.ma filter=lfs diff=lfs merge=lfs -text
*.max filter=lfs diff=lfs merge=lfs -text
*.mb filter=lfs diff=lfs merge=lfs -text
*.obj filter=lfs diff=lfs merge=lfs -text
*.ply filter=lfs diff=lfs merge=lfs -text
*.skp filter=lfs diff=lfs merge=lfs -text
*.stl filter=lfs diff=lfs merge=lfs -text
*.ztl filter=lfs diff=lfs merge=lfs -text
# Audio
*.aif filter=lfs diff=lfs merge=lfs -text
*.aiff filter=lfs diff=lfs merge=lfs -text
*.it filter=lfs diff=lfs merge=lfs -text
*.mod filter=lfs diff=lfs merge=lfs -text
*.mp3 filter=lfs diff=lfs merge=lfs -text
*.ogg filter=lfs diff=lfs merge=lfs -text
*.s3m filter=lfs diff=lfs merge=lfs -text
*.wav filter=lfs diff=lfs merge=lfs -text
*.xm filter=lfs diff=lfs merge=lfs -text
# Fonts
*.otf filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
# Images
*.bmp filter=lfs diff=lfs merge=lfs -text
*.exr filter=lfs diff=lfs merge=lfs -text
*.gif filter=lfs diff=lfs merge=lfs -text
*.hdr filter=lfs diff=lfs merge=lfs -text
*.iff filter=lfs diff=lfs merge=lfs -text
*.jpeg filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.pict filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.psd filter=lfs diff=lfs merge=lfs -text
*.tga filter=lfs diff=lfs merge=lfs -text
*.tif filter=lfs diff=lfs merge=lfs -text
*.tiff filter=lfs diff=lfs merge=lfs -text
# Collapse Unity-generated files on GitHub
*.asset linguist-generated
*.mat linguist-generated
*.meta linguist-generated
*.prefab linguist-generated
*.unity linguist-generated

147
AR/.gitignore vendored
View File

@ -1,147 +0,0 @@
# This .gitignore file should be placed at the root of your Unity project directory
# First part from https://github.com/github/gitignore/blob/master/Unity.gitignore
# Parkerhill additions at the end
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Uu]ser[Ss]ettings/
# MemoryCaptures can get excessive in size.
# They also could contain extremely sensitive data
/[Mm]emoryCaptures/
# Asset meta data should only be ignored when the corresponding asset is also ignored
!/[Aa]ssets/**/*.meta
# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*
# Autogenerated Jetbrains Rider plugin
/[Aa]ssets/Plugins/Editor/JetBrains*
# Visual Studio cache directory
.vs/
# Gradle cache directory
.gradle/
# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db
# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta
# Unity3D generated file on crash reports
sysinfo.txt
# Builds
*.apk
*.aab
*.unitypackage
# Crashlytics generated file
crashlytics-build.properties
# Packed Addressables
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*
# =========================
# PARKERHILL ADDITIONS
# =========================
# Unity app files
.GameStatistics
.PlayerSettings
# parkerhill unity project folder conventions
/AssetBundles/
# =========================
# OSX
# =========================
.DS_Store
.AppleDouble
.LSOverride
# thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# =========================
# Windows
# =========================
# Windows image file caches
Thumbs.db
Thumbs.db.meta
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
# Visual Studio stuff
.vs/
.idea/
.gradle/
PackageBackups/
# UWP builds
/UWP/*
.env

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 5040ff35809714c9f899bd2e7ae0f30a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 0a1aa25d695ea4175bf4920feb2742e1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,109 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-4490881977315335027
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 1
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: PlacedCubeMat
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaClip: 0
- _Blend: 0
- _BumpScale: 1
- _Cull: 2
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _EnvironmentReflections: 1
- _GlossMapScale: 1
- _Glossiness: 0
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Surface: 0
- _UVSec: 0
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0, g: 0.74509805, b: 0.8196079, a: 1}
- _Color: {r: 0.9647059, g: 0.455222, b: 0.11854753, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 0ce7ca15cd93341beb67396a494cef55
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,79 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: PlaneMat
m_Shader: {fileID: 4800000, guid: 9b989c81462e144eb95a232bec4719d5, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: af6bcea09b8134831b6599e2900aef81, type: 3}
m_Scale: {x: 2.25, y: 2.25}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _PlaneColor: {r: 1, g: 1, b: 1, a: 0}
- _TexTintColor: {r: 1, g: 1, b: 1, a: 0.4}

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 2da0ea038f25a4fa998f183878aedf79
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 262e742d15f1b4d1487c6709552f51e9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

6
IOT/README.md Normal file
View File

@ -0,0 +1,6 @@
#IOT:
## setup :
rename `secrets.ini.example` to `secrets.ini`

View File

@ -14,6 +14,8 @@ build_flags =
-D MONITOR_SPEED=${config.monitor_speed}
; DO NOT TOUCH --- END
-D EXAMPLE_NUMBER=69
-D API_HOST=\"iot.epi.cb85.software\"
-D DHTTYPE=\"DHT11\"
-D DHTPIN=2
-D EXAMPLE_STRING=\"Pouet\"

View File

@ -1,6 +1,8 @@
#ifndef PROGRAM_H
#define PROGRAM_H
#include "DHT.h"
class Program{
public:
/**
@ -17,5 +19,11 @@ public:
private:
/* data */
/**
* @brief capteur humi/temp
*
*/
DHT *dht;
};
#endif

94
IOT/lib/API/include/API.h Normal file
View File

@ -0,0 +1,94 @@
#ifndef API_H
#define API_H
#include <Arduino_JSON.h>
#include <WiFiEsp.h>
class API {
public:
/**
* @brief Construit un nouvelle objet API
*
* @param[in] user nom de l'utilisateur de l'API
* @param[in] password mot de passe de l'utilisateur
* @param[in] host address de l'api
* @param[in] https l'address de l'api est en https *(defaut `true`)*
*/
API(String user, String password, String host, bool https = true);
/**
* @brief Initialise la connection Wifi de l'esp
*
* @param wifiId nom du wifi
* @param wifiPass mot de passe du wifi
* @param espSerial port serie de l'esp (hard ou soft)
* @return true la connexion a bien fonctionner
* @return false erreur a la connexion
*/
bool wifiBegin(String wifiId, String wifiPass, Stream* espSerial);
/**
* @brief envoie la valeur d'un capteur de poubelle à l'api
*
* @param val valeur du capteur
* @param poubelleID ID de la poubelle
* @param unit uniter de mesure du capteur *(ex: g, cm, degree,...)
* @param full poubelle est considéré comme pleine
* @return true la valeur s'est bien envoyer
* @return false il y a une erreur durran l'envoie
*/
bool sendValute(String val, String poubelleID, String unit, bool full);
private:
/**
* @brief connect l'utilisateur a l'api et met a jour le token
*
* @return true l'utilisateur est bien connecter
* @return false erreur lors de la connexion de l'utilisateur
*/
bool connect();
/**
* @brief ID de l'utilisateur
*
*/
String user;
/**
* @brief mdp de l'utilisateur
*
*/
String password;
/**
* @brief adresse du serveur API
*
*/
String serveurHost;
/**
* @brief true = serveur en https (443)
*
*/
bool https;
/**
* @brief client http
*
*/
WiFiEspClient* client;
/**
* @brief token de connexion du client (vide = deconnecter)
*
*/
String token;
};
#endif

120
IOT/lib/API/src/API.cpp Normal file
View File

@ -0,0 +1,120 @@
#include "../include/API.h"
API::API(String user, String password, String host, bool https){
this->user = user;
this->password = password;
this->serveurHost = host;
this->https = https;
this->token = "";
this->client = new WiFiEspClient();
}
bool API::wifiBegin(String wifiId, String wifiPass, Stream* espSerial){
WiFi.init(espSerial);
// check for the presence of the shield
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present"); // FIXME: rm debug
return false;
}
// attempt to connect to WiFi network
int status = WL_IDLE_STATUS; // the Wifi radio's status
while (status != WL_CONNECTED) {
status = WiFi.begin(wifiId.c_str(), wifiPass.c_str());
}
return true;
}
bool API::connect(){
this->client->stop();
bool sortie = false;
JSONVar data;
data["identity"] = this->user;
data["password"] = this->password;
String strData = JSONVar::stringify(data);
if(this->https){
if (!this->client->connectSSL(this->serveurHost.c_str(), 443)) {
Serial.println("NOT Connected to server");
return sortie;
}
}else{
if (!this->client->connectSSL(("http://" + this->serveurHost).c_str(), 80)) {
Serial.println("NOT Connected to server");
return sortie;
}
}
this->client->println("POST /api/collections/users/auth-with-password HTTP/1.1");
this->client->println("Host: " + this->serveurHost);
this->client->println("Content-Type: application/json");
this->client->println("Content-Length: " + String(strData.length()));
this->client->println();
this->client->println(strData);
this->client->println("Connection: close");
this->client->println();
while (!client->available()) {}
String responce = "";
while (client->available()) {
responce += (char)client->read();
}
String str = responce.substring(responce.indexOf("{"),responce.lastIndexOf("}")+1);
JSONVar jsonRes = new JSONVar(JSONVar::parse(str));
this->token = JSONVar::stringify(jsonRes["token"]);
this->token = this->token.substring(1,this->token.length()-1);
this->client->stop();
sortie = true;
return sortie;
}
bool API::sendValute(String val, String poubelleID, String valUnit, bool full){
JSONVar data;
data["value"] = val;
data["trash_id"] = poubelleID;
data["unit"] = valUnit;
data["status"] = full;
String strData = JSONVar::stringify(data);
if(this->token == ""){
bool connected = this->connect();
if(!connected)return false;
}
if(this->https){
if (!this->client->connectSSL(("https://" + this->serveurHost).c_str(), 443)) {
Serial.println("NOT Connected to server");
return false;
}
}else{
if (!this->client->connectSSL(("http://" + this->serveurHost).c_str(), 80)) {
Serial.println("NOT Connected to server");
return false;
}
}
this->client->println("POST /api/collections/data/records HTTP/1.1");
this->client->println("Host: " + this->serveurHost);
this->client->println("Content-Type: application/json");
this->client->println("Content-Length: " + String(strData.length()));
this->client->println("Authorization: Bearer " + this->token);
this->client->println();
this->client->print(strData);
this->client->println("Connection: close");
this->client->println();
this->token = "";//XXX: on rm le token a chaque fois car on sais pas si la requet a bien aboutie et donc si il y est encore bon
return true;
}

View File

@ -38,6 +38,8 @@ monitor_flags =
lib_deps =
bportaluri/WiFiEsp@^2.2.2 ; gestion des commande 'AT' de l'esp01
arduino-libraries/Arduino_JSON@^0.2.0 ; gestion des json
adafruit/DHT sensor library@^1.4.4 ; DHT11 lib
adafruit/Adafruit Unified Sensor@^1.1.9 ; adafruit sensor lib (required by DHT11)
; example:
; erropix/ESP32 AnalogWrite@^0.2

View File

@ -3,4 +3,10 @@
; To be able to reproduce it
[secrets]
build_flags =
build_flags =
-D WIFI_SSID=\"...\"
-D WIFI_PASSWORD=\"...\"4
-D USER_NAME=\"...\"
-D USER_PASSWORD=\"...\"

View File

@ -2,9 +2,19 @@
Program::Program(){
// INIT OBJ
this->dht = new DHT(DHTPIN, DHTTYPE);
Serial.begin(MONITOR_SPEED);
dht->begin();
}
void Program::loop(){
//TODO: envoyer les infos des capteur par la suite
Serial.println("Temperature = " + String(dht->readTemperature())+" °C");
Serial.println("Humidite = " + String(dht->readHumidity())+" %");
delay(1000);
}

View File

@ -1,18 +0,0 @@
import PocketBase from 'pocketbase';
const pb = new PocketBase('https://iot.epi.cb85.software');
// fetch a paginated records list
const resultList = await pb.collection('data').getList(1, 50, {
filter: 'created >= "2022-01-01 00:00:00" && someField1 != someField2',
});
// you can also fetch all records at once via getFullList
const records = await pb.collection('data').getFullList(200 /* batch size */, {
sort: '-created',
});
// or fetch only the first record that matches the specified filter
const record = await pb.collection('data').getFirstListItem('someField="test"', {
expand: 'relField1,relField2.subRelField',
});

View File

@ -1,177 +1,12 @@
/*
WiFiEsp example: WebClient
#include <Arduino.h>
#include "Program.h"
This sketch connects to google website using an ESP8266 module to
perform a simple web search.
For more details see: http://yaab-arduino.blogspot.com/p/wifiesp-example-client.html
*/
#include <WiFiEsp.h>
#include <Arduino_JSON.h>
// Emulate Serial1 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
#endif
char ssid[] = "Clement4G"; // TODO: mettre id wifi dans config.ini
char pass[] = "Clement123"; // TODO: mettre pass wifi dans config.ini
int status = WL_IDLE_STATUS; // the Wifi radio's status
//char server[] = "arduino.tips";
char server[] = "iot.epi.cb85.software";
String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb2xsZWN0aW9uSWQiOiJfcGJfdXNlcnNfYXV0aF8iLCJleHAiOjE2ODExMzM4NDMsImlkIjoiZnNlNm9uZ3AxNHN5bHVvIiwidHlwZSI6ImF1dGhSZWNvcmQifQ.QKvfyAQ-lxLHTLyZIQ0FrMYFn5XPTujY_N1Oz6BRHn4";
void printWifiStatus();
JSONVar* connect();
// Initialize the Ethernet client object
WiFiEspClient client;
Program* program;
void setup() {
// initialize serial for debugging
Serial.begin(115200);
// initialize serial for ESP module
Serial1.begin(115200);
// initialize ESP module
WiFi.init(&Serial1);
// check for the presence of the shield
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue
while (true);
}
// attempt to connect to WiFi network
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to WPA SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network
status = WiFi.begin(ssid, pass);
}
// you're connected now, so print out the data
Serial.println("You're connected to the network");
printWifiStatus();
Serial.println();
Serial.println("Starting connection to server...");
// if you get a connection, report back via serial
String temp = JSONVar::stringify((*connect())["token"]);
token = temp.substring(1,temp.length()-1);
Serial.println(token);
String data = "{\"value\": \"123\",\"trash_id\": \"gdnuxl0wlgurtj3\",\"unit\": \"test\",\"status\": true}";
if (client.connectSSL(server, 443)) {
Serial.println("Connected to server");
// Make a HTTP request
// client.println("GET /api/collections/poubelle_status/records HTTP/1.1");
// client.println("Host: iot.epi.cb85.software");
// client.println("Connection: close");
// client.println();
client.println("POST /api/collections/data/records HTTP/1.1");
client.println("Host: iot.epi.cb85.software");
client.println("Content-Type: application/json");
client.println("Content-Length: " + String(data.length()));
client.println("Authorization: Bearer " + token);
client.println();
client.println(data);
client.println("Connection: close");
client.println();
Serial.print("POUET");
}
program = new Program();
}
void loop() {
// if there are incoming bytes available
// from the server, read them and print them
if (!client.available()) {
return;
}
while (client.available()) {
char c = client.read();
Serial.write(c);
}
// if the server's disconnected, stop the client
if (!client.connected()) {
Serial.println();
Serial.println("Disconnecting from server...");
client.stop();
// do nothing forevermore
while (true);
}
}
JSONVar* connect() {
String data = "{\"identity\":\"patrick\",\"password\":\"Patrick123\"}";
JSONVar* json = new JSONVar();
if (!client.connectSSL(server, 443)) {
Serial.println("NOT Connected to server");
return json;
}
client.println("POST /api/collections/users/auth-with-password HTTP/1.1");
client.println("Host: iot.epi.cb85.software");
client.println("Content-Type: application/json");
client.println("Content-Length: " + String(data.length()));
client.println();
client.println(data);
client.println("Connection: close");
client.println();
while (!client.available()) {
}
String responce = "";
while (client.available()) {
responce += (char)client.read();
}
Serial.println("---------------");
Serial.println(responce);
Serial.println("---------------");
String sortie = responce.substring(responce.indexOf("{"),responce.lastIndexOf("}")+1);
*json = JSON.parse(sortie);
return json;
}
void printWifiStatus() {
// print the SSID of the network you're attached to
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength
long rssi = WiFi.RSSI();
Serial.print("Signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
program->loop();
}

View File

@ -1,18 +0,0 @@
import PocketBase from 'pocketbase';
const pb = new PocketBase('https://iot.epi.cb85.software');
// fetch a paginated records list
const resultList = await pb.collection('trashs').getList(1, 50, {
filter: 'created >= "2022-01-01 00:00:00" && someField1 != someField2',
});
// you can also fetch all records at once via getFullList
const records = await pb.collection('trashs').getFullList(200 /* batch size */, {
sort: '-created',
});
// or fetch only the first record that matches the specified filter
const record = await pb.collection('trashs').getFirstListItem('someField="test"', {
expand: 'relField1,relField2.subRelField',
});

View File

@ -1,18 +0,0 @@
import PocketBase from 'pocketbase';
const pb = new PocketBase('https://iot.epi.cb85.software');
// fetch a paginated records list
const resultList = await pb.collection('users').getList(1, 50, {
filter: 'created >= "2022-01-01 00:00:00" && someField1 != someField2',
});
// you can also fetch all records at once via getFullList
const records = await pb.collection('users').getFullList(200 /* batch size */, {
sort: '-created',
});
// or fetch only the first record that matches the specified filter
const record = await pb.collection('users').getFirstListItem('someField="test"', {
expand: 'relField1,relField2.subRelField',
});

View File

@ -1,4 +1,7 @@
# Depot IOT VR
Lien du Gitea : (depot principale + gestion de projet)
https://gitea.cb85.software/Epitech-T-DEV-811/T-DEV-811
https://gitea.cb85.software/Epitech-T-DEV-811/T-DEV-811
Lien de la CAO : https://cad.onshape.com/documents/d370ee863400195afb23d026/w/1a94981b6a6f71d70b075e30/e/d0feb75fc5a122c54598349b?renderMode=0&uiState=6422993bab4d903a51186392