From 1c6c374537de6ac797db9b776282fe1f8958cf15 Mon Sep 17 00:00:00 2001 From: Daniela Date: Tue, 16 Apr 2019 15:51:46 +0200 Subject: [PATCH] Some adjustments in the Assigner module --- project/Assigner/assigner.c | 4 +--- project/Assigner/assigner_fun.c | 10 ++++++---- project/Assigner/assigner_fun.h | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/project/Assigner/assigner.c b/project/Assigner/assigner.c index 7ba663677..e4e024175 100644 --- a/project/Assigner/assigner.c +++ b/project/Assigner/assigner.c @@ -14,8 +14,6 @@ #include "../common/supermarket_net.h" #include "assigner_fun.h" -#define LOG_MODULE "Assigner" -#define LOG_LEVEL LOG_LEVEL_INFO #define OPENING_PERIOD (300*CLOCK_SECOND) @@ -45,7 +43,7 @@ static void msg_recv(const void* data, uint16_t len, const linkaddr_t* source_ad handle_battery_msg(src,data); break; default: - printf("Invalide type! This message is not for the Assigner"); + printf("Invalide type! This message is not for the Assigner\n"); break; } diff --git a/project/Assigner/assigner_fun.c b/project/Assigner/assigner_fun.c index d011d82a0..bb48cc57a 100644 --- a/project/Assigner/assigner_fun.c +++ b/project/Assigner/assigner_fun.c @@ -9,9 +9,6 @@ #include "../common/supermarket_net.h" #include "assigner_fun.h" -#define LOG_MODULE "App" -#define LOG_LEVEL LOG_LEVEL_INFO - //function invoked in order to look for the most charged cart to assign to the new arrived client cart* cart_selection() @@ -40,6 +37,11 @@ bool insert_cart(uint8_t new_req_battery, linkaddr_t mac_cart_addr) printf("Association Failed"); return false; } + cart* c = cart_list; + while(linkaddr_cmp(&(c->cart_address),&mac_cart_addr) == 0) + c = c->next; + if(c) + printf("Cart already associated!"\n); else { new_arrived_cart->cart_address = mac_cart_addr; @@ -47,7 +49,7 @@ bool insert_cart(uint8_t new_req_battery, linkaddr_t mac_cart_addr) new_arrived_cart->assigned = false; new_arrived_cart->next = cart_list; cart_list = new_arrived_cart; - LOG_INFO("Nuovo carrello inserito con mac_address: "); + LOG_INFO("New cart added with mac_address: "); LOG_INFO_LLADDR(&(new_arrived_cart->cart_address)); printf("\n"); } diff --git a/project/Assigner/assigner_fun.h b/project/Assigner/assigner_fun.h index 4fd5f300f..aa626457a 100644 --- a/project/Assigner/assigner_fun.h +++ b/project/Assigner/assigner_fun.h @@ -6,6 +6,8 @@ #include #include "sys/log.h" +#define LOG_MODULE "Assigner" +#define LOG_LEVEL LOG_LEVEL_INFO typedef struct cart {