Process ACK
This commit is contained in:
parent
59cce635c7
commit
e805ea1aef
2 changed files with 13 additions and 9 deletions
|
@ -805,16 +805,14 @@ void handle_ack(const unsigned char source_mac[6], const unsigned char *data, si
|
|||
return;
|
||||
}
|
||||
|
||||
char mac[18];
|
||||
format_mac(source_mac, mac);
|
||||
// Type of event: ACK received
|
||||
writeallx(1, "a", 1);
|
||||
|
||||
if (printf("%s ack %" PRIu16 "\n", mac, msgid) == -1) {
|
||||
err(1, "printf");
|
||||
}
|
||||
// MAC
|
||||
writeallx(1, source_mac, 6);
|
||||
|
||||
if (fflush(stdout) == EOF) {
|
||||
err(1, "fflush");
|
||||
}
|
||||
// Msgid
|
||||
writeallx_u16(1, msgid);
|
||||
|
||||
if (own_message_send_state == WAITING_ACK && msgid == own_message_msgid) {
|
||||
own_message_send_state = IDLE;
|
||||
|
|
|
@ -92,7 +92,7 @@ def eventloop(proc):
|
|||
|
||||
elif event_type == b'i':
|
||||
# Msgid for message
|
||||
msgid = readall_u16(proc.stdout);
|
||||
msgid = readall_u16(proc.stdout)
|
||||
print('(msgid: %i)' % msgid) #debg
|
||||
|
||||
elif event_type == b'm':
|
||||
|
@ -103,6 +103,12 @@ def eventloop(proc):
|
|||
|
||||
print('<%s> %s' % (format_mac(source_mac), message.decode('utf-8')))
|
||||
|
||||
elif event_type == b'a':
|
||||
# ACK received
|
||||
source_mac = readall(proc.stdout, 6)
|
||||
msgid = readall_u16(proc.stdout)
|
||||
print('(ack: %i)' % msgid) #debg
|
||||
|
||||
else:
|
||||
# Not sth we handle yet
|
||||
data = proc.stdout.read(1023)
|
||||
|
|
Loading…
Reference in a new issue