Skip to content

Commit

Permalink
Merge pull request #123 from sgouraud/pd-lstatus-fix
Browse files Browse the repository at this point in the history
save PD Local Status
  • Loading branch information
sidcha authored Oct 11, 2023
2 parents dbff2d1 + a3bf00d commit 35f0815
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
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

0 comments on commit 35f0815

Please sign in to comment.