mirror of
				https://gitlab.dit.htwk-leipzig.de/phillip.kuehne/dezibot.git
				synced 2025-10-31 07:10:00 +01:00 
			
		
		
		
	rename mesh to communication
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
| @@ -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); | ||||
| 
 | ||||
| @@ -1,6 +1,6 @@ | ||||
| 
 | ||||
| #ifndef Mesh_h | ||||
| #define Mesh_h | ||||
| #ifndef Communication_h | ||||
| #define Communication_h | ||||
| #include <stdint.h> | ||||
| #include <Arduino.h> | ||||
| #include <painlessMesh.h> | ||||
| @@ -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
 | ||||
| #endif //Communication_h
 | ||||
		Reference in New Issue
	
	Block a user