This commit is contained in:
natalija.zlatkova@gmail.com 2019-04-16 15:51:54 +02:00
commit f04a290aae
5 changed files with 14 additions and 12 deletions

View File

@ -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;
}

View File

@ -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");
}

View File

@ -6,6 +6,8 @@
#include <stdlib.h>
#include "sys/log.h"
#define LOG_MODULE "Assigner"
#define LOG_LEVEL LOG_LEVEL_INFO
typedef struct cart
{

View File

@ -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

View File

@ -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");
}