Added DTMF_FindContact.

This commit is contained in:
Dual Tachyon 2023-08-22 00:12:10 +01:00
parent db2e9686ea
commit 2e28b98e51
2 changed files with 27 additions and 0 deletions

26
dtmf.c
View File

@ -15,6 +15,7 @@
*/
#include <ctype.h>
#include <string.h>
#include "driver/eeprom.h"
#include "dtmf.h"
@ -50,3 +51,28 @@ bool DTMF_GetContact(uint8_t Index, char *pContact)
return true;
}
bool DTMF_FindContact(const char *pContact, char *pResult)
{
char Contact [16];
uint8_t i, j;
for (i = 0; i < 16; i++) {
if (!DTMF_GetContact(i, Contact)) {
return false;
}
for (j = 0; j < 3; j++) {
if (pContact[j] != Contact[j + 8]) {
break;
}
}
if (j == 3) {
memcpy(pResult, Contact, 8);
pResult[8] = 0;
return true;
}
}
return false;
}

1
dtmf.h
View File

@ -24,6 +24,7 @@ extern char gDTMF_String[15];
bool DTMF_ValidateCodes(char *pCode, uint8_t Size);
bool DTMF_GetContact(uint8_t Index, char *pContact);
bool DTMF_FindContact(const char *pContact, char *pResult);
#endif