fprintf(stderr, "%02x", cbuf[i]);
fprintf(stderr, "\n");
}
-
+
switch (event) {
case EVENT_RX_BROADCAST: {
uchar status = cbuf[1] & 0xd7;
uchar newdata = cbuf[1] & 0x20;
uchar phase = cbuf[2];
- if (memcmp(cbuf, "FR60\0\0\0\0", 8) == 0) {
- if (dbg) printf("device identifies as an FR60\n");
+ if (memcmp(cbuf, "310XT\0\0\0\0", 8) == 0) {
+ D("device identifies as an 310XT\n");
+ break;
+ } else if (memcmp(cbuf, "FR60\0\0\0\0", 8) == 0) {
+ D("device identifies as an FR60\n");
break;
}
+
lastphase = phase; // store the last phase we see the watch broadcast
D("lastphase %d\n", lastphase);
if (!pairing && !nopairing)
start_download(chan, antfsdir[downloadingfilenum].fileno);
}
break;
+ case EVENT_TRANSFER_TX_FAILED:
+ fprintf(stderr, "TX Transfer failed %d\n", ebuf[1]);
+ exit(1);
+ break;
case INVALID_MESSAGE:
printf("Invalid message %02x\n", ebuf[1]);
break;
fprintf(stderr, "\n");
break;
case MESG_CAPABILITIES_ID:
- if (dbg)
- printf("capabilities chans %d nets %d opt %02x adv %02x\n",
+ D("capabilities chans %d nets %d opt %02x adv %02x\n",
ebuf[0], ebuf[1], ebuf[2], ebuf[3]);
break;
case MESG_CHANNEL_STATUS_ID:
- if (dbg)
- printf("channel status %d\n", ebuf[1]);
+ D("channel status %d\n", ebuf[1]);
break;
case EVENT_RX_FAIL:
+ D("EVENT_RX_FAIL\n");
// ignore this
// TODO: this could be an indication the transfer has
// failed. handle here or time out?
break;
+ case EVENT_STARTUP_MESSAGE:
+ fprintf(stderr, "startup: %s%s%s%s%s%s",
+ ebuf[0] == 0 ? "power_on_reset" : "",
+ ebuf[0] & (1 << 0) ? "hw_reset_line" : "",
+ ebuf[0] & (1 << 1) ? "watch_dog_reset" : "",
+ ebuf[0] & (1 << 5) ? "command_reset" : "",
+ ebuf[0] & (1 << 6) ? "synchronous_reset" : "",
+ ebuf[0] & (1 << 7) ? "suspend_reset" : "");
+ fprintf(stderr, "\n");
+ break;
+ case EVENT_RX_SEARCH_TIMEOUT:
+ fprintf(stderr, "Search timed out, reopening channel");
+ exit(1);
+ do_open_channel(chan, 0);
+ break;
+
+ case EVENT_RX_FAIL_GO_TO_SEARCH:
+ fprintf(stderr, "Channel dropped to search mode after missing too many messages\n");
+ devid = sentid = 0; // reset
+ exit(1);
+ break;
+ case EVENT_CHANNEL_CLOSED:
+ D("Channel %d closed, ignoring\n", chan);
+ break;
default:
printf("Unhandled response event %02x\n", event);
break;