From 35c4b69542a6dcc3b48462e6682848d0c37ff5a2 Mon Sep 17 00:00:00 2001 From: fishsoupisgood Date: Mon, 27 May 2019 03:32:21 +0100 Subject: add 150 support, tidy up 50 support --- master/model-50-v2.patch | 128 +++++++++++++++++++++++++++++++---------------- 1 file changed, 84 insertions(+), 44 deletions(-) (limited to 'master/model-50-v2.patch') diff --git a/master/model-50-v2.patch b/master/model-50-v2.patch index a486300..7951a9f 100644 --- a/master/model-50-v2.patch +++ b/master/model-50-v2.patch @@ -83,7 +83,7 @@ index ab6f2d7..d14eeae 100644 #define DEF_LPTRANSINFO 1 diff --git a/dl_init_watch.c b/dl_init_watch.c -index 9cfc929..9e88500 100644 +index 9cfc929..d6a7408 100644 --- a/dl_init_watch.c +++ b/dl_init_watch.c @@ -62,6 +62,32 @@ WatchInfoPtr dl_init_watch(int type) @@ -114,16 +114,16 @@ index 9cfc929..9e88500 100644 + result->max_wristapp_len = 0; + result->max_mel_len = 0; + result->pre_notification_time = 0; -+ result->time_adjust = 9; ++ result->time_adjust = 2; + break; case DATALINK_70: result->dl_device = type; result->max_tz = 2; diff --git a/dl_send_data.c b/dl_send_data.c -index 3dfa12e..e68904f 100644 +index 3dfa12e..20f4203 100644 --- a/dl_send_data.c +++ b/dl_send_data.c -@@ -27,10 +27,16 @@ +@@ -27,10 +27,15 @@ #include #include #include @@ -132,15 +132,15 @@ index 3dfa12e..e68904f 100644 #include "datalink.h" #include "datalink_private.h" -+#if 0 - #define MAX_PCKT 38 -+#else -+#define MAX_PCKT 32 -+#endif +-#define MAX_PCKT 38 ++#define MAX_PCKT_OTHERS 38 ++#define MAX_PCKT_50 32 ++ ++unsigned max_pckt=MAX_PCKT_OTHERS; #define TIME_70 0x30 #define DSTART_70 0x60 -@@ -53,7 +59,7 @@ static unsigned char datablock2[] = { 0x14, 0x70, 0x02, 0x5a, +@@ -53,7 +58,7 @@ static unsigned char datablock2[] = { 0x14, 0x70, 0x02, 0x5a, 0x47, 0xb7, 0xa9, 0xcc, 0x74, 0x6f, 0x00, 0x00 }; @@ -149,7 +149,22 @@ index 3dfa12e..e68904f 100644 1, 0, 0, 0 }; static unsigned char dstart[] = { 5, 0x93, 0, 0, 0 }; -@@ -94,11 +100,18 @@ int _write_data(int fd, unsigned char *buf, unsigned char *data, int size, +@@ -78,11 +83,11 @@ int _write_data(int fd, unsigned char *buf, unsigned char *data, int size, + { + int bytes_left; + +- while (*buf + size > MAX_PCKT - 2) ++ while (*buf + size > max_pckt - 2) + { +- bytes_left = *buf + size - MAX_PCKT + 2; ++ bytes_left = *buf + size - max_pckt + 2; + memcpy(&buf[buf[0]], data, size - bytes_left); +- buf[0] = MAX_PCKT; ++ buf[0] = max_pckt; + dl_docrc(buf); + + if (write(fd, buf, *buf) != *buf) +@@ -94,11 +99,18 @@ int _write_data(int fd, unsigned char *buf, unsigned char *data, int size, memcpy(buf, dspace, *dspace); @@ -171,7 +186,7 @@ index 3dfa12e..e68904f 100644 } if (!size) -@@ -135,6 +148,14 @@ int dl_send_data(WatchInfoPtr wi, int type) +@@ -135,6 +147,14 @@ int dl_send_data(WatchInfoPtr wi, int type) int status; int ret=0; int p; @@ -186,7 +201,7 @@ index 3dfa12e..e68904f 100644 if (type == BLINK_FILE) { -@@ -148,6 +169,7 @@ int dl_send_data(WatchInfoPtr wi, int type) +@@ -148,6 +168,7 @@ int dl_send_data(WatchInfoPtr wi, int type) } else { @@ -194,7 +209,7 @@ index 3dfa12e..e68904f 100644 /* Try to get the directory for a temporary file from * the envinronment variable TMPDIR * Try P_tmpdir if that fails -@@ -171,11 +193,41 @@ int dl_send_data(WatchInfoPtr wi, int type) +@@ -171,11 +192,43 @@ int dl_send_data(WatchInfoPtr wi, int type) sprintf(buf, "Can't open %s for writing.", fname); return ((*dl_error_proc) (buf)); } @@ -227,8 +242,10 @@ index 3dfa12e..e68904f 100644 +#endif } -+ if (wi->dl_device == DATALINK_50) ++ if (wi->dl_device == DATALINK_50) { + addr = 0x000e; ++ max_pckt = MAX_PCKT_50; ++ } + memcpy(buf, start1, *start1); @@ -237,7 +254,7 @@ index 3dfa12e..e68904f 100644 { buf[4] = 1; } -@@ -212,7 +264,10 @@ int dl_send_data(WatchInfoPtr wi, int type) +@@ -212,7 +265,10 @@ int dl_send_data(WatchInfoPtr wi, int type) for (i = 0; i < dl_download_data.num_times; i++) { @@ -249,7 +266,7 @@ index 3dfa12e..e68904f 100644 p = 2; if (wi->dl_device == DATALINK_IRONMAN) { -@@ -235,23 +290,29 @@ int dl_send_data(WatchInfoPtr wi, int type) +@@ -235,23 +291,29 @@ int dl_send_data(WatchInfoPtr wi, int type) buf[p++] = dl_download_data.times[i].year; buf[p++] = dl_download_data.times[i].dow; buf[p++] = dl_download_data.times[i].seconds; @@ -291,7 +308,7 @@ index 3dfa12e..e68904f 100644 } if (wi->dl_device == DATALINK_150 || -@@ -263,7 +324,7 @@ int dl_send_data(WatchInfoPtr wi, int type) +@@ -263,7 +325,7 @@ int dl_send_data(WatchInfoPtr wi, int type) dl_download_data.times[i].date_fmt & 0xFF; } @@ -300,7 +317,7 @@ index 3dfa12e..e68904f 100644 buf[1] = TIME_70; dl_docrc(buf); -@@ -276,43 +337,80 @@ int dl_send_data(WatchInfoPtr wi, int type) +@@ -276,43 +338,80 @@ int dl_send_data(WatchInfoPtr wi, int type) if (wi->dl_device != DATALINK_IRONMAN && dl_download_data.memory) { @@ -309,9 +326,9 @@ index 3dfa12e..e68904f 100644 + if (wi->dl_device == DATALINK_50) { + buf[0] = 0x05; + buf[1] = 0x60; -+ buf[2] = dl_download_data.memory / (MAX_PCKT - 6); ++ buf[2] = dl_download_data.memory / (max_pckt - 6); + -+ if (dl_download_data.memory % (MAX_PCKT - 6)) ++ if (dl_download_data.memory % (max_pckt - 6)) + buf[2]++; + buf[2]++; + } else { @@ -379,9 +396,9 @@ index 3dfa12e..e68904f 100644 + } else { + memcpy(buf, dinfo, *dinfo); + buf[2] = 1; -+ buf[3] = dl_download_data.memory / (MAX_PCKT - 6); ++ buf[3] = dl_download_data.memory / (max_pckt - 6); + -+ if (dl_download_data.memory % (MAX_PCKT - 6)) ++ if (dl_download_data.memory % (max_pckt - 6)) + buf[3]++; + + buf[12] = dl_download_data.num_apps; @@ -410,7 +427,7 @@ index 3dfa12e..e68904f 100644 dl_docrc(buf); -@@ -320,15 +418,26 @@ int dl_send_data(WatchInfoPtr wi, int type) +@@ -320,15 +419,26 @@ int dl_send_data(WatchInfoPtr wi, int type) return ((*dl_error_proc) ("Can't write dinfo to tmp file.")); @@ -442,36 +459,35 @@ index 3dfa12e..e68904f 100644 for (i = 0; i < dl_download_data.num_apps; i++) { ap = &dl_download_data.apps[i]; -@@ -421,8 +530,16 @@ int dl_send_data(WatchInfoPtr wi, int type) +@@ -421,8 +531,16 @@ int dl_send_data(WatchInfoPtr wi, int type) return ((*dl_error_proc) ("Can't write to tmp file.")); +- memcpy(buf, dend, *dend); +- buf[2] = 1; + -+#if 0 - memcpy(buf, dend, *dend); - buf[2] = 1; -+#else -+ buf[0]=0x4; -+ buf[1]=0x62; -+#endif ++ if (wi->dl_device == DATALINK_50) { ++ buf[0]=0x4; ++ buf[1]=0x62; ++ } else { ++ memcpy(buf, dend, *dend); ++ buf[2] = 1; ++ } + + dl_docrc(buf); if (write(ofd, buf, *buf) != *buf) -@@ -558,7 +675,11 @@ int dl_send_data(WatchInfoPtr wi, int type) +@@ -558,7 +676,7 @@ int dl_send_data(WatchInfoPtr wi, int type) } /* timezone label packet for IRONMAN watch */ -+#if 0 - if (wi->dl_device == DATALINK_IRONMAN) -+#else -+ if (1) -+#endif +- if (wi->dl_device == DATALINK_IRONMAN) ++ if ((wi->dl_device == DATALINK_IRONMAN) || (wi->dl_device == DATALINK_50)) for (i = 0; i < dl_download_data.num_times; i++) { p = 0; -@@ -621,6 +742,22 @@ int dl_send_data(WatchInfoPtr wi, int type) +@@ -621,6 +739,22 @@ int dl_send_data(WatchInfoPtr wi, int type) return ((*dl_error_proc) ("Can't write to tmp file.")); @@ -481,7 +497,7 @@ index 3dfa12e..e68904f 100644 + buf[0] = 0x07; + buf[1] = 0x70; + buf[2] = 0x00; -+ buf[3] = 0x61 + dl_download_data.alarms[i].alarm_num; ++ buf[3] = 0x60 + dl_download_data.alarms[i].alarm_num; + buf[4] = 0x00; + + dl_docrc(buf); @@ -494,7 +510,19 @@ index 3dfa12e..e68904f 100644 } for (i = 0; i < dl_download_data.num_timers; i++) -@@ -673,7 +810,10 @@ int dl_send_data(WatchInfoPtr wi, int type) +@@ -657,9 +791,9 @@ int dl_send_data(WatchInfoPtr wi, int type) + + memcpy(buf, dinfo, *dinfo); + buf[2] = 2; +- buf[3] = wristapp->len / (MAX_PCKT - 6); ++ buf[3] = wristapp->len / (max_pckt - 6); + +- if (wristapp->len % (MAX_PCKT - 6)) ++ if (wristapp->len % (max_pckt - 6)) + buf[3]++; + + buf[4] = 1; +@@ -673,7 +807,10 @@ int dl_send_data(WatchInfoPtr wi, int type) memcpy(buf, dspace, *dspace); @@ -506,7 +534,19 @@ index 3dfa12e..e68904f 100644 buf[1] = DATA_70; pnum = 1; -@@ -735,7 +875,10 @@ int dl_send_data(WatchInfoPtr wi, int type) +@@ -719,9 +856,9 @@ int dl_send_data(WatchInfoPtr wi, int type) + + memcpy(buf, dinfo, *dinfo); + buf[2] = 3; +- buf[3] = melody->len / (MAX_PCKT - 6); ++ buf[3] = melody->len / (max_pckt - 6); + +- if (melody->len % (MAX_PCKT - 6)) ++ if (melody->len % (max_pckt - 6)) + buf[3]++; + + buf[4] = 0xff - melody->len; +@@ -735,7 +872,10 @@ int dl_send_data(WatchInfoPtr wi, int type) memcpy(buf, dspace, *dspace); @@ -518,7 +558,7 @@ index 3dfa12e..e68904f 100644 buf[1] = DATA_70; pnum = 1; -@@ -798,6 +941,7 @@ int dl_send_data(WatchInfoPtr wi, int type) +@@ -798,6 +938,7 @@ int dl_send_data(WatchInfoPtr wi, int type) close(ofd); @@ -526,7 +566,7 @@ index 3dfa12e..e68904f 100644 switch (type) { case BLINK_FILE: -@@ -892,6 +1036,7 @@ int dl_send_data(WatchInfoPtr wi, int type) +@@ -892,6 +1033,7 @@ int dl_send_data(WatchInfoPtr wi, int type) break; } -- cgit v1.2.3