diff --git a/CMakeLists.txt b/CMakeLists.txt index 6044ebd..ad77619 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ set(CMAKE_CXX_STANDARD 17) find_package(PkgConfig REQUIRED) pkg_check_modules(TCPSocket REQUIRED TCPSocket) -find_package(WiringPi REQUIRED) +find_package(wiringpi REQUIRED) add_executable(tirette main.cpp MyClient.cpp @@ -14,4 +14,4 @@ add_executable(tirette main.cpp target_link_libraries(tirette TCPSocket) -target_link_libraries(tirette WiringPi) \ No newline at end of file +target_link_libraries(tirette wiringpi) \ No newline at end of file diff --git a/main.cpp b/main.cpp index 1540c4b..0d1c1d4 100644 --- a/main.cpp +++ b/main.cpp @@ -17,26 +17,22 @@ int main() { pinMode(TIRETTE_GPIO, INPUT); pullUpDnControl(TIRETTE_GPIO, PUD_UP); - // bool* tiretteState = new bool(true); + bool* tiretteState = new bool(true); - // MyClient client(tiretteState, "127.0.0.1", 8080); + MyClient client(tiretteState, "127.0.0.1", 8080); - // client.start(); + client.start(); // Boucle principale while (true) { - // Lecture de l'état du GPIO de la tirette int etat = digitalRead(TIRETTE_GPIO); - // Si les aimants ne sont plus en contact, afficher un message if (etat == LOW) { - // tiretteState = new bool(false); - std::cout << "Les aimants ne sont plus en contact." << std::endl; - // client.sendMessage("tirette;start;set tirette_state;1"); - // Vous pouvez exécuter d'autres actions ici + std::cout << "Les aimants sont en contact." << std::endl; + client.sendMessage("tirette;start;set tirette_state;1"); } else { - std::cout << "Les aimants sont en contact." << std::endl; + std::cout << "Les aimants ne sont pas en contact." << std::endl; } // Attendre un court délai avant de vérifier à nouveau