29
29
#include "bbatt.h"
30
30
#include "ttops.h"
31
31
#include "util.h"
32
+ #include "ttblue.h"
32
33
33
34
const char * PLEASE_SETCAP_ME =
34
35
"**********************************************************\n"
@@ -228,12 +229,12 @@ read_gqf_status(TTDEV *ttd, int debug)
228
229
time_t last_update = 0 ;
229
230
uint8_t * fbuf ;
230
231
int length ;
231
- if ((length = tt_read_file (ttd , ttd -> files -> gps_status , debug , & fbuf )) < 0 ) {
232
- fprintf (stderr , "WARNING: Could not read GPS status file 0x%08x from watch.\n" , ttd -> files -> gps_status );
232
+ if ((length = tt_read_file (ttd , TTBLUE_FILE_GPS_STATUS , debug , & fbuf )) < 0 ) {
233
+ fprintf (stderr , "WARNING: Could not read GPS status file 0x%08x from watch.\n" , TTBLUE_FILE_GPS_STATUS );
233
234
last_update = -1 ;
234
235
} else {
235
236
#ifdef DUMP_0x00020001
236
- save_buf_to_file (make_tt_filename (ttd -> files -> gps_status , "bin" ), "wxb" , fbuf , length , 2 , true);
237
+ save_buf_to_file (make_tt_filename (TTBLUE_FILE_GPS_STATUS , "bin" ), "wxb" , fbuf , length , 2 , true);
237
238
#endif
238
239
if (length > 6 && (fbuf [0x02 ] | fbuf [0x03 ] | fbuf [0x04 ] | fbuf [0x05 ]) != 0 ) {
239
240
struct tm tmp = { .tm_mday = fbuf [0x05 ], .tm_mon = fbuf [0x04 ]- 1 , .tm_year = (((int )fbuf [0x02 ])<<8 ) + fbuf [0x03 ] - 1900 };
@@ -529,23 +530,25 @@ int main(int argc, const char **argv)
529
530
int length ;
530
531
531
532
fprintf (stderr , "Setting PHONE menu to '%s'.\n" , hostname );
532
- tt_delete_file (ttd , ttd -> files -> hostname );
533
- tt_write_file (ttd , ttd -> files -> hostname , false, (uint8_t * )hostname , strlen (hostname ), write_delay );
533
+ tt_delete_file (ttd , TTBLUE_FILE_HOSTNAME1 );
534
+ tt_write_file (ttd , TTBLUE_FILE_HOSTNAME1 , false, (uint8_t * )hostname , strlen (hostname ), write_delay );
535
+ tt_delete_file (ttd , TTBLUE_FILE_HOSTNAME2 ); // Write name to two files as V1 and V2 devices seem to use different files
536
+ tt_write_file (ttd , TTBLUE_FILE_HOSTNAME2 , false, (uint8_t * )hostname , strlen (hostname ), write_delay );
534
537
535
538
#ifdef DUMP_0x000f20000
536
- fprintf (stderr , "Reading preference file 0x%08x from watch...\n" , ttd -> files -> preference );
537
- if ((length = tt_read_file (ttd , ttd -> files -> preference , debug , & fbuf )) < 0 ) {
538
- fprintf (stderr , "WARNING: Could not read preferences file 0x%08x from watch.\n" , ttd -> files -> preference );
539
+ fprintf (stderr , "Reading preference file 0x%08x from watch...\n" , TTBLUE_FILE_PREFERENCES_XML );
540
+ if ((length = tt_read_file (ttd , TTBLUE_FILE_PREFERENCES_XML , debug , & fbuf )) < 0 ) {
541
+ fprintf (stderr , "WARNING: Could not read preferences file 0x%08x from watch.\n" , TTBLUE_FILE_PREFERENCES_XML );
539
542
} else {
540
- save_buf_to_file (make_tt_filename (ttd -> files -> preference , "xml" ), "wxb" , fbuf , length , 2 , true);
543
+ save_buf_to_file (make_tt_filename (TTBLUE_FILE_PREFERENCES_XML , "xml" ), "wxb" , fbuf , length , 2 , true);
541
544
free (fbuf );
542
545
}
543
546
#endif
544
547
545
548
if (set_time ) {
546
- fprintf (stderr , "Checking watch settings manifest file 0x%08x...\n" , ttd -> files -> manifest );
547
- if ((length = tt_read_file (ttd , ttd -> files -> manifest , debug , & fbuf )) < 0 ) {
548
- fprintf (stderr , "WARNING: Could not read settings manifest file 0x%08x from watch!\n" , ttd -> files -> manifest );
549
+ fprintf (stderr , "Checking watch settings manifest file 0x%08x...\n" , TTBLUE_FILE_MANIFEST1 );
550
+ if ((length = tt_read_file (ttd , TTBLUE_FILE_MANIFEST1 , debug , & fbuf )) < 0 ) {
551
+ fprintf (stderr , "WARNING: Could not read settings manifest file 0x%08x from watch!\n" , TTBLUE_FILE_MANIFEST1 );
549
552
} else {
550
553
// based on: https://github.com/ryanbinns/ttwatch/tree/master/manifest
551
554
// the position of the UTC-offset in the manifest is 169 in all known firmware versions, so lazily hard-coded here for now
@@ -565,8 +568,8 @@ int main(int argc, const char **argv)
565
568
if (btohl (* watch_timezone ) != lt -> tm_gmtoff ) {
566
569
fprintf (stderr , " Changing timezone from UTC%+d to UTC%+ld.\n" , btohl (* watch_timezone ), lt -> tm_gmtoff );
567
570
* watch_timezone = htobl (lt -> tm_gmtoff );
568
- tt_delete_file (ttd , ttd -> files -> manifest );
569
- tt_write_file (ttd , ttd -> files -> manifest , false, fbuf , length , write_delay );
571
+ tt_delete_file (ttd , TTBLUE_FILE_MANIFEST1 );
572
+ tt_write_file (ttd , TTBLUE_FILE_MANIFEST1 , false, fbuf , length , write_delay );
570
573
needs_reboot = true;
571
574
}
572
575
}
@@ -576,15 +579,15 @@ int main(int argc, const char **argv)
576
579
577
580
if (get_activities ) {
578
581
uint16_t * list ;
579
- int n_files = tt_list_sub_files (ttd , ttd -> files -> activity_start , & list );
582
+ int n_files = tt_list_sub_files (ttd , TTBLUE_FILE_TTBIN_DATA , & list );
580
583
581
584
if (n_files < 0 ) {
582
585
fprintf (stderr , "Could not list activity files on watch!\n" );
583
586
goto fail ;
584
587
}
585
588
fprintf (stderr , "Found %d activity files on watch.\n" , n_files );
586
589
for (int ii = 0 ; ii < n_files ; ii ++ ) {
587
- uint32_t fileno = ttd -> files -> activity_start + list [ii ];
590
+ uint32_t fileno = TTBLUE_FILE_TTBIN_DATA + list [ii ];
588
591
589
592
fprintf (stderr , " Reading activity file 0x%08X ...\n" , fileno );
590
593
term_title ("ttblue: Transferring activity %d/%d" , ii + 1 , n_files );
@@ -668,8 +671,8 @@ int main(int argc, const char **argv)
668
671
goto fail ;
669
672
} else {
670
673
fclose (f );
671
- tt_delete_file (ttd , ttd -> files -> quickgps );
672
- result = tt_write_file (ttd , ttd -> files -> quickgps , debug , fbuf , length , write_delay );
674
+ tt_delete_file (ttd , TTBLUE_FILE_GPSQUICKFIX_DATA );
675
+ result = tt_write_file (ttd , TTBLUE_FILE_GPSQUICKFIX_DATA , debug , fbuf , length , write_delay );
673
676
free (fbuf );
674
677
if (result < 0 ) {
675
678
fputs ("Failed to send QuickFixGPS update to watch.\n" , stderr );
@@ -678,7 +681,7 @@ int main(int argc, const char **argv)
678
681
// official TomTom Android app seems to only issue this
679
682
// "magic" update command when the GPS is brand new or
680
683
// after a factory reset, or with 3x --update-gps
681
- att_wrreq (ttd -> fd , ttd -> h -> cmd_status , BARRAY (0x05 , 0x01 , 0x00 , 0x01 ), 4 );
684
+ att_wrreq (ttd -> fd , ttd -> h -> cmd_status , BARRAY (MSG_UPDATE_EPHEMERIS , 0x01 , 0x00 , 0x01 ), 4 );
682
685
683
686
time_t last_gqf_update = read_gqf_status (ttd , debug - 1 );
684
687
if (last_gqf_update != -1 && last_gqf_update != 0 )
0 commit comments