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

Method processPacket

ESP32_AP-Flasher/src/udp.cpp:55–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55void UDPcomm::processPacket(AsyncUDPPacket packet) {
56 if (config.runStatus == RUNSTATUS_STOP) {
57 return;
58 }
59 IPAddress senderIP = packet.remoteIP();
60
61 switch (packet.data()[0]) {
62 case PKT_AVAIL_DATA_INFO: {
63 espAvailDataReq adr;
64 memset(&adr, 0, sizeof(espAvailDataReq));
65 memcpy(&adr, &packet.data()[1], std::min(packet.length() - 1, sizeof(espAvailDataReq)));
66 processDataReq(&adr, false, senderIP);
67 break;
68 }
69 case PKT_XFER_COMPLETE: {
70 espXferComplete xfc;
71 memset(&xfc, 0, sizeof(espXferComplete));
72 memcpy(&xfc, &packet.data()[1], std::min(packet.length() - 1, sizeof(espXferComplete)));
73 processXferComplete(&xfc, false);
74 break;
75 }
76 case PKT_XFER_TIMEOUT: {
77 espXferComplete xfc;
78 memset(&xfc, 0, sizeof(espXferComplete));
79 memcpy(&xfc, &packet.data()[1], std::min(packet.length() - 1, sizeof(espXferComplete)));
80 processXferTimeout(&xfc, false);
81 break;
82 }
83 case PKT_AVAIL_DATA_REQ: {
84 pendingData pending;
85 memset(&pending, 0, sizeof(pendingData));
86 memcpy(&pending, &packet.data()[1], std::min(packet.length() - 1, sizeof(pendingData)));
87 prepareExternalDataAvail(&pending, senderIP);
88 break;
89 }
90 case PKT_APLIST_REQ: {
91 APlist APitem;
92 APitem.src = wm.localIP();
93 strcpy(APitem.alias, config.alias);
94 APitem.channelId = curChannel.channel;
95 APitem.tagCount = getTagCount();
96 APitem.version = apInfo.version;
97
98 uint8_t buffer[sizeof(struct APlist) + 1];
99 buffer[0] = PKT_APLIST_REPLY;
100 memcpy(buffer + 1, &APitem, sizeof(struct APlist));
101 writeUdpPacket(buffer, sizeof(buffer), senderIP);
102 break;
103 }
104 case PKT_APLIST_REPLY: {
105 APlist APreply;
106 memset(&APreply, 0, sizeof(APlist));
107 memcpy(&APreply, &packet.data()[1], std::min(packet.length() - 1, sizeof(APlist)));
108 // remove active channel from list
109 for (int i = 0; i < 6; i++) {
110 if (channelList[i] == APreply.channelId) channelList[i] = 0;
111 }
112 wsSendAPitem(&APreply);

Callers 1

initMethod · 0.95

Calls 13

memsetFunction · 0.85
memcpyFunction · 0.85
processDataReqFunction · 0.85
processXferTimeoutFunction · 0.85
prepareExternalDataAvailFunction · 0.85
strcpyFunction · 0.85
getTagCountFunction · 0.85
wsSendAPitemFunction · 0.85
wsErrFunction · 0.85
updateTaginfoitemFunction · 0.85
localIPMethod · 0.80
processXferCompleteFunction · 0.70

Tested by

no test coverage detected