MCPcopy Create free account
hub / github.com/OpenEPaperLink/OpenEPaperLink / rxCmdProcessor

Function rxCmdProcessor

ESP32_AP-Flasher/src/serialap.cpp:407–456  ·  view source on GitHub ↗

Asynchronous command processor

Source from the content-addressed store, hash-verified

405
406// Asynchronous command processor
407void rxCmdProcessor(void* parameter) {
408 rxCmdQueue = xQueueCreate(30, sizeof(struct rxCmd*));
409 txActive = xSemaphoreCreateBinary();
410 xSemaphoreGive(txActive);
411 while (1) {
412 if (apInfo.isOnline) {
413 struct rxCmd* rxcmd = nullptr;
414 BaseType_t q = xQueueReceive(rxCmdQueue, &rxcmd, 10);
415 if (q == pdTRUE) {
416 switch (rxcmd->type) {
417 case RX_CMD_RQB:
418 processBlockRequest((struct espBlockRequest*)rxcmd->data);
419#ifdef HAS_RGB_LED
420 // shortBlink(CRGB::Blue);
421#endif
422 quickBlink(3);
423 break;
424 case RX_CMD_ADR:
425 processDataReq((struct espAvailDataReq*)rxcmd->data, true);
426#ifdef HAS_RGB_LED
427 // shortBlink(CRGB::Aqua);
428#endif
429 quickBlink(1);
430 break;
431 case RX_CMD_XFC:
432 processXferComplete((struct espXferComplete*)rxcmd->data, true);
433#ifdef HAS_RGB_LED
434 // shortBlink(CRGB::Purple);
435#endif
436 break;
437 case RX_CMD_XTO:
438 processXferTimeout((struct espXferComplete*)rxcmd->data, true);
439 break;
440 case RX_CMD_RSET:
441 Serial.println("AP did reset, resending pending\r\n");
442 refreshAllPending();
443 sendChannelPower(&curChannel);
444 break;
445 case RX_CMD_TRD:
446 // received tag return data
447 processTagReturnData((struct espTagReturnData*)rxcmd->data, rxcmd->len, true);
448 break;
449 }
450 if (rxcmd->data) free(rxcmd->data);
451 if (rxcmd) free(rxcmd);
452 }
453 }
454 vTaskDelay(1 / portTICK_PERIOD_MS);
455 }
456}
457void rxSerialTask(void* parameter) {
458 static char cmdbuffer[4] = {0};
459 static uint8_t* packetp = nullptr;

Callers

nothing calls this directly

Calls 9

processDataReqFunction · 0.85
processXferTimeoutFunction · 0.85
refreshAllPendingFunction · 0.85
sendChannelPowerFunction · 0.85
printlnMethod · 0.80
processBlockRequestFunction · 0.70
quickBlinkFunction · 0.70
processXferCompleteFunction · 0.70
processTagReturnDataFunction · 0.70

Tested by

no test coverage detected