+
+ // strip
+ while (*cmd==' ' || *cmd=='\t') cmd++;
+
+ while (cmd[i]!='\0') {
+ if (cmd[i]==' ' || cmd[i]=='\t') { i++; continue; }
+ if (cmd[i]=='-') {
+ switch (cmd[i + 1]) {
+ case 's':
+ case 'S':
+ activateField = true;
+ break;
+ case 'k':
+ case 'K':
+ leaveSignalON = true;
+ break;
+ case 't':
+ case 'T':
+ decodeTLV = true;
+ break;
+ default:
+ PrintAndLog("Invalid option");
+ return 1;
+ }
+ i += 2;
+ continue;
+ }
+ if ((cmd[i] >= '0' && cmd[i] <= '9') ||
+ (cmd[i] >= 'a' && cmd[i] <= 'f') ||
+ (cmd[i] >= 'A' && cmd[i] <= 'F') ) {
+ buf[strlen(buf) + 1] = 0x00;
+ buf[strlen(buf)] = cmd[i];
+ i++;
+
+ if (strlen(buf) >= 2) {
+ sscanf(buf, "%x", &temp);
+ data[datalen] = (uint8_t)(temp & 0xff);
+ *buf = 0;
+ if (datalen > sizeof(data) - 2) {
+ PrintAndLog("Buffer is full...");
+ break;
+ } else {
+ datalen++;
+ }
+ }
+ continue;
+ }
+ PrintAndLog("Invalid char on input");
+ return 1;
+ }
+ if (*buf) {
+ PrintAndLog("Hex must have even number of digits. Detected %d symbols.", datalen * 2 + strlen(buf));
+ return 1;
+ }