5 uint32_t Communication::groupNumber = 0;
8 void (*Communication::userCallback)(String &msg) =
nullptr;
12 String data = String(groupNumber) +
"#" + msg;
13 mesh.sendBroadcast(data);
17 void Communication::receivedCallback(uint32_t from, String &msg)
19 int separatorIndex = msg.indexOf(
'#');
20 if (separatorIndex != -1) {
21 String groupNumberStr = msg.substring(0, separatorIndex);
22 uint32_t num = groupNumberStr.toInt();
23 String restOfMsg = msg.substring(separatorIndex + 1);
25 Serial.printf(
"startHere: Received from %u groupNumber=%u msg=%s\n", from, num, restOfMsg.c_str());
27 if (groupNumber != num)
return;
31 userCallback(restOfMsg);
38 Serial.printf(
"--> startHere: New Connection, nodeId = %u\n", nodeId);
43 Serial.printf(
"Changed connections\n");
48 Serial.printf(
"Adjusted time %u. Offset = %d\n",
mesh.getNodeTime(), offset);
66 userCallback = callbackFunc;
74 mesh.setDebugMsgTypes(ERROR | STARTUP);
77 mesh.onReceive(&receivedCallback);
82 static uint8_t ucParameterToPass;
83 TaskHandle_t xHandle = NULL;
85 xTaskCreate(
vTaskUpdate,
"vTaskMeshUpdate", 4096, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle);
86 configASSERT(xHandle);