From 4878895c862f3e147e89bd5eb4f3d2ce7d22784c Mon Sep 17 00:00:00 2001 From: Tollef Fog Heen Date: Sun, 28 Aug 2011 21:32:25 +0200 Subject: [PATCH] More debugging --- fr60.c | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/fr60.c b/fr60.c index c1b8c6f..88fde80 100644 --- a/fr60.c +++ b/fr60.c @@ -336,16 +336,20 @@ chevent(uchar chan, uchar event) 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) @@ -634,6 +638,10 @@ revent(uchar chan, uchar event) 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; @@ -668,19 +676,42 @@ revent(uchar chan, uchar event) 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; -- 2.39.5