diff --git a/src/Dezibot.h b/src/Dezibot.h index 63e26df..2e6fb1e 100644 --- a/src/Dezibot.h +++ b/src/Dezibot.h @@ -17,7 +17,7 @@ #include "multiColorLight/MultiColorLight.h" #include "motionDetection/MotionDetection.h" #include "infraredLight/InfraredLight.h" -#include "mesh/Mesh.h" +#include "communication/Communication.h" class Dezibot { @@ -30,7 +30,7 @@ public: MultiColorLight multiColorLight; MotionDetection motionDetection; InfraredLight infraredLight; - Mesh mesh; + Communication communication; void begin(void); /* Display display diff --git a/src/mesh/Mesh.cpp b/src/communication/Communication.cpp similarity index 82% rename from src/mesh/Mesh.cpp rename to src/communication/Communication.cpp index f5121e4..6e443f9 100644 --- a/src/mesh/Mesh.cpp +++ b/src/communication/Communication.cpp @@ -1,20 +1,20 @@ -#include "Mesh.h" +#include "Communication.h" Scheduler userScheduler; // to control your personal task painlessMesh mesh; -uint32_t Mesh::groupNumber = 0; +uint32_t Communication::groupNumber = 0; // User-defined callback function pointer -void (*Mesh::userCallback)(uint32_t from, String &msg) = nullptr; +void (*Communication::userCallback)(String &msg) = nullptr; -void Mesh::sendMessage(String msg) +void Communication::sendMessage(String msg) { String data = String(groupNumber) + "#" + msg; mesh.sendBroadcast(data); } // Needed for painless library -void Mesh::receivedCallback(uint32_t from, String &msg) +void Communication::receivedCallback(uint32_t from, String &msg) { int separatorIndex = msg.indexOf('#'); if (separatorIndex != -1) { @@ -28,7 +28,7 @@ void Mesh::receivedCallback(uint32_t from, String &msg) // Execute user-defined callback if it is set if (userCallback) { - userCallback(from, restOfMsg); + userCallback(restOfMsg); } } } @@ -56,17 +56,17 @@ void vTaskUpdate(void *pvParameters) } } -void Mesh::setGroupNumber(uint32_t number) { +void Communication::setGroupNumber(uint32_t number) { groupNumber = number; } // Method to set the user-defined callback function -void Mesh::onReceive(void (*callbackFunc)(uint32_t from, String &msg)) +void Communication::onReceive(void (*callbackFunc)(String &msg)) { userCallback = callbackFunc; } -void Mesh::begin(void) +void Communication::begin(void) { Serial.begin(115200); diff --git a/src/mesh/Mesh.h b/src/communication/Communication.h similarity index 73% rename from src/mesh/Mesh.h rename to src/communication/Communication.h index d00147d..e6644f7 100644 --- a/src/mesh/Mesh.h +++ b/src/communication/Communication.h @@ -1,6 +1,6 @@ -#ifndef Mesh_h -#define Mesh_h +#ifndef Communication_h +#define Communication_h #include #include #include @@ -10,7 +10,7 @@ #define MESH_PORT 5555 -class Mesh{ +class Communication{ public: /** * @brief initialize the Mesh Compnent, must be called before the other methods are used. @@ -22,11 +22,11 @@ public: void sendMessage(String msg); - void onReceive(void (*callbackFunc)(uint32_t from, String &msg)); + void onReceive(void (*callbackFunc)(String &msg)); private: - static void (*userCallback)(uint32_t from, String &msg); + static void (*userCallback)(String &msg); static void receivedCallback(uint32_t from, String &msg); static uint32_t groupNumber; }; -#endif //Mesh_h \ No newline at end of file +#endif //Communication_h \ No newline at end of file