mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2025-11-15 07:38:12 +00:00
goodixmoc: cleanup enroll state machine
As suggested by @benzea, the following cleanup actions have been
performed:
- let case order match enroll states enum
- remove FP_ENROLL_IDENTIFY that is no longer used
- finally use fpi_ssm_next_state instead of explicitly jumping to
FP_ENROLL_CREATE
Additionally, all types/functions/variables referring to "enroll_init"
used for FP_ENROLL_CREATE have been renamed to match "enroll_create".
All other states use similar name matching.
Signed-off-by: Enrik Berkhan <Enrik.Berkhan@inka.de>
This commit is contained in:
@@ -631,20 +631,20 @@ fp_enroll_enum_cb (FpiDeviceGoodixMoc *self,
|
||||
return;
|
||||
}
|
||||
|
||||
fpi_ssm_jump_to_state (self->task_ssm, FP_ENROLL_CREATE);
|
||||
fpi_ssm_next_state (self->task_ssm);
|
||||
}
|
||||
|
||||
static void
|
||||
fp_enroll_init_cb (FpiDeviceGoodixMoc *self,
|
||||
gxfp_cmd_response_t *resp,
|
||||
GError *error)
|
||||
fp_enroll_create_cb (FpiDeviceGoodixMoc *self,
|
||||
gxfp_cmd_response_t *resp,
|
||||
GError *error)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
fpi_ssm_mark_failed (self->task_ssm, error);
|
||||
return;
|
||||
}
|
||||
memcpy (self->template_id, resp->enroll_init.tid, TEMPLATE_ID_SIZE);
|
||||
memcpy (self->template_id, resp->enroll_create.tid, TEMPLATE_ID_SIZE);
|
||||
fpi_ssm_next_state (self->task_ssm);
|
||||
}
|
||||
|
||||
@@ -837,16 +837,6 @@ fp_enroll_sm_run_state (FpiSsm *ssm, FpDevice *device)
|
||||
|
||||
switch (fpi_ssm_get_cur_state (ssm))
|
||||
{
|
||||
case FP_ENROLL_ENUM:
|
||||
{
|
||||
goodix_sensor_cmd (self, MOC_CMD0_GETFINGERLIST, MOC_CMD1_DEFAULT,
|
||||
false,
|
||||
(const guint8 *) &dummy,
|
||||
1,
|
||||
fp_enroll_enum_cb);
|
||||
}
|
||||
break;
|
||||
|
||||
case FP_ENROLL_PWR_BTN_SHIELD_ON:
|
||||
{
|
||||
goodix_sensor_cmd (self, MOC_CMD0_PWR_BTN_SHIELD, MOC_CMD1_PWR_BTN_SHIELD_ON,
|
||||
@@ -857,13 +847,23 @@ fp_enroll_sm_run_state (FpiSsm *ssm, FpDevice *device)
|
||||
}
|
||||
break;
|
||||
|
||||
case FP_ENROLL_ENUM:
|
||||
{
|
||||
goodix_sensor_cmd (self, MOC_CMD0_GETFINGERLIST, MOC_CMD1_DEFAULT,
|
||||
false,
|
||||
(const guint8 *) &dummy,
|
||||
1,
|
||||
fp_enroll_enum_cb);
|
||||
}
|
||||
break;
|
||||
|
||||
case FP_ENROLL_CREATE:
|
||||
{
|
||||
goodix_sensor_cmd (self, MOC_CMD0_ENROLL_INIT, MOC_CMD1_DEFAULT,
|
||||
false,
|
||||
(const guint8 *) &dummy,
|
||||
1,
|
||||
fp_enroll_init_cb);
|
||||
fp_enroll_create_cb);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ typedef enum {
|
||||
typedef enum {
|
||||
FP_ENROLL_PWR_BTN_SHIELD_ON = 0,
|
||||
FP_ENROLL_ENUM,
|
||||
FP_ENROLL_IDENTIFY,
|
||||
FP_ENROLL_CREATE,
|
||||
FP_ENROLL_CAPTURE,
|
||||
FP_ENROLL_UPDATE,
|
||||
|
||||
@@ -343,10 +343,10 @@ gx_proto_parse_body (uint16_t cmd, uint8_t *buffer, uint16_t buffer_len, pgxfp_c
|
||||
break;
|
||||
|
||||
case MOC_CMD0_ENROLL_INIT:
|
||||
if (buffer_len < sizeof (gxfp_enroll_init_t) + 1)
|
||||
if (buffer_len < sizeof (gxfp_enroll_create_t) + 1)
|
||||
return -1;
|
||||
if (presp->result == GX_SUCCESS)
|
||||
memcpy (&presp->enroll_init.tid, &buffer[1], TEMPLATE_ID_SIZE);
|
||||
memcpy (&presp->enroll_create.tid, &buffer[1], TEMPLATE_ID_SIZE);
|
||||
break;
|
||||
|
||||
case MOC_CMD0_ENROLL:
|
||||
@@ -465,4 +465,4 @@ gx_proto_init_sensor_config (pgxfp_sensor_cfg_t pconfig)
|
||||
memcpy (pconfig->crc_value, &crc32_calc, PACKAGE_CRC_SIZE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,10 +105,10 @@ typedef struct _gxfp_parse_msg
|
||||
} gxfp_parse_msg_t, *pgxfp_parse_msg_t;
|
||||
|
||||
|
||||
typedef struct _gxfp_enroll_init
|
||||
typedef struct _gxfp_enroll_create
|
||||
{
|
||||
uint8_t tid[TEMPLATE_ID_SIZE];
|
||||
} gxfp_enroll_init_t, *pgxfp_enroll_init_t;
|
||||
} gxfp_enroll_create_t, *pgxfp_enroll_create_t;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
typedef struct _template_format
|
||||
@@ -192,7 +192,7 @@ typedef struct _fp_cmd_response
|
||||
{
|
||||
gxfp_parse_msg_t parse_msg;
|
||||
gxfp_verify_t verify;
|
||||
gxfp_enroll_init_t enroll_init;
|
||||
gxfp_enroll_create_t enroll_create;
|
||||
gxfp_capturedata_t capture_data_resp;
|
||||
gxfp_check_duplicate_t check_duplicate_resp;
|
||||
gxfp_enroll_commit_t enroll_commit;
|
||||
|
||||
Reference in New Issue
Block a user