From e805ea1aefc297eefb3aa2d4d737df82e1e05998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Sun, 14 Jul 2019 20:39:45 +0300 Subject: [PATCH] Process ACK --- ethermess-backend.c | 14 ++++++-------- ethermess.py | 8 +++++++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ethermess-backend.c b/ethermess-backend.c index 829fd9f..02adba4 100644 --- a/ethermess-backend.c +++ b/ethermess-backend.c @@ -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; diff --git a/ethermess.py b/ethermess.py index b3615d2..de60607 100644 --- a/ethermess.py +++ b/ethermess.py @@ -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)