From c4441d5df3bdbb90d4ab41d6071dc35e6d0230ad Mon Sep 17 00:00:00 2001
From: Torben Petersen <petersen@ibr.cs.tu-bs.de>
Date: Fri, 23 Jul 2021 13:49:44 +0200
Subject: [PATCH] cleanup of code

---
 software/main.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/software/main.c b/software/main.c
index 8355268..f299d8b 100644
--- a/software/main.c
+++ b/software/main.c
@@ -316,10 +316,12 @@ void *dump_thread(void *arg)
     msg_t msg;
     gnrc_pktsnip_t *snip = NULL;
     gnrc_pktsnip_t *payload = NULL;
+
     uint8_t *data;
     eval_message_t *packet;
     gnrc_netif_hdr_t *hdr;
     uint8_t len;
+
     memset(serialbuffer, sizeof(serialbuffer), 0x00);
 
     while(1) {
@@ -327,7 +329,7 @@ void *dump_thread(void *arg)
             puts("Unable to receive message");
             continue;
         }
-        //printf("[dump_thread] message received: %d\n", msg.type);
+
         switch(msg.type) {
             case GNRC_NETAPI_MSG_TYPE_RCV :
                 //irq_disable();
@@ -341,7 +343,7 @@ void *dump_thread(void *arg)
                     switch(snip->type)  {
                         case GNRC_NETTYPE_UNDEF :
                             payload = snip;
-                        break;
+                            break;
                         case GNRC_NETTYPE_NETIF :
                             hdr = snip->data;
                             //printf("HDR: %d %d %d\n", hdr->rssi, hdr->lqi, hdr->crc_valid);
@@ -366,7 +368,7 @@ void *dump_thread(void *arg)
                                         printf("<magic:length_error:%d\n", length);
                                     }
                                 } else {
-                                    printf("<valid\n");
+                                    puts("<valid");
                                     /// This is another packet, ignore it!
                                 }
                             } else {
@@ -404,17 +406,17 @@ void *dump_thread(void *arg)
                                     puts("!length error 1");
                                 }
                             }
-                        break;
+                            break;
                         default :
                             printf("snip of type %d\n", snip->type);
-                        break;
+                            break;
                     }
                     snip = snip->next;
                 }
                 gnrc_pktbuf_release(msg.content.ptr);
 
                 //irq_enable();
-            break;
+                break;
             default :
                 puts("ERROR: Unknown message type???");
                 //gnrc_pktbuf_release( msg.content.ptr );
@@ -457,6 +459,7 @@ void *send_thread(void *arg)
     netopt_enable_t enable = true;
     netopt_enable_t disable = false;
     int ret;
+
     ret = gnrc_netapi_set(ieee802154_netif->pid, NETOPT_PROMISCUOUSMODE, 0, &enable, sizeof(netopt_enable_t));
     if(ret < 0) {
         puts("Unable to set promiscous mode");
@@ -492,8 +495,10 @@ void *send_thread(void *arg)
     memset(serialbuffer, sizeof(serialbuffer2), 0x00);
     
     while(1) {
-        msg_receive(&msg);
-        (void)msg;
+        if(msg_receive(&msg) != 1) {
+            puts("[send thread] Unable to receive message");
+            continue;
+        }
 
         /*
         //printf("[dump_thread] message received: %d\n", msg.type);
@@ -744,7 +749,6 @@ int main(void)
     
     gnrc_netif_t *netif = NULL;
     if((netif = gnrc_netif_iter(netif))) {
-        
         #if defined(BOARD_IBR_NODE)
         netif = gnrc_netif_iter(netif);
         #endif
-- 
GitLab