mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
make style
This commit is contained in:
parent
0d9223a547
commit
0373696662
483 changed files with 56514 additions and 52451 deletions
|
@ -12,16 +12,17 @@
|
|||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
int detectNexWatch(uint8_t *dest, size_t *size, bool *invert) {
|
||||
int detectNexWatch(uint8_t *dest, size_t *size, bool *invert)
|
||||
{
|
||||
|
||||
uint8_t preamble[28] = {0,0,0,0,0,1,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
uint8_t preamble_i[28] = {1,1,1,1,1,0,1,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
|
||||
uint8_t preamble[28] = {0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
uint8_t preamble_i[28] = {1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
// sanity check.
|
||||
if ( *size < sizeof(preamble) + 100) return -1;
|
||||
if (*size < sizeof(preamble) + 100) return -1;
|
||||
|
||||
size_t startIdx = 0;
|
||||
|
||||
if (!preambleSearch(DemodBuffer, preamble, sizeof(preamble), size, &startIdx)){
|
||||
if (!preambleSearch(DemodBuffer, preamble, sizeof(preamble), size, &startIdx)) {
|
||||
// if didn't find preamble try again inverting
|
||||
if (!preambleSearch(DemodBuffer, preamble_i, sizeof(preamble_i), size, &startIdx)) return -4;
|
||||
*invert ^= 1;
|
||||
|
@ -31,7 +32,8 @@ int detectNexWatch(uint8_t *dest, size_t *size, bool *invert) {
|
|||
return (int) startIdx;
|
||||
}
|
||||
|
||||
int CmdNexWatchDemod(const char *Cmd) {
|
||||
int CmdNexWatchDemod(const char *Cmd)
|
||||
{
|
||||
|
||||
if (!PSKDemod("", false)) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - NexWatch can't demod signal");
|
||||
|
@ -41,32 +43,32 @@ int CmdNexWatchDemod(const char *Cmd) {
|
|||
size_t size = DemodBufferLen;
|
||||
int idx = detectNexWatch(DemodBuffer, &size, &invert);
|
||||
if (idx <= 0) {
|
||||
if (idx == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - NexWatch not enough samples");
|
||||
// else if (idx == -2)
|
||||
// PrintAndLogEx(DEBUG, "DEBUG: Error - NexWatch only noise found");
|
||||
// else if (idx == -3)
|
||||
// PrintAndLogEx(DEBUG, "DEBUG: Error - NexWatch problem during PSK demod");
|
||||
else if (idx == -4)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - NexWatch preamble not found");
|
||||
// else if (idx == -5)
|
||||
// PrintAndLogEx(DEBUG, "DEBUG: Error - NexWatch size not correct: %d", size);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - NexWatch error %d",idx);
|
||||
if (idx == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - NexWatch not enough samples");
|
||||
// else if (idx == -2)
|
||||
// PrintAndLogEx(DEBUG, "DEBUG: Error - NexWatch only noise found");
|
||||
// else if (idx == -3)
|
||||
// PrintAndLogEx(DEBUG, "DEBUG: Error - NexWatch problem during PSK demod");
|
||||
else if (idx == -4)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - NexWatch preamble not found");
|
||||
// else if (idx == -5)
|
||||
// PrintAndLogEx(DEBUG, "DEBUG: Error - NexWatch size not correct: %d", size);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - NexWatch error %d", idx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
setDemodBuf(DemodBuffer, size, idx+4);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + ((idx+4)*g_DemodClock));
|
||||
setDemodBuf(DemodBuffer, size, idx + 4);
|
||||
setClockGrid(g_DemodClock, g_DemodStartIdx + ((idx + 4)*g_DemodClock));
|
||||
|
||||
idx = 8+32; // 8 = preamble, 32 = reserved bits (always 0)
|
||||
idx = 8 + 32; // 8 = preamble, 32 = reserved bits (always 0)
|
||||
|
||||
//get ID
|
||||
uint32_t ID = 0;
|
||||
for (uint8_t k = 0; k < 4; k++){
|
||||
for (uint8_t m = 0; m < 8; m++){
|
||||
ID = (ID << 1) | DemodBuffer[m + k + (m*4)];
|
||||
for (uint8_t k = 0; k < 4; k++) {
|
||||
for (uint8_t m = 0; m < 8; m++) {
|
||||
ID = (ID << 1) | DemodBuffer[m + k + (m * 4)];
|
||||
}
|
||||
}
|
||||
//parity check (TBD)
|
||||
|
@ -75,7 +77,7 @@ int CmdNexWatchDemod(const char *Cmd) {
|
|||
|
||||
//output
|
||||
PrintAndLogEx(NORMAL, "NexWatch ID: %d", ID);
|
||||
if (invert){
|
||||
if (invert) {
|
||||
PrintAndLogEx(NORMAL, "Had to Invert - probably NexKey");
|
||||
for (size_t i = 0; i < size; i++)
|
||||
DemodBuffer[i] ^= 1;
|
||||
|
@ -87,7 +89,8 @@ int CmdNexWatchDemod(const char *Cmd) {
|
|||
|
||||
//by marshmellow
|
||||
//see ASKDemod for what args are accepted
|
||||
int CmdNexWatchRead(const char *Cmd) {
|
||||
int CmdNexWatchRead(const char *Cmd)
|
||||
{
|
||||
lf_read(true, 10000);
|
||||
return CmdNexWatchDemod(Cmd);
|
||||
}
|
||||
|
@ -99,13 +102,15 @@ static command_t CommandTable[] = {
|
|||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
int CmdLFNEXWATCH(const char *Cmd) {
|
||||
int CmdLFNEXWATCH(const char *Cmd)
|
||||
{
|
||||
clearCommandBuffer();
|
||||
CmdsParse(CommandTable, Cmd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdHelp(const char *Cmd) {
|
||||
int CmdHelp(const char *Cmd)
|
||||
{
|
||||
CmdsHelp(CommandTable);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue