Some adjustments in the Assigner module
This commit is contained in:
parent
c38f616feb
commit
1c6c374537
@ -14,8 +14,6 @@
|
|||||||
#include "../common/supermarket_net.h"
|
#include "../common/supermarket_net.h"
|
||||||
#include "assigner_fun.h"
|
#include "assigner_fun.h"
|
||||||
|
|
||||||
#define LOG_MODULE "Assigner"
|
|
||||||
#define LOG_LEVEL LOG_LEVEL_INFO
|
|
||||||
#define OPENING_PERIOD (300*CLOCK_SECOND)
|
#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);
|
handle_battery_msg(src,data);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("Invalide type! This message is not for the Assigner");
|
printf("Invalide type! This message is not for the Assigner\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,9 +9,6 @@
|
|||||||
#include "../common/supermarket_net.h"
|
#include "../common/supermarket_net.h"
|
||||||
#include "assigner_fun.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
|
//function invoked in order to look for the most charged cart to assign to the new arrived client
|
||||||
cart* cart_selection()
|
cart* cart_selection()
|
||||||
@ -40,6 +37,11 @@ bool insert_cart(uint8_t new_req_battery, linkaddr_t mac_cart_addr)
|
|||||||
printf("Association Failed");
|
printf("Association Failed");
|
||||||
return false;
|
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
|
else
|
||||||
{
|
{
|
||||||
new_arrived_cart->cart_address = mac_cart_addr;
|
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->assigned = false;
|
||||||
new_arrived_cart->next = cart_list;
|
new_arrived_cart->next = cart_list;
|
||||||
cart_list = new_arrived_cart;
|
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));
|
LOG_INFO_LLADDR(&(new_arrived_cart->cart_address));
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
|
|
||||||
|
#define LOG_MODULE "Assigner"
|
||||||
|
#define LOG_LEVEL LOG_LEVEL_INFO
|
||||||
|
|
||||||
typedef struct cart
|
typedef struct cart
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user