-int CmdLFPCF7931Config(const char *Cmd)
-{
- int res = 0;
- // res = sscanf(Cmd,
- // "%02x %02x %hu %hu %hu %hu %hu %hhu %hd %hd",
- // &configPcf.password[0],
- // &configPcf.password[1],
- // &configPcf.password[2],
- // &configPcf.password[3],
- // &configPcf.password[4],
- // &configPcf.password[5],
- // &configPcf.password[6],
- // &configPcf.init_delay,
- // &configPcf.offset[0],
- // &configPcf.offset[1]);
-
- if (res >= 7 || res < 1){
- if(res == 7) configPcf.init_delay = 17500; //default value
-
- if(res<=8){
- configPcf.offset[0] = 0; //default value
- configPcf.offset[1] = 0; //default value
- }
-
- if(res < 1){
- PrintAndLog("Usage: <password byte 1 (in hex, lsb first)> <password byte 2 (in hex, lsb first)> [...] <password byte 7 (in hex, lsb first)> <tag initialization delay (in us)> <optional : offset on the low pulses width (in us)> <optional : offset on the low pulses position (in us)>");
- PrintAndLog("The time offsets could be usefull to correct slew rate generated by the antenna.");
- }
-
- PrintAndLog("Current configuration :");
- PrintAndLog("Password (LSB first on each byte) : %02x %02x %02x %02x %02x %02x %02x", configPcf.password[0], configPcf.password[1], configPcf.password[2], configPcf.password[3], configPcf.password[4], configPcf.password[5], configPcf.password[6]);
- PrintAndLog("Tag initialization delay : %d us", configPcf.init_delay);
- PrintAndLog("Offsets : %d us on the low pulses width, %d us on the low pulses positions", configPcf.offset[0], configPcf.offset[1]);
-
- return 0;
- }
-
- //default values
- configPcf.password[0] = 0xFF;
- configPcf.password[1] = 0xFF;
- configPcf.password[2] = 0xFF;
- configPcf.password[3] = 0xFF;
- configPcf.password[4] = 0xFF;
- configPcf.password[5] = 0xFF;
- configPcf.password[6] = 0xFF;
-
- configPcf.init_delay = 17500;
- configPcf.offset[0] = 0;
- configPcf.offset[1] = 0;
-
- PrintAndLog("Incorrect format");
- PrintAndLog("Examples of right usage : lf pcf7931 config 11 22 33 44 55 66 77 20000");
- PrintAndLog(" lf pcf7931 config FF FF FF FF FF FF FF 17500 -10 30");
- return 0;
+int CmdLFPCF7931Config(const char *Cmd){
+
+ uint8_t ctmp = param_getchar(Cmd, 0);
+ if ( ctmp == 0) return pcf7931_printConfig();
+ if ( ctmp == 'H' || ctmp == 'h' ) return usage_pcf7931_config();
+ if ( ctmp == 'R' || ctmp == 'r' ) return pcf7931_resetConfig();
+
+ if ( param_gethex(Cmd, 0, configPcf.Pwd, 14) ) return usage_pcf7931_config();
+
+ configPcf.InitDelay = (param_get32ex(Cmd,1,0,10) & 0xFFFF);
+ configPcf.OffsetWidth = (int)(param_get32ex(Cmd,2,0,10) & 0xFFFF);
+ configPcf.OffsetPosition = (int)(param_get32ex(Cmd,3,0,10) & 0xFFFF);
+
+ pcf7931_printConfig();
+ return 0;