MCPcopy Create free account
hub / github.com/Blueforcer/awtrix3 / tick

Method tick

src/ServerManager.cpp:280–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280void ServerManager_::tick()
281{
282 mws.run();
283
284 if (!AP_MODE)
285 {
286 int packetSize = udp.parsePacket();
287 if (packetSize)
288 {
289 int len = udp.read(incomingPacket, 255);
290 if (len > 0)
291 {
292 incomingPacket[len] = 0;
293 }
294 if (strcmp(incomingPacket, "FIND_AWTRIX") == 0)
295 {
296 udp.beginPacket(udp.remoteIP(), 4211);
297 if (WEB_PORT != 80)
298 {
299 char buffer[128];
300 sprintf(buffer, "%s:%d", HOSTNAME.c_str(), WEB_PORT);
301 udp.printf(buffer);
302 }
303 else
304 {
305 udp.printf(HOSTNAME.c_str());
306 }
307
308 udp.endPacket();
309 }
310 }
311 }
312
313 if (!currentClient || !currentClient.connected()) {
314 if (TCPserver.hasClient()) {
315 if (currentClient) {
316 currentClient.stop();
317 Serial.println("Vorheriger Client getrennt, um neuen Client zu akzeptieren.");
318 }
319 currentClient = TCPserver.available();
320 Serial.println("Neuer Client verbunden.");
321 }
322 }
323
324 if (currentClient && currentClient.connected()) {
325 while (currentClient.available()) {
326 char incomingByte = currentClient.read();
327 if (incomingByte == '\n') {
328 dataBuffer[bufferIndex] = '\0';
329 GameManager.ControllerInput(dataBuffer);
330 bufferIndex = 0;
331 }
332 else if (incomingByte != '\r') {
333 if (bufferIndex < BUFFER_SIZE - 1) {
334 dataBuffer[bufferIndex++] = incomingByte;
335 }
336 else {
337 bufferIndex = 0;

Callers

nothing calls this directly

Calls 5

runMethod · 0.80
readMethod · 0.80
connectedMethod · 0.80
stopMethod · 0.45
ControllerInputMethod · 0.45

Tested by

no test coverage detected