Merge branch 'master' of git.giomba.it:giomba/nes-proj

This commit is contained in:
giomba 2019-04-16 15:53:01 +02:00
commit f6e5c137a0
5 changed files with 15 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

@ -19,7 +19,7 @@
typedef struct user_invoice
{
uint8_t n_prods;
float total_sum;
uint32_t total_sum;
uint32_t customer_id;
uint8_t empty;
linkaddr_t address_basket;
@ -85,7 +85,7 @@ static void input_callback(const void* data, uint16_t len, const linkaddr_t* sou
nullnet_buf = (uint8_t*)&start_sending_list;
LOG_INFO("Sending acknowledgment to start sending list of products to ");
LOG_INFO_LLADDR(&(invoices[index].address_basket));
LOG_INFO_LLADDR(&(invoices[index].address_basket));
nullnet_len = sizeof(start_sending_list);
NETSTACK_NETWORK.output(&(invoices[index].address_basket));
} else
@ -93,7 +93,7 @@ static void input_callback(const void* data, uint16_t len, const linkaddr_t* sou
}
if (received_msg.msg_type == PRODUCT_MSG) {
product_msg *product = (product_msg*)(&received_msg);
printf("Received id: %d, price %f\n", (int)product->product_id, product->price);
printf("Received id: %d, price %f\n", (int)product->product_id, (int)product->price);
uint8_t index = invoice_index(product->customer_id, invoices);
if (index != -1) {
if (invoices[index].n_prods > 0) {
@ -123,9 +123,10 @@ PROCESS_THREAD(cassa_main_process, ev, data) {
nullnet_set_input_callback(input_callback); //this should be moved down?
printf("Dear customer, insert your card id\n");
while (true) {
printf("Dear customer, insert your card id\n");
PROCESS_WAIT_EVENT_UNTIL(ev == serial_line_event_message);
printf("Customer's id: %s\n", (char*)data);

View File

@ -72,7 +72,7 @@ typedef struct product_msg
enum message_type msg_type;
uint32_t customer_id;
uint32_t product_id;
float price;
uint32_t price;
}product_msg;