[Assigner] Problem in association_req of cart already associated solved

This commit is contained in:
Daniela 2019-04-18 23:16:08 +02:00
parent 957c93d472
commit 1f27de6ca6

View File

@ -38,10 +38,13 @@ bool insert_cart(uint8_t new_req_battery, linkaddr_t mac_cart_addr)
return false; return false;
} }
cart* c = cart_list; 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; c = c->next;
else
break;
} }
if(c) if(c)
printf("Cart already associated!\n"); printf("Cart already associated!\n");