nes-proj/common/supermarket_net.h

84 lines
1.5 KiB
C
Raw Normal View History

2019-04-11 15:46:54 +00:00
#ifndef SUPERMARKET_NET_H
#define SUPERMARKET_NET_H
2019-04-13 07:29:17 +00:00
#include "product.h"
#define PRODUCT_ARRAY_MAX_LEN 5
2019-04-12 14:30:01 +00:00
enum message_type {
2019-04-11 15:46:54 +00:00
ASSOCIATION_REQUEST_MSG,
ASSOCIATION_REPLY_MSG,
BATTERY_STATUS_MSG,
ASSIGNMENT_MSG,
2019-04-12 14:30:01 +00:00
CASH_OUT_MSG,
2019-04-12 17:05:44 +00:00
ITEM_MSG, /* from item to cart */
PRODUCT_PARTIAL_LIST_MSG, /* from cart to cash */
2019-04-12 14:30:01 +00:00
BASKET_MSG,
START_OF_LIST_PRODUCTS_MSG,
PRODUCT_PARTIAL_LIST_ACK, /* everytime the cash register receives a product message, it sends an ack to the cart so that the cart can send the next product message */
START_SHOPPING_MSG
2019-04-11 15:46:54 +00:00
};
2019-04-12 14:30:01 +00:00
typedef struct msg {
enum message_type msg_type;
}msg;
2019-04-12 14:30:05 +00:00
2019-04-12 14:44:25 +00:00
typedef struct assoc_req_msg
2019-04-12 14:30:01 +00:00
{
enum message_type msg_type;
uint8_t battery_percentage;
2019-04-12 14:30:05 +00:00
2019-04-12 14:30:01 +00:00
}assoc_req_msg;
2019-04-12 14:30:05 +00:00
2019-04-12 14:30:01 +00:00
typedef struct assoc_reply_msg
{
enum message_type msg_type;
}assoc_reply_msg;
2019-04-12 14:30:05 +00:00
2019-04-12 14:30:01 +00:00
typedef struct battery_msg
{
enum message_type msg_type;
uint8_t battery_percentage;
}battery_msg;
typedef struct assign_msg
{
enum message_type msg_type;
uint32_t customer_id;
2019-04-12 14:44:25 +00:00
}assign_msg;
2019-04-12 14:30:01 +00:00
typedef struct basket_msg
2019-04-12 14:44:25 +00:00
{
2019-04-12 14:30:01 +00:00
enum message_type msg_type;
uint8_t n_products;
2019-04-14 13:27:32 +00:00
uint32_t customer_id;
2019-04-12 14:30:01 +00:00
}basket_msg;
2019-04-13 07:29:17 +00:00
typedef struct item_msg
{
enum message_type msg_type;
product_t p;
} item_msg;
2019-04-12 14:30:01 +00:00
typedef struct cash_out_msg
{
enum message_type msg_type;
2019-04-14 13:27:32 +00:00
uint32_t customer_id;
2019-04-12 14:30:01 +00:00
}cash_out_msg;
typedef struct product_partial_list_msg
2019-04-12 14:30:01 +00:00
{
2019-04-12 14:44:25 +00:00
enum message_type msg_type;
uint32_t customer_id;
uint8_t array_len;
product_t p[PRODUCT_ARRAY_MAX_LEN];
}product_partial_list_msg;
2019-04-12 14:30:01 +00:00
2019-04-11 15:46:54 +00:00
#endif