Introduced bmlite callback functions
Change-Id: I6f8502b06733b1bebfe700dbe78407eeb0e256ff
This commit is contained in:
parent
4be3f43031
commit
799ae949a7
@ -29,6 +29,80 @@
|
|||||||
|
|
||||||
#define REMOVE_ID_ALL_TEMPLATES 0U
|
#define REMOVE_ID_ALL_TEMPLATES 0U
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
BMLITE_ERROR_OK = 0,
|
||||||
|
BMLITE_ERROR_CAPTURE,
|
||||||
|
BMLITE_ERROR_CAPTURE_START,
|
||||||
|
BMLITE_ERROR_ENROLL_START,
|
||||||
|
BMLITE_ERROR_ENROLL_ADD,
|
||||||
|
BMLITE_ERROR_ENROLL_FINISH,
|
||||||
|
BMLITE_ERROR_WRONG_ANSWER,
|
||||||
|
BMLITE_ERROR_FINGER_WAIT,
|
||||||
|
BMLITE_ERROR_IDENTYFY,
|
||||||
|
BMLITE_ERROR_TEMPLATE_SAVE,
|
||||||
|
BMLITE_ERROR_TEMPLATE_DELETE,
|
||||||
|
BMLITE_ERROR_TEMPLATE_COUNT,
|
||||||
|
BMLITE_ERROR_TEMPLATE_GETIDS,
|
||||||
|
BMLITE_ERROR_IMAGE_EXTRACT,
|
||||||
|
BMLITE_ERROR_IMAGE_GETSIZE,
|
||||||
|
BMLITE_ERROR_IMAGE_GET,
|
||||||
|
BMLITE_ERROR_GETVERSION,
|
||||||
|
BMLITE_ERROR_SW_RESET,
|
||||||
|
BMLITE_ERROR_CALIBRATE,
|
||||||
|
BMLITE_ERROR_CALIBRATE_DELETE,
|
||||||
|
BMLITE_ERROR_SEND_CMD
|
||||||
|
} bmlite_error_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Error Callback function
|
||||||
|
*
|
||||||
|
* @param[in] Callback Error Code
|
||||||
|
* @param[in] BEP result code
|
||||||
|
*/
|
||||||
|
void bmlite_on_error(bmlite_error_t error, int32_t value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Starting Capture Callback function
|
||||||
|
*/
|
||||||
|
void bmlite_on_start_capture();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Finishing Capture Callback function
|
||||||
|
*/
|
||||||
|
void bmlite_on_finish_capture();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Starting Enroll Callback function
|
||||||
|
*/
|
||||||
|
void bmlite_on_start_enroll();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Finishing Enroll Callback function
|
||||||
|
*/
|
||||||
|
void bmlite_on_finish_enroll();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Starting Capture for Enroll Callback function
|
||||||
|
*/
|
||||||
|
void bmlite_on_start_enrollcapture();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Finishing Capture for Enroll Callback function
|
||||||
|
*/
|
||||||
|
void bmlite_on_finish_enrollcapture();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Starting Identify Callback function
|
||||||
|
*/
|
||||||
|
void bmlite_on_identify_start();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Finishing Identify Callback function
|
||||||
|
*/
|
||||||
|
void bmlite_on_identify_finish();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sends HCP commands for capturing an image in Bio MCU
|
* @brief Sends HCP commands for capturing an image in Bio MCU
|
||||||
*
|
*
|
||||||
|
|||||||
@ -37,23 +37,28 @@
|
|||||||
|
|
||||||
#define RECEIVE_TIMEOUT 10
|
#define RECEIVE_TIMEOUT 10
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
#define log_debug(format, ...) printf(format, ##__VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define log_debug(format, ...)
|
|
||||||
#endif
|
|
||||||
// #define log_info(format, ...) printf(format, ##__VA_ARGS__)
|
|
||||||
// #define log_error(format, ...) printf(format, ##__VA_ARGS__)
|
|
||||||
|
|
||||||
#define log_info(format, ...)
|
|
||||||
#define log_error(format, ...)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Maximum attempts for capture image */
|
/** Maximum attempts for capture image */
|
||||||
static const uint8_t MAX_CAPTURE_ATTEMPTS = 15U;
|
static const uint8_t MAX_CAPTURE_ATTEMPTS = 15U;
|
||||||
static const uint16_t CAPTURE_TIMEOUT = 3000;
|
static const uint16_t CAPTURE_TIMEOUT = 3000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Mock callback functions
|
||||||
|
*/
|
||||||
|
__attribute__((weak)) void bmlite_on_error(bmlite_error_t error, int32_t value) { (void)error; (void)value; }
|
||||||
|
|
||||||
|
__attribute__((weak)) void bmlite_on_start_capture() {}
|
||||||
|
__attribute__((weak)) void bmlite_on_finish_capture() {}
|
||||||
|
|
||||||
|
__attribute__((weak)) void bmlite_on_finish_enroll() {}
|
||||||
|
__attribute__((weak)) void bmlite_on_start_enroll() {}
|
||||||
|
|
||||||
|
__attribute__((weak)) void bmlite_on_start_enrollcapture() {}
|
||||||
|
__attribute__((weak)) void bmlite_on_finish_enrollcapture() {}
|
||||||
|
|
||||||
|
__attribute__((weak)) void bmlite_on_identify_start() {}
|
||||||
|
__attribute__((weak)) void bmlite_on_identify_finish() {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Helper function for sending HCP commands
|
* @brief Helper function for sending HCP commands
|
||||||
@ -84,7 +89,6 @@ static fpc_bep_result_t send_command_args2(fpc_com_chain_t *chain, fpc_hcp_cmd_t
|
|||||||
|
|
||||||
if (arg_key1 != ARG_NONE) {
|
if (arg_key1 != ARG_NONE) {
|
||||||
if (!fpc_hcp_arg_add(&command, arg_key1, arg_data1_length, false, arg_data1)) {
|
if (!fpc_hcp_arg_add(&command, arg_key1, arg_data1_length, false, arg_data1)) {
|
||||||
log_error("%s:%u Could not add arg:%u\n", __func__, __LINE__, arg_key1);
|
|
||||||
bep_result = FPC_BEP_RESULT_NO_MEMORY;
|
bep_result = FPC_BEP_RESULT_NO_MEMORY;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@ -92,7 +96,6 @@ static fpc_bep_result_t send_command_args2(fpc_com_chain_t *chain, fpc_hcp_cmd_t
|
|||||||
|
|
||||||
if (arg_key2 != ARG_NONE) {
|
if (arg_key2 != ARG_NONE) {
|
||||||
if (!fpc_hcp_arg_add(&command, arg_key2, arg_data2_length, false, arg_data2)) {
|
if (!fpc_hcp_arg_add(&command, arg_key2, arg_data2_length, false, arg_data2)) {
|
||||||
log_error("%s:%u Could not add arg:%u\n", __func__, __LINE__, arg_key2);
|
|
||||||
bep_result = FPC_BEP_RESULT_NO_MEMORY;
|
bep_result = FPC_BEP_RESULT_NO_MEMORY;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@ -102,7 +105,7 @@ static fpc_bep_result_t send_command_args2(fpc_com_chain_t *chain, fpc_hcp_cmd_t
|
|||||||
bep_result = com_to_bep_result(com_result);
|
bep_result = com_to_bep_result(com_result);
|
||||||
|
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("%s:%u ERROR %d\n", __func__, __LINE__, bep_result);
|
bmlite_on_error(BMLITE_ERROR_SEND_CMD, bep_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
@ -162,7 +165,6 @@ static fpc_bep_result_t receive_result_args2(fpc_com_chain_t *chain,
|
|||||||
if (arg_data) {
|
if (arg_data) {
|
||||||
bep_result = *(int8_t *)arg_data->data;
|
bep_result = *(int8_t *)arg_data->data;
|
||||||
} else {
|
} else {
|
||||||
log_error("%s Result argument missing\n", __func__);
|
|
||||||
bep_result = FPC_BEP_RESULT_INVALID_ARGUMENT;
|
bep_result = FPC_BEP_RESULT_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
@ -175,7 +177,6 @@ static fpc_bep_result_t receive_result_args2(fpc_com_chain_t *chain,
|
|||||||
if (arg_data && arg_data->size <= arg_data1_length) {
|
if (arg_data && arg_data->size <= arg_data1_length) {
|
||||||
memcpy(arg_data1, arg_data->data, arg_data->size);
|
memcpy(arg_data1, arg_data->data, arg_data->size);
|
||||||
} else {
|
} else {
|
||||||
log_error("%s %d argument missing\n", __func__, arg_key1);
|
|
||||||
bep_result = FPC_BEP_RESULT_INVALID_ARGUMENT;
|
bep_result = FPC_BEP_RESULT_INVALID_ARGUMENT;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@ -186,10 +187,7 @@ static fpc_bep_result_t receive_result_args2(fpc_com_chain_t *chain,
|
|||||||
arg_data = fpc_hcp_arg_get(&response, arg_key2);
|
arg_data = fpc_hcp_arg_get(&response, arg_key2);
|
||||||
if (arg_data && arg_data->size <= arg_data2_length) {
|
if (arg_data && arg_data->size <= arg_data2_length) {
|
||||||
memcpy(arg_data2, arg_data->data, arg_data->size);
|
memcpy(arg_data2, arg_data->data, arg_data->size);
|
||||||
} else {
|
}
|
||||||
/* Not an error since the second argument is optional */
|
|
||||||
log_debug("%s %d argument missing\n", __func__, arg_key2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
@ -214,18 +212,16 @@ fpc_bep_result_t bep_capture(fpc_com_chain_t *chain, uint16_t timeout)
|
|||||||
{
|
{
|
||||||
fpc_bep_result_t bep_result;
|
fpc_bep_result_t bep_result;
|
||||||
|
|
||||||
log_info("Put finger on sensor\n");
|
|
||||||
|
|
||||||
/* Capture finger down */
|
/* Capture finger down */
|
||||||
bep_result = send_command(chain, CMD_CAPTURE, ARG_TIMEOUT, &timeout, sizeof(timeout));
|
bep_result = send_command(chain, CMD_CAPTURE, ARG_TIMEOUT, &timeout, sizeof(timeout));
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("%s:%u Error transmitting CMD_CAPTURE\n", __func__, __LINE__);
|
bmlite_on_error(BMLITE_ERROR_CAPTURE_START, bep_result);
|
||||||
return bep_result;
|
return bep_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
platform_set_led(BMLITE_LED_STATUS_WAITTOUCH);
|
bmlite_on_start_capture();
|
||||||
bep_result = receive_result_no_args(chain);
|
bep_result = receive_result_no_args(chain);
|
||||||
platform_set_led(BMLITE_LED_STATUS_READY);
|
bmlite_on_finish_capture();
|
||||||
|
|
||||||
return bep_result;
|
return bep_result;
|
||||||
}
|
}
|
||||||
@ -239,47 +235,43 @@ fpc_bep_result_t bep_enroll_finger(fpc_com_chain_t *chain)
|
|||||||
/* Enroll start */
|
/* Enroll start */
|
||||||
bep_result = send_command(chain, CMD_ENROLL, ARG_START, NULL, 0);
|
bep_result = send_command(chain, CMD_ENROLL, ARG_START, NULL, 0);
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("%s, ERROR line:%u\n", __func__, __LINE__);
|
bmlite_on_error(BMLITE_ERROR_ENROLL_START, bep_result);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
bep_result = receive_result_no_args(chain);
|
bep_result = receive_result_no_args(chain);
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("%s:%u, ERROR receiving status=%d\n", __func__, __LINE__, bep_result);
|
bmlite_on_error(BMLITE_ERROR_WRONG_ANSWER, bep_result);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bmlite_on_start_enroll();
|
||||||
|
|
||||||
for (uint8_t i = 0; i < MAX_CAPTURE_ATTEMPTS; ++i) {
|
for (uint8_t i = 0; i < MAX_CAPTURE_ATTEMPTS; ++i) {
|
||||||
|
|
||||||
|
bmlite_on_start_enrollcapture();
|
||||||
bep_result = bep_capture(chain, CAPTURE_TIMEOUT);
|
bep_result = bep_capture(chain, CAPTURE_TIMEOUT);
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("Capture failed\n");
|
bmlite_on_error(BMLITE_ERROR_CAPTURE, bep_result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_info("Capture done. Remove finger from sensor\n");
|
bmlite_on_finish_enrollcapture();
|
||||||
|
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
|
||||||
log_error("%s:%u, ERROR receiving, result=%d\n", __func__, __LINE__, bep_result);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Enroll add */
|
/* Enroll add */
|
||||||
bep_result = send_command(chain, CMD_ENROLL, ARG_ADD, NULL, 0);
|
bep_result = send_command(chain, CMD_ENROLL, ARG_ADD, NULL, 0);
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("%s:%u, ERROR\n", __func__, __LINE__);
|
bmlite_on_error(BMLITE_ERROR_ENROLL_ADD, bep_result);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bep_result = receive_result_args1(chain, ARG_COUNT, &samples_remaining,
|
bep_result = receive_result_args1(chain, ARG_COUNT, &samples_remaining,
|
||||||
sizeof(samples_remaining));
|
sizeof(samples_remaining));
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("%s:%u, ERROR receiving status=%d\n", __func__, __LINE__, bep_result);
|
bmlite_on_error(BMLITE_ERROR_WRONG_ANSWER, bep_result);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_info("Enroll samples remaining: %d\n", samples_remaining);
|
|
||||||
|
|
||||||
if (samples_remaining == 0U) {
|
if (samples_remaining == 0U) {
|
||||||
enroll_done = true;
|
enroll_done = true;
|
||||||
break;
|
break;
|
||||||
@ -287,14 +279,14 @@ fpc_bep_result_t bep_enroll_finger(fpc_com_chain_t *chain)
|
|||||||
|
|
||||||
bep_result = send_command(chain, CMD_WAIT, ARG_FINGER_UP, NULL, 0);
|
bep_result = send_command(chain, CMD_WAIT, ARG_FINGER_UP, NULL, 0);
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("%s:%u, ERROR\n", __func__, __LINE__);
|
bmlite_on_error(BMLITE_ERROR_FINGER_WAIT, bep_result);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait for finger to be lifted from sensor */
|
/* Wait for finger to be lifted from sensor */
|
||||||
bep_result = receive_result_no_args(chain);
|
bep_result = receive_result_no_args(chain);
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("%s:%u, ERROR receiving status=%d\n", __func__, __LINE__, bep_result);
|
bmlite_on_error(BMLITE_ERROR_WRONG_ANSWER, bep_result);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -303,11 +295,12 @@ fpc_bep_result_t bep_enroll_finger(fpc_com_chain_t *chain)
|
|||||||
if (bep_result == FPC_BEP_RESULT_OK) {
|
if (bep_result == FPC_BEP_RESULT_OK) {
|
||||||
bep_result = receive_result_no_args(chain);
|
bep_result = receive_result_no_args(chain);
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("%s:%u, ERROR receiving status=%d\n", __func__, __LINE__, bep_result);
|
bmlite_on_error(BMLITE_ERROR_ENROLL_FINISH, bep_result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
bmlite_on_finish_enroll();
|
||||||
return (!enroll_done) ? FPC_BEP_RESULT_GENERAL_ERROR : bep_result;
|
return (!enroll_done) ? FPC_BEP_RESULT_GENERAL_ERROR : bep_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,33 +310,33 @@ fpc_bep_result_t bep_identify_finger(fpc_com_chain_t *chain, uint16_t *template_
|
|||||||
|
|
||||||
*match = false;
|
*match = false;
|
||||||
|
|
||||||
|
bmlite_on_identify_start();
|
||||||
bep_result = bep_capture(chain, CAPTURE_TIMEOUT);
|
bep_result = bep_capture(chain, CAPTURE_TIMEOUT);
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("Capture failed result=%d\n", bep_result);
|
bmlite_on_error(BMLITE_ERROR_CAPTURE, bep_result);
|
||||||
return bep_result;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_info("Capture done. Remove finger from sensor\n");
|
|
||||||
|
|
||||||
bep_result = bep_image_extract(chain);
|
bep_result = bep_image_extract(chain);
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("Extract failed\n");
|
goto exit;
|
||||||
return bep_result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bep_result = send_command(chain, CMD_IDENTIFY, ARG_NONE, NULL, 0);
|
bep_result = send_command(chain, CMD_IDENTIFY, ARG_NONE, NULL, 0);
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("Identify failed\n");
|
bmlite_on_error(BMLITE_ERROR_IDENTYFY, bep_result);
|
||||||
return bep_result;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
bep_result = receive_result_args2(chain, ARG_MATCH, match, sizeof(bool),
|
bep_result = receive_result_args2(chain, ARG_MATCH, match, sizeof(bool),
|
||||||
ARG_ID, template_id, sizeof(uint16_t));
|
ARG_ID, template_id, sizeof(uint16_t));
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("Identify failed\n");
|
bmlite_on_error(BMLITE_ERROR_WRONG_ANSWER, bep_result);
|
||||||
return bep_result;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exit:
|
||||||
|
bmlite_on_identify_finish();
|
||||||
return bep_result;
|
return bep_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,7 +347,7 @@ fpc_bep_result_t bep_save_template(fpc_com_chain_t *chain, uint16_t template_id)
|
|||||||
bep_result = send_command_args2(chain, CMD_TEMPLATE, ARG_SAVE, NULL, 0, ARG_ID, &template_id,
|
bep_result = send_command_args2(chain, CMD_TEMPLATE, ARG_SAVE, NULL, 0, ARG_ID, &template_id,
|
||||||
sizeof(template_id));
|
sizeof(template_id));
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("%s:%u, ERROR\n", __func__, __LINE__);
|
bmlite_on_error(BMLITE_ERROR_TEMPLATE_SAVE, bep_result);
|
||||||
return bep_result;
|
return bep_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,7 +366,7 @@ fpc_bep_result_t bep_delete_template(fpc_com_chain_t *chain, uint16_t template_i
|
|||||||
ARG_ID, &template_id, sizeof(template_id));
|
ARG_ID, &template_id, sizeof(template_id));
|
||||||
}
|
}
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("%s:%u, ERROR\n", __func__, __LINE__);
|
bmlite_on_error(BMLITE_ERROR_TEMPLATE_DELETE, bep_result);
|
||||||
return bep_result;
|
return bep_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,13 +379,13 @@ fpc_bep_result_t bep_get_template_count(fpc_com_chain_t *chain, uint32_t *templa
|
|||||||
|
|
||||||
bep_result = send_command(chain, CMD_STORAGE_TEMPLATE, ARG_COUNT, NULL, 0);
|
bep_result = send_command(chain, CMD_STORAGE_TEMPLATE, ARG_COUNT, NULL, 0);
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("%s:%u ERROR sending CMD_STORAGE_TEMPLATE\n", __func__, __LINE__);
|
bmlite_on_error(BMLITE_ERROR_TEMPLATE_COUNT, bep_result);
|
||||||
return bep_result;
|
return bep_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bep_result = receive_result_args1(chain, ARG_COUNT, template_count, sizeof(template_count[0]));
|
bep_result = receive_result_args1(chain, ARG_COUNT, template_count, sizeof(template_count[0]));
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("%s:%u, ERROR receiving status=%d\n", __func__, __LINE__, bep_result);
|
bmlite_on_error(BMLITE_ERROR_WRONG_ANSWER, bep_result);
|
||||||
return bep_result;
|
return bep_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,14 +399,15 @@ fpc_bep_result_t bep_get_template_ids(fpc_com_chain_t *chain, uint16_t *template
|
|||||||
|
|
||||||
bep_result = send_command(chain, CMD_STORAGE_TEMPLATE, ARG_ID, NULL, 0);
|
bep_result = send_command(chain, CMD_STORAGE_TEMPLATE, ARG_ID, NULL, 0);
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("%s:%u ERROR sending CMD_STORAGE_TEMPLATE\n", __func__, __LINE__);
|
bmlite_on_error(BMLITE_ERROR_TEMPLATE_GETIDS, bep_result);
|
||||||
return bep_result;
|
return bep_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bep_result = receive_result_args1(chain, ARG_DATA, template_ids, nof_templates *
|
bep_result = receive_result_args1(chain, ARG_DATA, template_ids, nof_templates *
|
||||||
sizeof(template_ids[0]));
|
sizeof(template_ids[0]));
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("%s:%u, ERROR receiving status=%d\n", __func__, __LINE__, bep_result);
|
bmlite_on_error(BMLITE_ERROR_WRONG_ANSWER, bep_result);
|
||||||
|
|
||||||
return bep_result;
|
return bep_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,7 +420,7 @@ fpc_bep_result_t bep_image_extract(fpc_com_chain_t *chain)
|
|||||||
|
|
||||||
bep_result = send_command(chain, CMD_IMAGE, ARG_EXTRACT, NULL, 0);
|
bep_result = send_command(chain, CMD_IMAGE, ARG_EXTRACT, NULL, 0);
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("Extract failed\n");
|
bmlite_on_error(BMLITE_ERROR_IMAGE_EXTRACT, bep_result);
|
||||||
return bep_result;
|
return bep_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,12 +433,10 @@ fpc_bep_result_t bep_image_get_size(fpc_com_chain_t *chain, uint32_t *size)
|
|||||||
|
|
||||||
bep_result = send_command(chain, CMD_IMAGE, ARG_SIZE, NULL, 0);
|
bep_result = send_command(chain, CMD_IMAGE, ARG_SIZE, NULL, 0);
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("Extract failed\n");
|
bmlite_on_error(BMLITE_ERROR_IMAGE_GETSIZE, bep_result);
|
||||||
return bep_result;
|
return bep_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_info("Downloading image data...\n");
|
|
||||||
|
|
||||||
return receive_result_args1(chain, ARG_SIZE, size, sizeof(size));
|
return receive_result_args1(chain, ARG_SIZE, size, sizeof(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,7 +446,7 @@ fpc_bep_result_t bep_image_get(fpc_com_chain_t *chain, uint8_t *data, uint32_t s
|
|||||||
|
|
||||||
bep_result = send_command(chain, CMD_IMAGE, ARG_UPLOAD, NULL, 0);
|
bep_result = send_command(chain, CMD_IMAGE, ARG_UPLOAD, NULL, 0);
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("Extract failed\n");
|
bmlite_on_error(BMLITE_ERROR_IMAGE_GET, bep_result);
|
||||||
return bep_result;
|
return bep_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,7 +459,7 @@ fpc_bep_result_t bep_version(fpc_com_chain_t *chain, char *version, int len)
|
|||||||
|
|
||||||
bep_result = send_command_args2(chain, CMD_INFO, ARG_GET, NULL, 0, ARG_VERSION, NULL, 0);
|
bep_result = send_command_args2(chain, CMD_INFO, ARG_GET, NULL, 0, ARG_VERSION, NULL, 0);
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("%s, ERROR line:%u\n", __func__, __LINE__);
|
bmlite_on_error(BMLITE_ERROR_GETVERSION, bep_result);
|
||||||
return bep_result;
|
return bep_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,7 +472,7 @@ fpc_bep_result_t bep_reset(fpc_com_chain_t *chain)
|
|||||||
|
|
||||||
bep_result = send_command_no_args(chain, CMD_RESET);
|
bep_result = send_command_no_args(chain, CMD_RESET);
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("%s:%u, ERROR\n", __func__, __LINE__);
|
bmlite_on_error(BMLITE_ERROR_SW_RESET, bep_result);
|
||||||
return bep_result;
|
return bep_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,7 +485,7 @@ fpc_bep_result_t bep_sensor_calibrate(fpc_com_chain_t *chain)
|
|||||||
|
|
||||||
bep_result = send_command_no_args(chain, CMD_STORAGE_CALIBRATION);
|
bep_result = send_command_no_args(chain, CMD_STORAGE_CALIBRATION);
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("%s:%u, ERROR\n", __func__, __LINE__);
|
bmlite_on_error(BMLITE_ERROR_CALIBRATE, bep_result);
|
||||||
return bep_result;
|
return bep_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,7 +498,7 @@ fpc_bep_result_t bep_sensor_calibrate_remove(fpc_com_chain_t *chain)
|
|||||||
|
|
||||||
bep_result = send_command(chain, CMD_STORAGE_CALIBRATION, ARG_DELETE, NULL, 0);
|
bep_result = send_command(chain, CMD_STORAGE_CALIBRATION, ARG_DELETE, NULL, 0);
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("%s:%u, ERROR\n", __func__, __LINE__);
|
bmlite_on_error(BMLITE_ERROR_CALIBRATE_DELETE, bep_result);
|
||||||
return bep_result;
|
return bep_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,7 +511,7 @@ fpc_bep_result_t bep_sensor_wait_for_finger(fpc_com_chain_t *chain, uint16_t tim
|
|||||||
|
|
||||||
bep_result = send_command(chain, CMD_WAIT, ARG_FINGER_DOWN, NULL, 0);
|
bep_result = send_command(chain, CMD_WAIT, ARG_FINGER_DOWN, NULL, 0);
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("%s:%u, ERROR\n", __func__, __LINE__);
|
bmlite_on_error(BMLITE_ERROR_FINGER_WAIT, bep_result);
|
||||||
return bep_result;
|
return bep_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,7 +525,7 @@ fpc_bep_result_t bep_sensor_wait_finger_not_present(fpc_com_chain_t *chain, uint
|
|||||||
|
|
||||||
bep_result = send_command(chain, CMD_WAIT, ARG_FINGER_UP, NULL, 0);
|
bep_result = send_command(chain, CMD_WAIT, ARG_FINGER_UP, NULL, 0);
|
||||||
if (bep_result != FPC_BEP_RESULT_OK) {
|
if (bep_result != FPC_BEP_RESULT_OK) {
|
||||||
log_error("%s:%u, ERROR\n", __func__, __LINE__);
|
bmlite_on_error(BMLITE_ERROR_FINGER_WAIT, bep_result);
|
||||||
return bep_result;
|
return bep_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -35,6 +35,59 @@
|
|||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
// #include "fpc_hal_interfaces.h"
|
// #include "fpc_hal_interfaces.h"
|
||||||
|
|
||||||
|
void bmlite_on_error(bmlite_error_t error, int32_t value)
|
||||||
|
{
|
||||||
|
if(value != FPC_BEP_RESULT_TIMEOUT) {
|
||||||
|
platform_set_led(3);
|
||||||
|
platform_timebase_busy_wait(500);
|
||||||
|
platform_set_led(0);
|
||||||
|
platform_timebase_busy_wait(500);
|
||||||
|
platform_set_led(3);
|
||||||
|
platform_timebase_busy_wait(500);
|
||||||
|
platform_set_led(0);
|
||||||
|
platform_timebase_busy_wait(500);
|
||||||
|
} else {
|
||||||
|
platform_set_led(3);
|
||||||
|
platform_timebase_busy_wait(100);
|
||||||
|
platform_set_led(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// void bmlite_on_start_capture();
|
||||||
|
// void bmlite_on_finish_capture();
|
||||||
|
|
||||||
|
void bmlite_on_finish_enroll()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void bmlite_on_start_enroll()
|
||||||
|
{
|
||||||
|
platform_set_led(1);
|
||||||
|
platform_timebase_busy_wait(500);
|
||||||
|
platform_set_led(2);
|
||||||
|
platform_timebase_busy_wait(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bmlite_on_start_enrollcapture()
|
||||||
|
{
|
||||||
|
platform_set_led(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bmlite_on_finish_enrollcapture()
|
||||||
|
{
|
||||||
|
platform_set_led(0);
|
||||||
|
platform_timebase_busy_wait(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bmlite_on_identify_start()
|
||||||
|
{
|
||||||
|
platform_set_led(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// void bmlite_on_identify_finish();
|
||||||
|
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
int baudrate = 4000000;
|
int baudrate = 4000000;
|
||||||
@ -71,12 +124,8 @@ int main (int argc, char **argv)
|
|||||||
// nothing hapened
|
// nothing hapened
|
||||||
} else if (btn_time < 5000) {
|
} else if (btn_time < 5000) {
|
||||||
// Enroll
|
// Enroll
|
||||||
platform_set_led(BMLITE_LED_STATUS_STARTENROLL);
|
|
||||||
platform_timebase_busy_wait(500);
|
|
||||||
res = bep_enroll_finger(&hcp_chain);
|
res = bep_enroll_finger(&hcp_chain);
|
||||||
res = bep_save_template(&hcp_chain, current_id++);
|
res = bep_save_template(&hcp_chain, current_id++);
|
||||||
platform_set_led(BMLITE_LED_STATUS_STARTENROLL);
|
|
||||||
platform_timebase_busy_wait(500);
|
|
||||||
} else {
|
} else {
|
||||||
// Erase All templates
|
// Erase All templates
|
||||||
platform_set_led(BMLITE_LED_STATUS_DELETE_TEMPLATES);
|
platform_set_led(BMLITE_LED_STATUS_DELETE_TEMPLATES);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user