Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save PD Local Status #123

Merged
merged 3 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/osdp_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ union osdp_ephemeral_data {

/* PD State Flags */
#define PD_FLAG_SC_CAPABLE BIT(0) /* PD secure channel capable */
#define PD_FLAG_TAMPER BIT(1) /* local tamper status */
#define PD_FLAG_POWER BIT(2) /* local power status */
#define PD_FLAG_R_TAMPER BIT(3) /* remote tamper status */
#define PD_FLAG_AWAIT_RESP BIT(4) /* set after command is sent */
#define PD_FLAG_SKIP_SEQ_CHECK BIT(5) /* disable seq checks (debug) */
Expand Down
15 changes: 12 additions & 3 deletions src/osdp_pd.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ static int pd_translate_event(struct osdp_pd *pd, struct osdp_event *event)
reply_code = REPLY_MFGREP;
break;
case OSDP_EVENT_STATUS:
if (event->status.tamper == 1) {
SET_FLAG(pd, PD_FLAG_TAMPER);
} else {
CLEAR_FLAG(pd, PD_FLAG_TAMPER);
}
if (event->status.power == 1) {
SET_FLAG(pd, PD_FLAG_POWER);
} else {
CLEAR_FLAG(pd, PD_FLAG_POWER);
}
reply_code = REPLY_LSTATR;
break;
default:
Expand Down Expand Up @@ -736,10 +746,9 @@ static int pd_build_reply(struct osdp_pd *pd, uint8_t *buf, int max_len)
}
case REPLY_LSTATR:
assert_buf_len(REPLY_LSTATR_LEN, max_len);
event = (struct osdp_event *)pd->ephemeral_data;
buf[len++] = pd->reply_id;
buf[len++] = event->status.tamper;
buf[len++] = event->status.power;
buf[len++] = ISSET_FLAG(pd, PD_FLAG_TAMPER);
buf[len++] = ISSET_FLAG(pd, PD_FLAG_POWER);
ret = OSDP_PD_ERR_NONE;
break;
case REPLY_RSTATR:
Expand Down
Loading