Skip to content

Commit

Permalink
Add state transition timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
pimvanpelt committed Jan 25, 2020
1 parent 4cb38fb commit 0ebb1d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/mgos_fingerprint_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ struct mgos_fingerprint {
uint8_t svc_state;
int svc_timer_id;
uint16_t svc_period_ms;
float svc_state_ts;
};

#ifdef __cplusplus
Expand Down
5 changes: 5 additions & 0 deletions src/mgos_fingerprint_svc.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ static void mgos_fingerprint_svc_enroll(struct mgos_fingerprint *finger) {
}

finger->svc_state = MGOS_FINGERPRINT_STATE_ENROLL2;
finger->svc_state_ts = mg_time();
if (finger->handler)
finger->handler(finger, MGOS_FINGERPRINT_EV_STATE_ENROLL2, NULL,
finger->handler_user_data);
Expand Down Expand Up @@ -110,6 +111,7 @@ static void mgos_fingerprint_svc_enroll(struct mgos_fingerprint *finger) {
(void *) (uintptr_t) &pack, finger->handler_user_data);

finger->svc_state = MGOS_FINGERPRINT_STATE_ENROLL1;
finger->svc_state_ts = mg_time();
if (finger->handler)
finger->handler(finger, MGOS_FINGERPRINT_EV_STATE_ENROLL1, NULL,
finger->handler_user_data);
Expand All @@ -125,6 +127,7 @@ static void mgos_fingerprint_svc_enroll(struct mgos_fingerprint *finger) {

LOG(LL_ERROR, ("Error, returning to enroll mode"));
finger->svc_state = MGOS_FINGERPRINT_STATE_ENROLL1;
finger->svc_state_ts = mg_time();

if (finger->handler)
finger->handler(finger, MGOS_FINGERPRINT_EV_STATE_ENROLL1,
Expand Down Expand Up @@ -187,12 +190,14 @@ bool mgos_fingerprint_svc_mode_set(struct mgos_fingerprint *finger, int mode) {
if (!finger) return false;
if (mode == MGOS_FINGERPRINT_MODE_ENROLL) {
finger->svc_state = MGOS_FINGERPRINT_STATE_ENROLL1;
finger->svc_state_ts = mg_time();
if (finger->handler)
finger->handler(finger, MGOS_FINGERPRINT_EV_STATE_ENROLL1, NULL,
finger->handler_user_data);
return true;
}
finger->svc_state = MGOS_FINGERPRINT_STATE_MATCH;
finger->svc_state_ts = mg_time();
if (finger->handler)
finger->handler(finger, MGOS_FINGERPRINT_EV_STATE_MATCH, NULL,
finger->handler_user_data);
Expand Down

0 comments on commit 0ebb1d3

Please sign in to comment.