From 1f27de6ca65fdaefc159f9519c1a8f3f75ef89d6 Mon Sep 17 00:00:00 2001 From: Daniela Date: Thu, 18 Apr 2019 23:16:08 +0200 Subject: [PATCH] [Assigner] Problem in association_req of cart already associated solved --- project/Assigner/assigner_fun.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/project/Assigner/assigner_fun.c b/project/Assigner/assigner_fun.c index a4133c6cc..71ba7ed30 100644 --- a/project/Assigner/assigner_fun.c +++ b/project/Assigner/assigner_fun.c @@ -38,10 +38,13 @@ bool insert_cart(uint8_t new_req_battery, linkaddr_t mac_cart_addr) return false; } cart* c = cart_list; - while(c) + //If a cart is reset this will send a new association request even if it was previously associated so I need to check my cart_list and find out if its mac_address is already there, in order to avoid to insert the same cart twice + while(c) { - if(linkaddr_cmp(&(c->cart_address),&mac_cart_addr) == 0) + if(linkaddr_cmp(&(c->cart_address),&mac_cart_addr) == 0) //Returns 0 if the addresses are different c = c->next; + else + break; } if(c) printf("Cart already associated!\n");