]>
git.zerfleddert.de Git - proxmark3-svn/blob - client/cmdlfnexwatch.c
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
9 //-----------------------------------------------------------------------------
14 #include "cmdlfnexwatch.h"
15 #include "proxmark3.h"
19 #include "cmdparser.h"
24 static int CmdHelp(const char *Cmd
);
26 int CmdPSKNexWatch(const char *Cmd
)
28 if (!PSKDemod("", false)) return 0;
29 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};
30 size_t startIdx
= 0, size
= DemodBufferLen
;
32 if (!preambleSearch(DemodBuffer
, preamble
, sizeof(preamble
), &size
, &startIdx
)){
33 // if didn't find preamble try again inverting
34 if (!PSKDemod("1", false)) return 0;
35 size
= DemodBufferLen
;
36 if (!preambleSearch(DemodBuffer
, preamble
, sizeof(preamble
), &size
, &startIdx
)) return 0;
39 if (size
!= 128) return 0;
40 setDemodBuf(DemodBuffer
, size
, startIdx
+4);
41 startIdx
= 8+32; //4 = extra i added, 8 = preamble, 32 = reserved bits (always 0)
44 for (uint8_t wordIdx
=0; wordIdx
<4; wordIdx
++){
45 for (uint8_t idx
=0; idx
<8; idx
++){
46 ID
= (ID
<< 1) | DemodBuffer
[startIdx
+wordIdx
+(idx
*4)];
51 //checksum check (TBD)
54 PrintAndLog("NexWatch ID: %d", ID
);
56 PrintAndLog("Had to Invert - probably NexKey");
57 for (uint8_t idx
=0; idx
<size
; idx
++)
58 DemodBuffer
[idx
] ^= 1;
61 CmdPrintDemodBuff("x");
66 //see ASKDemod for what args are accepted
67 int CmdNexWatchRead(const char *Cmd
) {
70 // get samples silently
71 getSamples("10000",false);
72 // demod and output viking ID
73 return CmdPSKNexWatch(Cmd
);
76 static command_t CommandTable
[] = {
77 {"help", CmdHelp
, 1, "This help"},
78 {"demod", CmdPSKNexWatch
, 1, "Demodulate a NexWatch tag (nexkey, quadrakey) from the GraphBuffer"},
79 {"read", CmdNexWatchRead
, 0, "Attempt to Read and Extract tag data from the antenna"},
83 int CmdLFNexWatch(const char *Cmd
) {
84 CmdsParse(CommandTable
, Cmd
);
88 int CmdHelp(const char *Cmd
) {
89 CmdsHelp(CommandTable
);