Commit c330e083 authored by Bc. Petr Elexa's avatar Bc. Petr Elexa

panel: Update acs protocol

parent 813fa50e
......@@ -47,9 +47,8 @@
#define FC_USER_NOT_AUTH_RESP 0x2 // M -> S
#define FC_USER_AUTH_RESP 0x3 // M -> S
#define FC_DOOR_CTRL 0x4 // M -> S
#define FC_NEW_USER 0x5 // S -> M
#define FC_DOOR_STATUS 0x6 // S -> M
#define FC_ALIVE 0x7 // M -> S
#define FC_DOOR_STATUS 0x5 // S -> M
#define FC_ALIVE 0x6 // M -> S
// priorities for each function code (0-7)
#define PRIO_RESERVED 0x0
......@@ -57,20 +56,16 @@
#define PRIO_USER_AUTH_RESP_FAIL 0x2
#define PRIO_USER_AUTH_RESP_OK 0x2
#define PRIO_DOOR_CTRL 0x3
#define PRIO_NEW_USER 0x3
#define PRIO_DOOR_STATUS 0x4
#define PRIO_ALIVE 0x1
// Data for FC_DOOR_CTRL
#define DATA_DOOR_CTRL_MODE_DEF 0x00
#define DATA_DOOR_CTRL_UNLCK 0x01
#define DATA_DOOR_CTRL_LOCK 0x02
#define DATA_DOOR_CTRL_LEARN 0x03
#define DATA_DOOR_CTRL_CLR_CACHE 0x04
#define DATA_DOOR_CTRL_REMOTE_UNLCK 0x01
#define DATA_DOOR_CTRL_CLR_CACHE 0x02
// Data for FC_DOOR_STATUS
#define DATA_DOOR_STATUS_CLOSED 0x0
#define DATA_DOOR_STATUS_OPEN 0x1
#define DATA_DOOR_STATUS_CLOSED 0x01
#define DATA_DOOR_STATUS_OPEN 0x02
// Setting for master communication status
#define ACS_MASTER_ALIVE_PERIOD_MS 5000
......@@ -104,11 +99,6 @@ typedef struct
uint32_t user_id;
} acs_msg_data_auth_resp_t;
typedef struct
{
uint32_t user_id;
} acs_msg_data_new_user_t;
typedef struct
{
uint8_t ctrl_command;
......
......@@ -177,21 +177,9 @@ void term_can_recv(uint8_t msg_obj_num)
{
switch (msg_obj.data[0])
{
case DATA_DOOR_CTRL_MODE_DEF:
DEBUGSTR("mode DEF\n");
reader_conf[reader_idx].mode = READER_MODE_DEF;
break;
case DATA_DOOR_CTRL_UNLCK:
case DATA_DOOR_CTRL_REMOTE_UNLCK:
DEBUGSTR("cmd UNLOCK\n");
terminal_user_authorized(reader_idx);
break;
case DATA_DOOR_CTRL_LOCK:
DEBUGSTR("mode LOCK\n");
reader_conf[reader_idx].mode = READER_MODE_LOCKED;
break;
case DATA_DOOR_CTRL_LEARN:
DEBUGSTR("mode LEARN\n");
reader_conf[reader_idx].mode = READER_MODE_LEARN;
reader_unlock(reader_idx, BEEP_ON_SUCCESS, OK_LED_ON_SUCCESS);
break;
case DATA_DOOR_CTRL_CLR_CACHE:
DEBUGSTR("cmd CLR CACHE\n");
......@@ -206,8 +194,8 @@ void term_can_recv(uint8_t msg_obj_num)
else return;
}
// Send command to server that register given user id
static void terminal_register_user(uint32_t user_id, uint8_t reader_idx)
// Send door status update to server
static void terminal_send_door_status(uint8_t reader_idx, bool open)
{
//check if master online
if (_act_master == ACS_RESERVED_ADDR)
......@@ -219,19 +207,21 @@ static void terminal_register_user(uint32_t user_id, uint8_t reader_idx)
// Prepare msg head to send request on CAN
acs_msg_head_t head;
head.scalar = CAN_MSGOBJ_EXT;
head.prio = PRIO_NEW_USER;
head.fc = FC_NEW_USER;
head.prio = PRIO_DOOR_STATUS;
head.fc = FC_DOOR_STATUS;
head.dst = _act_master;
uint8_t status = (open ? DATA_DOOR_STATUS_OPEN : DATA_DOOR_STATUS_CLOSED);
if (reader_idx == ACS_READER_A_IDX)
{
head.src = get_reader_a_addr();
CAN_send_once(ACS_MSGOBJ_SEND_DOOR_A, head.scalar, (void *)&user_id, sizeof(user_id));
CAN_send_once(ACS_MSGOBJ_SEND_DOOR_A, head.scalar, (void *)&status, sizeof(status));
}
else if (reader_idx == ACS_READER_B_IDX)
{
head.src = get_reader_b_addr();
CAN_send_once(ACS_MSGOBJ_SEND_DOOR_B, head.scalar, (void *)&user_id, sizeof(user_id));
CAN_send_once(ACS_MSGOBJ_SEND_DOOR_B, head.scalar, (void *)&status, sizeof(status));
}
}
......@@ -273,27 +263,20 @@ static void terminal_user_identified(uint32_t user_id, uint8_t reader_idx)
if (reader_idx < ACS_READER_COUNT)
{
if (reader_conf[reader_idx].mode == READER_MODE_LOCKED)
{
terminal_user_not_authorized(reader_idx);
}
else if (reader_conf[reader_idx].mode == READER_MODE_LEARN)
{
terminal_register_user(user_id, reader_idx);
}
#if CACHING_ENABLED
else if (static_cache_get(&user))
if (static_cache_get(&user))
{
if (map_reader_idx_to_cache(reader_idx) & user.value)
{
terminal_user_authorized(reader_idx);
}
}
#endif
else
#else
{
terminal_request_auth(user_id, reader_idx);
}
#endif
}
}
......
......@@ -44,7 +44,6 @@ reader_conf_t reader_conf[ACS_READER_MAXCOUNT] =
.timer_open = NULL,
.open_time_sec = ACS_READER_A_OPEN_TIME_MS,
.gled_time_sec = ACS_READER_A_OK_GLED_TIME_MS,
.mode = READER_MODE_DEF,
.enabled = ACS_READER_A_ENABLED,
},
{
......@@ -52,7 +51,6 @@ reader_conf_t reader_conf[ACS_READER_MAXCOUNT] =
.timer_open = NULL,
.open_time_sec = ACS_READER_B_OPEN_TIME_MS,
.gled_time_sec = ACS_READER_B_OK_GLED_TIME_MS,
.mode = READER_MODE_DEF,
.enabled = ACS_READER_B_ENABLED,
}
};
......
......@@ -25,7 +25,6 @@ typedef struct
TimerHandle_t timer_ok;
uint16_t open_time_sec;
uint16_t gled_time_sec;
reader_mode_t mode;
uint8_t enabled;
} reader_conf_t;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment