Skip to content

Commit 8a3c9f0

Browse files
jwhithamdpgeorge
authored andcommitted
extmod/modlwip: Call user callback on newly-received UDP or RAW packet.
User callbacks allow code to respond to incoming messages without blocking or polling. User callbacks are optional, and if no callback is registered the code has no effect. The mechanism is the same as for TCP: when a connection is accepted or a TCP packet is received, a user callback is executed. Fixes issue micropython#3594. Signed-off-by: Jack Whitham <jack.d.whitham@gmail.com>
1 parent 406356e commit 8a3c9f0

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

extmod/modlwip.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,8 @@ static void udp_raw_incoming(lwip_socket_obj_t *socket, struct pbuf *p, const ip
463463
slot->peer_addr = *addr;
464464
slot->peer_port = port;
465465
socket->incoming.udp_raw.iput = (socket->incoming.udp_raw.iput + 1) % LWIP_INCOMING_PACKET_QUEUE_LEN;
466+
// Notify user callback of the new packet
467+
exec_user_callback(socket);
466468
}
467469
}
468470

0 commit comments

Comments
 (0)