+ if ((buf[1] == 'p') || (buf[1] == 't')) // tsculfw: ping or set timestamp command echoed?
+ return 0;
+
+ if (buf[1] == '?') {// tsculfw: unknown command
+ fprintf(stderr, "unknown ASKSIN command sent\n");
+ return 0;
+ }
+
+ if (buf[1] == 'F') { // tsculfw: timestamp message?
+ rdata->is_TSCUL = 1;
+ if (buf_len <= (3+14)) // tsculfw: reasonable len?
+ return 0;
+ if (!validate_nibble(buf[3]) || !validate_nibble(buf[4])) // tsculfw: hex?
+ return 0;
+
+ rdata->credits = ascii_to_nibble(buf[3]); // tsculfw: coarse credits info, 0 = full credits (1800 x10ms) available
+
+ //AFF1B000053A1010F0520CB1122334BD57110
+ switch(ascii_to_nibble(buf[4]) & 0x7) { // tsculfw: message type?
+ case 0: // tsculfw: send fail message repeat fail or AES Auth error
+ fprintf(stderr, "send didn't complete, repeat fail or AES Auth error\n");
+ return 0;
+ case 1: // tsculfw: received message
+ rpos += 7; // tsculfw: ignore timestamp data for now
+ break;
+ case 2: // tsculfw: ping answer
+ return 0;
+ case 3: // tsculfw: send success
+ rdata->message_type = MESSAGE_TYPE_B;
+ return 0;
+ case 4: // tsculfw: send fail channel busy message
+ fprintf(stderr, "CCA didn't complete, too much traffic\n");
+ return 0;
+ case 5: // tsculfw: send fail credits message
+ fprintf(stderr, "send didn't complete, not enough credits left\n");
+ return 0;
+ case 6: // tsculfw: send timestamp fail message no buffer or send message length error
+ fprintf(stderr, "send didn't complete, not enough credits left -> wait 30 minutes with TSCUL powered and not reset\n");
+ return 0;
+ case 7: // tsculfw: send fail due to cc1101 TX-FIFO underflow error message
+ fprintf(stderr, "send didn't complete, cc1101 TX-FIFO underflow\n");
+ return 0;
+ default:
+ break;
+ }
+ }
+
+ while(validate_nibble(buf[(rpos * 2) + 1]) &&
+ validate_nibble(buf[(rpos * 2) + 2]) &&
+ (rpos + 1 < buf_len)) {
+ rdata->message[pos] = ascii_to_nibble(buf[(rpos * 2) + 1]) << 4;
+ rdata->message[pos] |= ascii_to_nibble(buf[(rpos * 2) + 2]);