| 94 | } |
| 95 | |
| 96 | void UdpConnection::onReceive(pbuf* buf, IpAddress remoteIP, uint16_t remotePort) |
| 97 | { |
| 98 | debug_d("UDP received: %d bytes", buf->tot_len); |
| 99 | if(onDataCallback) { |
| 100 | auto data = new char[buf->tot_len + 1]; |
| 101 | pbuf_copy_partial(buf, data, buf->tot_len, 0); |
| 102 | data[buf->tot_len] = '\0'; |
| 103 | |
| 104 | onDataCallback(*this, data, buf->tot_len, remoteIP, remotePort); |
| 105 | |
| 106 | delete[] data; |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | void UdpConnection::staticOnReceive(void* arg, struct udp_pcb*, struct pbuf* p, LWIP_IP_ADDR_T* addr, u16_t port) |
| 111 | { |
no test coverage detected