mirror of
https://gitlab.dit.htwk-leipzig.de/phillip.kuehne/dezibot.git
synced 2025-05-21 20:11:46 +02:00
rename mesh to communication
This commit is contained in:
parent
5676ce46fd
commit
8b3a724854
@ -17,7 +17,7 @@
|
|||||||
#include "multiColorLight/MultiColorLight.h"
|
#include "multiColorLight/MultiColorLight.h"
|
||||||
#include "motionDetection/MotionDetection.h"
|
#include "motionDetection/MotionDetection.h"
|
||||||
#include "infraredLight/InfraredLight.h"
|
#include "infraredLight/InfraredLight.h"
|
||||||
#include "mesh/Mesh.h"
|
#include "communication/Communication.h"
|
||||||
|
|
||||||
|
|
||||||
class Dezibot {
|
class Dezibot {
|
||||||
@ -30,7 +30,7 @@ public:
|
|||||||
MultiColorLight multiColorLight;
|
MultiColorLight multiColorLight;
|
||||||
MotionDetection motionDetection;
|
MotionDetection motionDetection;
|
||||||
InfraredLight infraredLight;
|
InfraredLight infraredLight;
|
||||||
Mesh mesh;
|
Communication communication;
|
||||||
void begin(void);
|
void begin(void);
|
||||||
/*
|
/*
|
||||||
Display display
|
Display display
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
#include "Mesh.h"
|
#include "Communication.h"
|
||||||
|
|
||||||
Scheduler userScheduler; // to control your personal task
|
Scheduler userScheduler; // to control your personal task
|
||||||
painlessMesh mesh;
|
painlessMesh mesh;
|
||||||
uint32_t Mesh::groupNumber = 0;
|
uint32_t Communication::groupNumber = 0;
|
||||||
|
|
||||||
// User-defined callback function pointer
|
// 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;
|
String data = String(groupNumber) + "#" + msg;
|
||||||
mesh.sendBroadcast(data);
|
mesh.sendBroadcast(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed for painless library
|
// Needed for painless library
|
||||||
void Mesh::receivedCallback(uint32_t from, String &msg)
|
void Communication::receivedCallback(uint32_t from, String &msg)
|
||||||
{
|
{
|
||||||
int separatorIndex = msg.indexOf('#');
|
int separatorIndex = msg.indexOf('#');
|
||||||
if (separatorIndex != -1) {
|
if (separatorIndex != -1) {
|
||||||
@ -28,7 +28,7 @@ void Mesh::receivedCallback(uint32_t from, String &msg)
|
|||||||
|
|
||||||
// Execute user-defined callback if it is set
|
// Execute user-defined callback if it is set
|
||||||
if (userCallback) {
|
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;
|
groupNumber = number;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method to set the user-defined callback function
|
// 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;
|
userCallback = callbackFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mesh::begin(void)
|
void Communication::begin(void)
|
||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
#ifndef Mesh_h
|
#ifndef Communication_h
|
||||||
#define Mesh_h
|
#define Communication_h
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <painlessMesh.h>
|
#include <painlessMesh.h>
|
||||||
@ -10,7 +10,7 @@
|
|||||||
#define MESH_PORT 5555
|
#define MESH_PORT 5555
|
||||||
|
|
||||||
|
|
||||||
class Mesh{
|
class Communication{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief initialize the Mesh Compnent, must be called before the other methods are used.
|
* @brief initialize the Mesh Compnent, must be called before the other methods are used.
|
||||||
@ -22,11 +22,11 @@ public:
|
|||||||
|
|
||||||
void sendMessage(String msg);
|
void sendMessage(String msg);
|
||||||
|
|
||||||
void onReceive(void (*callbackFunc)(uint32_t from, String &msg));
|
void onReceive(void (*callbackFunc)(String &msg));
|
||||||
private:
|
private:
|
||||||
static void (*userCallback)(uint32_t from, String &msg);
|
static void (*userCallback)(String &msg);
|
||||||
static void receivedCallback(uint32_t from, String &msg);
|
static void receivedCallback(uint32_t from, String &msg);
|
||||||
static uint32_t groupNumber;
|
static uint32_t groupNumber;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif //Mesh_h
|
#endif //Communication_h
|
Loading…
x
Reference in New Issue
Block a user