exit(1);
}
+void do_open_channel(uchar chan, int net) {
+ int chtype = 0; // wildcard
+ int devno = 0; // wildcard
+ int devtype = 1; // wildcard
+ int manid = 5; // wildcard
+ int freq = 0x32; // garmin specific radio frequency
+ int srchto = 255; // max timeout
+ int waveform = 0x0053; // aids search somehow
+
+ ANT_CloseChannel(chan);
+ ANT_AssignChannel(chan, chtype, net);
+ // Wali: changed order of the following seq. according windows
+ ANT_SetChannelPeriod(chan, period);
+ ANT_SetChannelSearchTimeout(chan, srchto);
+ //ANT_RequestMessage(chan, MESG_CAPABILITIES_ID); //informative
+ ANT_SetChannelRFFreq(chan, freq);
+ ANT_SetSearchWaveform(chan, waveform);
+ ANT_SetChannelId(chan, devno, devtype, manid);
+ ANT_OpenChannel(chan);
+ ANT_RequestMessage(chan, MESG_CHANNEL_STATUS_ID); //informative
+}
+
void
-start_download(uchar chan, int fileno)
+start_download(uchar chan, int fileno, int offset, int crcseed)
{
- char getfilepkt[100];
- sprintf(getfilepkt, "4409%02x00000000000001000000000000", fileno);
- ANT_SendBurstTransferA(chan, getfilepkt, strlen(getfilepkt)/16);
+ uchar getfilepkt[100];
+
+ (void)chan;(void)fileno;(void)getfilepkt;
+
+ dl_s_fn = fileno;
+ dl_s_offset = offset;
+ dl_s_crc = crcseed;
+
+ sprintf((char*)getfilepkt, "4409%02x%02x%02x%02x%02x%02x" "00%02x%02x%02x00000000",
+ (fileno&0xff),
+ (fileno>>8)&0xff,
+ offset & 0xff,
+ (offset >> 8) & 0xff,
+ (offset >> 16) & 0xff,
+ (offset >> 24) & 0xff,
+ (offset == 0 ? 1 : 0),
+ crcseed & 0xff,
+ (crcseed >> 8) & 0xff);
+ printf("starting download: %s\n", getfilepkt);
+ ANT_SendBurstTransferA(chan, getfilepkt, strlen((char*)getfilepkt)/16);
+}
+
+void
+retry_transfer(uchar chan) {
+ start_download(chan, dl_s_fn, dl_s_offset, dl_s_crc);
}
size_t
-format_time(char* s, size_t max, time_t tm)
+format_time(char* s, char *format, size_t max, time_t tm)
{
time_t unix_tm = tm + 631065600;
struct tm local_tm;
localtime_r(&unix_tm, &local_tm);
- return strftime(s, max, "%c", &local_tm);
+ return strftime(s, max, format, &local_tm);
}
void
assert(sizeof(struct antfs_dir_header) == ANTFSHEADERSIZE);
memcpy(&hdr, blast + 24, ANTFSHEADERSIZE);
- printf("system time: %d\n", hdr.system_time);
- format_time(textual_time, 256, hdr.real_time);
+ printf("system time: %d\n", hdr.system_time);
+ format_time(textual_time, "%c", 256, hdr.real_time);
printf("real time: %d (%s)\n", hdr.real_time, textual_time);
antfsdir_used = 0;
if (dbg) printf("unexpected ant-fs packet: header says %d bytes, but received %d\n", size, blsize - 24);
exit(1);
}
- sprintf(filename, "antfs-dump.%d", antfsdir[downloadingfilenum].fileno);
- storefd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644);
+ format_time(ts, "%F.%H.%M.%S", 256, antfsdir[downloadingfilenum].last_modified);
+ sprintf(filename, "antfs-dump.%s.fit", ts);
+ storefd = open(filename, O_WRONLY | O_CREAT, 0644);
if (storefd < 0) {
perror(filename);
exit(1);