feat: Test_IOT #40

Merged
Clement merged 7 commits from feat/Test_IOT into master 2023-04-25 08:54:14 +00:00
4 changed files with 16 additions and 4 deletions
Showing only changes of commit b3da67f31e - Show all commits

View File

@ -21,3 +21,5 @@ build_flags =
-D EXAMPLE_NUMBER=69
-D TRASHCAN_ONE=\"gdnuxl0wlgurtj3\"

View File

@ -3,6 +3,7 @@
#include <Arduino.h>
#include <Ultrasonic.h>
#include "API.h"
class Program{
public:
@ -26,5 +27,11 @@ private:
*
*/
Ultrasonic *ultrasonic;
/**
* @brief Réference de l'API pour les calls
*
*/
API *api;
};
#endif

View File

@ -1,10 +1,13 @@
#include "Program.h"
int distance;
Program::Program(){
this->api = new API(USER_NAME, USER_PASSWORD, API_HOST);
Serial1.begin(MONITOR_SPEED);
this->api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1);
Serial.begin(MONITOR_SPEED);
this->ultrasonic = new Ultrasonic(ULTRA_SOUND_TRIGD, ULTRA_SOUND_ECHO);
}
@ -12,7 +15,8 @@ Program::Program(){
void Program::loop(){
distance = this->ultrasonic->read();
this->api->sendValue(JSONVar::stringify(distance), TRASHCAN_ONE, "W", false);
Serial.print("Distance in CM: ");
Serial.println(distance);
delay(1000);
delay(10000);
}

View File

@ -46,4 +46,3 @@ void TestSendValue() {
api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1);
TEST_ASSERT_EQUAL_MESSAGE(true, api->sendValue("30", "gdnuxl0wlgurtj3", "W", true), "Not Connected to server");
}