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 { diff --git a/project/common/product.h b/project/common/product.h index 4d75e9494..0231d6b53 100644 --- a/project/common/product.h +++ b/project/common/product.h @@ -4,6 +4,6 @@ typedef struct product_t { uint32_t product_id; char expiration_date[8]; // gg/mm/yy - float price; + uint32_t price; } product_t; #endif diff --git a/project/product/product.c b/project/product/product.c index 20b48dec7..4d7e51dea 100644 --- a/project/product/product.c +++ b/project/product/product.c @@ -21,9 +21,9 @@ static linkaddr_t dest_addr = {{0x00, 0x12, 0x4b, 0x00, 0x0f, 0x24, 0x18, 0x04}}; product_t product_list[] = { - { 1, "21/12/19", 1.05 }, - { 2, "12/05/19", 3.25 }, - { 3, "05/05/21", 2.50 } + { 1, "21/12/19", 105 }, + { 2, "12/05/19", 325 }, + { 3, "05/05/21", 250 } }; PROCESS(product_proc, "product random generator"); @@ -38,7 +38,7 @@ void scan_product(product_t* p){ nullnet_len = sizeof(m); NETSTACK_NETWORK.output(&dest_addr); - LOG_INFO("Product id [%d] scanned from ", (int)p->product_id); + LOG_INFO("Product id [%d, %d] scanned from ", (int)p->product_id, (int)p->price); LOG_INFO_LLADDR(&dest_addr); LOG_INFO_("\n"); }