From 830d40a777251dd281972c79fb0d0ab4bc5601bf Mon Sep 17 00:00:00 2001 From: Clement Date: Sun, 14 May 2023 11:04:47 +0200 Subject: [PATCH 1/6] fix api --- IOT/lib/API/src/API.cpp | 1 - IOT/src/Program.cpp | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/IOT/lib/API/src/API.cpp b/IOT/lib/API/src/API.cpp index 5af9675..a9b45d0 100644 --- a/IOT/lib/API/src/API.cpp +++ b/IOT/lib/API/src/API.cpp @@ -119,6 +119,5 @@ bool API::sendValue(String val, String poubelleID, String valUnit, bool full){ 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; } \ No newline at end of file diff --git a/IOT/src/Program.cpp b/IOT/src/Program.cpp index d2afe08..33f31af 100644 --- a/IOT/src/Program.cpp +++ b/IOT/src/Program.cpp @@ -33,15 +33,14 @@ void Program::loop(){ this->screen->printVal(distance, poid, humitemp); this->api->sendValue(distance, TRASHCAN_ONE, this->ultrasonic->getValType(), this->ultrasonic->isFull()); - Serial.print("Distance in CM = " + distance); Serial.println(this->ultrasonic->isFull()?" true":" false"); + Serial.println("humiTemp = " + humitemp); this->api->sendValue(humitemp, TRASHCAN_TWO, this->dht->getValType(), this->dht->isFull()); - Serial.print("humiTemp = " + humitemp); Serial.println(this->dht->isFull()?" true":" false"); + Serial.println("poid = " + poid); this->api->sendValue(poid, TRASHCAN_THREE, this->balance->getValType(), this->balance->isFull()); - Serial.print("poid = " + poid); Serial.println(this->balance->isFull()?" true":" false"); Serial.println(); From ef447b2dc7e536b2078d6e99d78200e21cb87851 Mon Sep 17 00:00:00 2001 From: Clement Date: Sun, 14 May 2023 22:25:15 +0200 Subject: [PATCH 2/6] fix link in readme --- README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 33ad593..0a4e7bd 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,10 @@ # Depot IOT VR Lien du Gitea : (depot principale + gestion de projet) -https://gitea.cb85.software/Epitech-T-DEV-811/T-DEV-811 - +https://git.lab-ouest.org/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 - ### Mobile/Unity Pour gérer l'AR, nous avons décider d'utiliser Unity et pour résoudre le souci de multi target en AR, nous avons utilisé Vuforia. @@ -21,7 +19,7 @@ coté IoT, les valeurs de chaque capteurs sont envoyé à l'API puis ensuite, l' le champ 'unit' dans la collection trash correspond au type de capteur que l'IoT va envoyer a l'api. Le mapping suivant a été conventionner: | Capteur | Unit | Valeur | -|----------------------|:----:|--------------------------------------| +| -------------------- |:----:| ------------------------------------ | | Temperature/Humidité | T/H | 10.0;50 (10 degré et 50% d'humidité) | -| Poids | W | 200 (200 gram) | -| Distance | D | 40 (40 cm) | \ No newline at end of file +| Poids | W | 200 (200 gram) | +| Distance | D | 40 (40 cm) | \ No newline at end of file From 650290ab678c1628a3aae7c1f14ad3320c32fece Mon Sep 17 00:00:00 2001 From: Clement Date: Sun, 14 May 2023 22:26:32 +0200 Subject: [PATCH 3/6] fix readme iot --- IOT/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/IOT/README.md b/IOT/README.md index 8942b26..729545c 100644 --- a/IOT/README.md +++ b/IOT/README.md @@ -3,4 +3,6 @@ ## setup : -rename `secrets.ini.example` to `secrets.ini` \ No newline at end of file +renomé `secrets.ini.example` to `secrets.ini` et le remplir + +compiler avec Platform.io \ No newline at end of file From 7b21441976f8575f556c3e9a830b41b255e669f0 Mon Sep 17 00:00:00 2001 From: Clement Date: Sun, 14 May 2023 23:16:16 +0200 Subject: [PATCH 4/6] fix some thing --- IOT/config.ini | 6 ++++-- IOT/lib/API/include/API.h | 8 +++++--- IOT/lib/API/src/API.cpp | 3 +++ IOT/lib/Capteur/src/HumiTemp.cpp | 10 +++++++++- IOT/lib/Capteur/src/Ultrason.cpp | 6 +++--- IOT/src/Program.cpp | 1 - 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/IOT/config.ini b/IOT/config.ini index 0481ac1..50af406 100644 --- a/IOT/config.ini +++ b/IOT/config.ini @@ -45,7 +45,9 @@ build_flags = -D API_HOST=\"iot.epi.cb85.software\" ;---CAPTEUR FULL CONFIG--- - - -D ULTRA_SOUND_FULL=\"10\" + ;valFull/valReset + -D ULTRA_SOUND_FULL=\"5/10\" + ;tempmin:tempmax/hummin:humax -D DHT_FULL=\"20:30/60:80\" + ;poid max -D POID_FULL=\"100\" \ No newline at end of file diff --git a/IOT/lib/API/include/API.h b/IOT/lib/API/include/API.h index 463f6f6..0fd0b57 100644 --- a/IOT/lib/API/include/API.h +++ b/IOT/lib/API/include/API.h @@ -49,8 +49,6 @@ public: */ bool connect(); - //TODO :: Check wifibegin avant - private: @@ -89,7 +87,11 @@ private: */ String token; - + /** + * @brief wifi démmaré + * + */ + bool init; }; diff --git a/IOT/lib/API/src/API.cpp b/IOT/lib/API/src/API.cpp index a9b45d0..f6e5161 100644 --- a/IOT/lib/API/src/API.cpp +++ b/IOT/lib/API/src/API.cpp @@ -8,11 +8,13 @@ API::API(String user, String password, String host, bool https){ this->https = https; this->token = ""; this->client = new WiFiEspClient(); + this->init = false; } bool API::wifiBegin(String wifiId, String wifiPass, Stream* espSerial){ WiFi.init(espSerial); + this->init = true; // check for the presence of the shield if (WiFi.status() == WL_NO_SHIELD) { @@ -28,6 +30,7 @@ bool API::wifiBegin(String wifiId, String wifiPass, Stream* espSerial){ return true; } bool API::connect(){ + if(!this->init)return false; this->client->stop(); bool sortie = false; diff --git a/IOT/lib/Capteur/src/HumiTemp.cpp b/IOT/lib/Capteur/src/HumiTemp.cpp index 10fbd56..2aeb2a4 100644 --- a/IOT/lib/Capteur/src/HumiTemp.cpp +++ b/IOT/lib/Capteur/src/HumiTemp.cpp @@ -11,8 +11,16 @@ String HumiTemp::read(){ int hum = this->capteur->readHumidity(true); int temp = this->capteur->readTemperature(false,true); + String stemp = this->fullVall.substring(0, this->fullVall.indexOf("/")); + String shum = this->fullVall.substring(this->fullVall.indexOf("/")+1, this->fullVall.length()); + + int mintemp = stemp.substring(0, stemp.indexOf(":")).toInt(); + int maxtemp = stemp.substring(stemp.indexOf(":")+1, stemp.length()).toInt(); + int minhum = shum.substring(0, shum.indexOf(":")).toInt(); + int maxhum = shum.substring(shum.indexOf(":")+1, shum.length()).toInt(); + //valeur pour un élevage d'astico de pèche selon chatGPT - if((temp > 20 && temp < 30) && (hum > 60 && hum < 80)){//TODO: passer les valeurs en config + if((temp > mintemp && temp < maxtemp) && (hum > minhum && hum < maxhum)){ this->full = true; }else{ this->full = false; diff --git a/IOT/lib/Capteur/src/Ultrason.cpp b/IOT/lib/Capteur/src/Ultrason.cpp index 3154f0e..12137cb 100644 --- a/IOT/lib/Capteur/src/Ultrason.cpp +++ b/IOT/lib/Capteur/src/Ultrason.cpp @@ -9,11 +9,11 @@ Ultrason::Ultrason(int trigeur, int echo, String fullVall): String Ultrason::read(){ int sortie = this->capteur->read(); - if (sortie < this->fullVall.toInt()) + if (sortie < this->fullVall.substring(0, this->fullVall.indexOf("/")).toInt()) { this->full = true; - }else{ + }else if (sortie > this->fullVall.substring(this->fullVall.indexOf("/")+1, this->fullVall.length()).toInt()){ this->full = false; } return String(sortie); -}//TODO: faire en sorte que full se reset avec une autre val \ No newline at end of file +} \ No newline at end of file diff --git a/IOT/src/Program.cpp b/IOT/src/Program.cpp index 33f31af..e20c7c9 100644 --- a/IOT/src/Program.cpp +++ b/IOT/src/Program.cpp @@ -45,5 +45,4 @@ void Program::loop(){ Serial.println(); - delay(1000); } \ No newline at end of file From 0037b1831a083406efb6f73ae2d7cedcd1312196 Mon Sep 17 00:00:00 2001 From: Clement Date: Sun, 14 May 2023 23:17:05 +0200 Subject: [PATCH 5/6] rm debug --- IOT/lib/API/src/API.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/IOT/lib/API/src/API.cpp b/IOT/lib/API/src/API.cpp index f6e5161..ba2f917 100644 --- a/IOT/lib/API/src/API.cpp +++ b/IOT/lib/API/src/API.cpp @@ -18,7 +18,6 @@ bool API::wifiBegin(String wifiId, String wifiPass, Stream* 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; } From 23651cb6d5e920d067fa57a96b0abdbba757e715 Mon Sep 17 00:00:00 2001 From: Clement Date: Sun, 14 May 2023 23:26:16 +0200 Subject: [PATCH 6/6] fix diagramme --- IOT/docs/diagram/class.puml | 14 +++++++++++++- IOT/lib/OledScreen/include/OledScreen.h | 7 ------- IOT/lib/OledScreen/src/OledScreeen.cpp | 20 -------------------- 3 files changed, 13 insertions(+), 28 deletions(-) diff --git a/IOT/docs/diagram/class.puml b/IOT/docs/diagram/class.puml index 36bc169..4b7cdb5 100644 --- a/IOT/docs/diagram/class.puml +++ b/IOT/docs/diagram/class.puml @@ -41,7 +41,7 @@ class Balance{ + tar(val: int = 0): bool } -class Ultrason{ +class HumiTemp{ - capteur: DHT* + HumiTemp(pin: int, type: String, fullVal: String) + read(): String @@ -53,6 +53,15 @@ class Ultrason{ + read(): String } +class OledScreen{ + - display: Adafruit_SSD1306* + + OledScreen(screenWidth: int, screenHeight: int, oledResetPin: int = -1) + + welcome(): void + + clear(): void + + wifiWaiting(): void + + printVal(distance: String, poid: String, humitemp: String): void +} + Balance --|> Capteur Ultrason --|> Capteur HumiTemp --|> Capteur @@ -62,5 +71,8 @@ Program <-- Balance Program <-- Ultrason Program <-- HumiTemp +Program <- API + +OledScreen -> Program @enduml \ No newline at end of file diff --git a/IOT/lib/OledScreen/include/OledScreen.h b/IOT/lib/OledScreen/include/OledScreen.h index d2a7f6e..11a553d 100644 --- a/IOT/lib/OledScreen/include/OledScreen.h +++ b/IOT/lib/OledScreen/include/OledScreen.h @@ -21,13 +21,6 @@ public: */ void welcome(); - /** - * @brief print the total amount on the screen - * - * @param amount The total amount to print in centimes - */ - void printAmount(int amount); - /** * @brief Clear the screen diff --git a/IOT/lib/OledScreen/src/OledScreeen.cpp b/IOT/lib/OledScreen/src/OledScreeen.cpp index c88b6b2..dfa7c29 100644 --- a/IOT/lib/OledScreen/src/OledScreeen.cpp +++ b/IOT/lib/OledScreen/src/OledScreeen.cpp @@ -40,26 +40,6 @@ void OledScreen::printVal(String distance, String poid, String humitemp){ -void OledScreen::printAmount(int amount) { - this->display->clearDisplay(); - this->display->setCursor(0, 0); - this->display->setTextSize(2); - this->display->setTextColor(WHITE); - this->display->println(F(" Total: ")); - this->display->println(); - - this->display->print(amount / 100); - this->display->print(F(",")); - int centimes = amount % 100; - if (centimes < 10) { - this->display->print(F("0")); - } - this->display->println(centimes); - this->display->print(F(" EUR")); - this->display->display(); -} - - void OledScreen::wifiWaiting() { this->clear(); this->display->setCursor(0, 0);