Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: R503_fingerprint_HelloWorldV4
Diff: Fingerprint.cpp
- Revision:
- 1:f392aee31272
- Parent:
- 0:35cd316e4b41
- Child:
- 2:6f273d942c43
--- a/Fingerprint.cpp Tue Mar 16 16:31:41 2021 +0000
+++ b/Fingerprint.cpp Wed Mar 17 14:12:47 2021 +0000
@@ -39,7 +39,7 @@
writeStructuredPacket(packet); \
if (getStructuredPacket(&packet) != FINGERPRINT_OK) \
return FINGERPRINT_PACKETRECIEVEERR; \
- if (packet->type != FINGERPRINT_ACKPACKET) \
+ if (packet.type != FINGERPRINT_ACKPACKET) \
return FINGERPRINT_PACKETRECIEVEERR;
/*!
@@ -47,7 +47,7 @@
*/
#define SEND_CMD_PACKET(...) \
GET_CMD_PACKET(__VA_ARGS__); \
- return packet->data[0];
+ return packet.data[0];
/***************************************************************************
PUBLIC FUNCTIONS
@@ -102,7 +102,7 @@
uint8_t Fingerprint::checkPassword(void) {
GET_CMD_PACKET(FINGERPRINT_VERIFYPASSWORD, (uint8_t)(thePassword >> 24),(uint8_t)(thePassword >> 16), (uint8_t)(thePassword >> 8),(uint8_t)(thePassword & 0xFF));
- if (packet->data[0] == FINGERPRINT_OK)
+ if (packet.data[0] == FINGERPRINT_OK)
return FINGERPRINT_OK;
else
return FINGERPRINT_PACKETRECIEVEERR;
@@ -119,14 +119,14 @@
uint8_t Fingerprint::getParameters(void) {
GET_CMD_PACKET(FINGERPRINT_READSYSPARAM);
- status_reg = ((uint16_t)packet->data[1] << 8) | packet->data[2];
- system_id = ((uint16_t)packet->data[3] << 8) | packet->data[4];
- capacity = ((uint16_t)packet->data[5] << 8) | packet->data[6];
- security_level = ((uint16_t)packet->data[7] << 8) | packet->data[8];
- device_addr = ((uint32_t)packet->data[9] << 24) |
- ((uint32_t)packet->data[10] << 16) |
- ((uint32_t)packet->data[11] << 8) | (uint32_t)packet->data[12];
- packet_len = ((uint16_t)packet->data[13] << 8) | packet->data[14];
+ status_reg = ((uint16_t)packet.data[1] << 8) | packet.data[2];
+ system_id = ((uint16_t)packet.data[3] << 8) | packet.data[4];
+ capacity = ((uint16_t)packet.data[5] << 8) | packet.data[6];
+ security_level = ((uint16_t)packet.data[7] << 8) | packet.data[8];
+ device_addr = ((uint32_t)packet.data[9] << 24) |
+ ((uint32_t)packet.data[10] << 16) |
+ ((uint32_t)packet.data[11] << 8) | (uint32_t)packet.data[12];
+ packet_len = ((uint16_t)packet.data[13] << 8) | packet.data[14];
if (packet_len == 0) {
packet_len = 32;
} else if (packet_len == 1) {
@@ -136,9 +136,9 @@
} else if (packet_len == 3) {
packet_len = 256;
}
- baud_rate = (((uint16_t)packet->data[15] << 8) | packet->data[16]) * 9600;
+ baud_rate = (((uint16_t)packet.data[15] << 8) | packet.data[16]) * 9600;
- return packet->data[0];
+ return packet.data[0];
}
/**************************************************************************/
@@ -266,15 +266,15 @@
fingerID = 0xFFFF;
confidence = 0xFFFF;
- fingerID = packet->data[1];
+ fingerID = packet.data[1];
fingerID <<= 8;
- fingerID |= packet->data[2];
+ fingerID |= packet.data[2];
- confidence = packet->data[3];
+ confidence = packet.data[3];
confidence <<= 8;
- confidence |= packet->data[4];
+ confidence |= packet.data[4];
- return packet->data[0];
+ return packet.data[0];
}
/**************************************************************************/
@@ -329,15 +329,15 @@
fingerID = 0xFFFF;
confidence = 0xFFFF;
- fingerID = packet->data[1];
+ fingerID = packet.data[1];
fingerID <<= 8;
- fingerID |= packet->data[2];
+ fingerID |= packet.data[2];
- confidence = packet->data[3];
+ confidence = packet.data[3];
confidence <<= 8;
- confidence |= packet->data[4];
+ confidence |= packet.data[4];
- return packet->data[0];
+ return packet.data[0];
}
/**************************************************************************/
@@ -351,11 +351,11 @@
uint8_t Fingerprint::getTemplateCount(void) {
GET_CMD_PACKET(FINGERPRINT_TEMPLATECOUNT);
- templateCount = packet->data[1];
+ templateCount = packet.data[1];
templateCount <<= 8;
- templateCount |= packet->data[2];
+ templateCount |= packet.data[2];
- return packet->data[0];
+ return packet.data[0];
}
/**************************************************************************/
@@ -382,46 +382,46 @@
void Fingerprint::writeStructuredPacket(const Fingerprint_Packet &packet)
{
- R503Serial.putc((uint8_t)(packet->start_code >> 8));
- R503Serial.putc((uint8_t)(packet->start_code & 0xFF));
- R503Serial.putc(packet->address[0]);
- R503Serial.putc(packet->address[1]);
- R503Serial.putc(packet->address[2]);
- R503Serial.putc(packet->address[3]);
- R503Serial.putc(packet->type);
+ R503Serial.putc((uint8_t)(packet.start_code >> 8));
+ R503Serial.putc((uint8_t)(packet.start_code & 0xFF));
+ R503Serial.putc(packet.address[0]);
+ R503Serial.putc(packet.address[1]);
+ R503Serial.putc(packet.address[2]);
+ R503Serial.putc(packet.address[3]);
+ R503Serial.putc(packet.type);
- uint16_t wire_length = packet->length + 2;
+ uint16_t wire_length = packet.length + 2;
R503Serial.putc((uint8_t)(wire_length >> 8));
R503Serial.putc((uint8_t)(wire_length & 0xFF));
#ifdef FINGERPRINT_DEBUG
Serial.print(". 0x");
- Serial.print((uint8_t)(packet->start_code >> 8), HEX);
+ Serial.print((uint8_t)(packet.start_code >> 8), HEX);
Serial.print(", 0x");
- Serial.print((uint8_t)(packet->start_code & 0xFF), HEX);
+ Serial.print((uint8_t)(packet.start_code & 0xFF), HEX);
Serial.print(", 0x");
- Serial.print(packet->address[0], HEX);
+ Serial.print(packet.address[0], HEX);
Serial.print(", 0x");
- Serial.print(packet->address[1], HEX);
+ Serial.print(packet.address[1], HEX);
Serial.print(", 0x");
- Serial.print(packet->address[2], HEX);
+ Serial.print(packet.address[2], HEX);
Serial.print(", 0x");
- Serial.print(packet->address[3], HEX);
+ Serial.print(packet.address[3], HEX);
Serial.print(", 0x");
- Serial.print(packet->type, HEX);
+ Serial.print(packet.type, HEX);
Serial.print(", 0x");
Serial.print((uint8_t)(wire_length >> 8), HEX);
Serial.print(", 0x");
Serial.print((uint8_t)(wire_length & 0xFF), HEX);
#endif
- uint16_t sum = ((wire_length) >> 8) + ((wire_length)&0xFF) + packet->type;
- for (uint8_t i = 0; i < packet->length; i++) {
- R503Serial.putc(packet->data[i]);
- sum += packet->data[i];
+ uint16_t sum = ((wire_length) >> 8) + ((wire_length)&0xFF) + packet.type;
+ for (uint8_t i = 0; i < packet.length; i++) {
+ R503Serial.putc(packet.data[i]);
+ sum += packet.data[i];
#ifdef FINGERPRINT_DEBUG
Serial.print(", 0x");
- Serial.print(packet->data[i], HEX);
+ Serial.print(packet.data[i], HEX);
#endif
}