/*
 *
 * */
#include <Arduino.h>

#ifndef COMMANDS_H_
#define COMMANDS_H_

// RESPONSE CODES
const uint8_t SUCCESS = 0x00;                // Command dispose success
const uint8_t ERR_FAIL = 0x01;               // Command dispose failed
const uint8_t ERR_VERIFY = 0x10;             // 1:1 match failed with appointed ID Template .
const uint8_t ERR_IDENTIFY = 0x11;           // 1:N match，but no the same Template .
const uint8_t ERR_TMPL_EMPTY = 0x12;         // No enrolled Template in appointed ID.
const uint8_t ERR_TMPL_NOT_EMPTY = 0x13;     // With template data in appointed ID.
const uint8_t ERR_ALL_TMPL_EMPTY = 0x14;     // NO any enrolled template data
const uint8_t ERR_EMPTY_ID_NOEXIST = 0x15;   // No valid for enroll Template ID .
const uint8_t ERR_BROKEN_ID_NOEXIST = 0x16;  // No broken Template.
const uint8_t ERR_INVALID_TMPL_DATA = 0x17;  // Appointed template Data invalid.
const uint8_t ERR_DUPLICATION_ID = 0x18;     // This fingerprint have been enrolled.
const uint8_t ERR_BAD_QUALITY = 0x19;        //  Fingerprint image lower quality .
const uint8_t ERR_MERGE_FAIL = 0x1A;         //  Template merge failed.
const uint8_t ERR_MEMORY = 0x1C;             //  Memory error .
const uint8_t ERR_INVALID_TMPL_NO = 0x1D;    //  Template ID No. that appointed is invalid.
const uint8_t ERR_INVALID_PARAM = 0x22;      // Use wrong parameters .
const uint8_t ERR_GEN_COUNT = 0x25;          //  Count of template merge is invalid.
const uint8_t ERR_INVALID_BUFFER_ID = 0x26;  //  Buffer ID No. is wrong
const uint8_t ERR_FP_NOT_DETECTED = 0x28;    // No fingerprint in sensor .
const uint8_t ERR_TIME_OUT = 0x23;           // No finger is detected in the period of FP TimeOut
const uint8_t ERR_FP_CANCEL = 0x41;          // Current operation is cancelled
const uint8_t RESPONSE_COMMAND_LSB = 0x08;   // position
const uint8_t DETECT_FINGER_RESPONSE = 0x0A; // 0-no finger, 1-finger on sensor

// COMMANDS
const uint16_t CMD_TEST_CONNECTION = 0x0001;  // For test the communication to device
const uint16_t CMD_SET_PARAM = 0x0002;        // Set parameter (Device ID, Security Level, BP S, Duplication Check ,Auto Learn)
const uint16_t CMD_GET_PARAM = 0x0003;        // Get parameter (Device ID, Security Level, BPS, Duplication Check, Auto Learn)
const uint16_t CMD_GET_DEVICE_INFO = 0x0004;  // Get device information
const uint16_t CMD_ENTER_IAP_MODE = 0x0005;   // Set device to IAP mode
const uint16_t CMD_GET_IMAGE = 0x0020;        // Capture the fingerprint image and save to ImageBuffer
const uint16_t CMD_FINGER_DETECT = 0x0021;    // Detect the fingerprint input state
const uint16_t CMD_UP_IMAGE = 0x0022;         // Upload the fingerprint image data in ImageBuffer to HOST
const uint16_t CMD_DOWN_IMAGE = 0x0023;       // Download the fingerprint image to module and save in ImageBuffer
const uint16_t CMD_STORE_CHAR = 0x0040;       // Save the template data that storage in Ram Buffer into Flash Memory
const uint16_t CMD_LOAD_CHAR = 0x0041;        // Save the template data that storage in flash memory into Ram Buffer
const uint16_t CMD_UP_CHAR = 0x0042;          // Upload the template data that storage in appointed Ram Buffer to HOST
const uint16_t CMD_DOWN_CHAR = 0x0043;        // Download the template data to appointed Ram Buffer in module
const uint16_t CMD_DEL_CHAR = 0x0044;         // Appointed an range in DB and then delete all template data in the range
const uint16_t CMD_GET_EMPTY_ID = 0x0045;     // appointed an range and get the first ID number which is unappropriated in the range
const uint16_t CMD_GET_STATUS = 0x0046;       // Get the appointed ID number whether is available
const uint16_t CMD_GET_BROKEN_ID = 0x0047;    // Check all the template data whether or not broken in the appointed range
const uint16_t CMD_GET_ENROLL_COUNT = 0x0048; // Get the count of enrolled template in appointed range
const uint16_t CMD_GENERATE = 0x0060;         // Generate template data from fingerprint image that saved in ImageBuffer and then save to appointed Ram Buffer
const uint16_t CMD_MERGE = 0x0061;            // Compose two or three template that saved in Ram Buffer and then generate ultimate template data
const uint16_t CMD_MATCH = 0x0062;            // 1:1 match, match between two templates that appointed in Ram Buffer
const uint16_t CMD_SEARCH = 0x0063;           // 1:N identify ,an template in Ram Buffer match to all template that appointed range in DB
const uint16_t CMD_VERIFY = 0x0064;           // 1:1 match, an template in Ram Buffer match with an template in DB
const uint16_t CMD_SET_MODULE_SN = 0x0008;    // Set the Module SN from Host and to Module ; Note: Temporarily does not support
const uint16_t CMD_GET_MODULE_SN = 0x0009;    // Get the Module SN from module to Host ; Note: Temporarily does not support

const uint16_t REGULAR_PACKET_LENGTH = 26; // command and response packets
const uint16_t TEMPLATE_DATA_PACKET_LENGTH = 510; // template + command
#endif
