]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - client/cmdlfnexwatch.c
d44c2a276205ff30c48be2da64ae6f14738a298c
1 //-----------------------------------------------------------------------------
3 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
4 // at your option, any later version. See the LICENSE.txt file for the text of
6 //-----------------------------------------------------------------------------
7 // Low frequency Honeywell NexWatch tag commands
8 // PSK1 RF/16, RF/2, 128 bits long (known)
9 //-----------------------------------------------------------------------------
11 #include "cmdlfnexwatch.h"
21 #include "cmdparser.h"
26 static int CmdHelp(const char *Cmd
);
28 int CmdPSKNexWatch(const char *Cmd
)
30 if (!PSKDemod("", false)) return 0;
31 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};
32 size_t startIdx
= 0, size
= DemodBufferLen
;
34 if (!preambleSearch(DemodBuffer
, preamble
, sizeof(preamble
), &size
, &startIdx
)){
35 // if didn't find preamble try again inverting
36 if (!PSKDemod("1", false)) return 0;
37 size
= DemodBufferLen
;
38 if (!preambleSearch(DemodBuffer
, preamble
, sizeof(preamble
), &size
, &startIdx
)) return 0;
41 if (size
!= 128) return 0;
42 setDemodBuf(DemodBuffer
, size
, startIdx
+4);
43 setClockGrid(g_DemodClock
, g_DemodStartIdx
+ ((startIdx
+4)*g_DemodClock
));
44 startIdx
= 8+32; // 8 = preamble, 32 = reserved bits (always 0)
47 for (uint8_t wordIdx
=0; wordIdx
<4; wordIdx
++){
48 for (uint8_t idx
=0; idx
<8; idx
++){
49 ID
= (ID
<< 1) | DemodBuffer
[startIdx
+wordIdx
+(idx
*4)];
54 //checksum check (TBD)
57 PrintAndLog("NexWatch ID: %d", ID
);
59 PrintAndLog("Had to Invert - probably NexKey");
60 for (uint8_t idx
=0; idx
<size
; idx
++)
61 DemodBuffer
[idx
] ^= 1;
64 CmdPrintDemodBuff("x");
69 //see ASKDemod for what args are accepted
70 int CmdNexWatchRead(const char *Cmd
) {
73 // demod and output viking ID
74 return CmdPSKNexWatch(Cmd
);
77 static command_t CommandTable
[] = {
78 {"help", CmdHelp
, 1, "This help"},
79 {"demod", CmdPSKNexWatch
, 1, "Demodulate a NexWatch tag (nexkey, quadrakey) from the GraphBuffer"},
80 {"read", CmdNexWatchRead
, 0, "Attempt to Read and Extract tag data from the antenna"},
84 int CmdLFNexWatch(const char *Cmd
) {
85 CmdsParse(CommandTable
, Cmd
);
89 int CmdHelp(const char *Cmd
) {
90 CmdsHelp(CommandTable
);