nes-proj/project/Giomba/cart.c

53 lines
1.3 KiB
C
Raw Normal View History

2019-04-11 15:46:54 +00:00
#include <stdio.h>
#include <string.h>
#include "os/dev/leds.h"
#include "batmon-sensor.h"
#include "../common/supermarket_net.h"
#include "event.h"
#include "log.h"
#include "sendrecv.h"
2019-04-12 12:56:37 +00:00
#include "status.h"
2019-04-11 15:46:54 +00:00
//static linkaddr_t destination_address = {{ 0x00, 0x12, 0x4b, 0x00, 0x0f, 0x8f, 0x18, 0x11 }};
PROCESS(cart_main_process, "Cart Process");
AUTOSTART_PROCESSES(&cart_main_process);
PROCESS_THREAD(cart_main_process, ev, data) {
PROCESS_BEGIN();
2019-04-12 12:56:37 +00:00
// SENSORS_ACTIVATE(batmon_sensor);
2019-04-11 15:46:54 +00:00
/*** Variables initialization ***/
2019-04-14 13:28:10 +00:00
// status = NOT_ASSOCIATED; // TODO DEBUG
status = SHOPPING; // NOT_ASSOCIATED;
2019-04-12 14:30:05 +00:00
etimer_set(&broadcast_timer, 5 * CLOCK_SECOND);
2019-04-11 15:46:54 +00:00
2019-04-12 12:56:37 +00:00
/*** Subsystem initialization ***/
net_init();
2019-04-11 15:46:54 +00:00
2019-04-12 12:56:37 +00:00
/* START */
2019-04-11 15:46:54 +00:00
printf("Hello! I'm the cart.\n");
while (true) {
PROCESS_WAIT_EVENT();
switch(status) {
case NOT_ASSOCIATED: s_not_associated(ev, data); break;
case ASSOCIATED: s_associated(ev, data); break;
case SHOPPING: s_shopping(ev, data); break;
case CASH_OUT_WAIT4ACK: s_cash_out_wait4ack(ev, data); break;
case CASH_OUT_SEND_LIST: s_cash_out_send_list(ev, data); break;
default:
printf("[E] Invalid status. Resetting status.\n");
status = NOT_ASSOCIATED;
2019-04-12 14:30:05 +00:00
break;
2019-04-11 15:46:54 +00:00
}
}
PROCESS_END();
}