izivkov/CasioGShockSmartSync

Support Rangeman GPR-B1000

mattnin opened this issue · 68 comments

The repository for the GPR-B1000 sync app has been made open source and is here, https://github.com/zspuspoki/RangemanSync
Would love if this is integrated into this app. I mostly use the time sync via NTP server, and uploading gps waypoints via spreadsheet.

@mattnin Thanks for your suggestion. I can possibly see integrating the GRP-B1000 into this app as an Activity.

There was another request for that a while ago, before the RangemanSync repository was available, but we could not do it at that time. One of the main issues was I do not have this watch, and it is difficult to develop without the watch. I am trying to get some donations so I can support more watches, but I have received $0 so far, lol. This is still a problem, but maybe I can work with somebody for testing. Obviously, the new repository will help, although the code is in C#, which needs to be converted to Kotlin.

Alternatively, we can get somebody to contribute to this app with knowledge of this watch. Maybe you or I can ask if RangemanSync developers will be willing to contribute to this project.

The first thing is to determine if the watch will connect to this app. Have you tried connecting?

@mattnin BTW, I was wondering why not just use the RangemanSync app as is. They seem to support time sync now. What features of this app you would like to have?

I'd be glad to test as I have this watch.

Yes, I have the app, purchased from Google Play, and it does connect to the watch. It mostly works as stated, however there is an error "connect failed" after a sync attempt. Perhaps the original developer can chime in and give his input on it. He has a windows version that supposedly does not give that error. The features such as upload waypoints using a map, upload waypoints using a chart, and saving waypoints to GPX all work well however. As matter of fact, I uploaded some waypoints using the app today for a hike I'm getting ready for in just a few minutes. I still prefer using this app to upload waypoints versus g shock connected or the newer casio watches app.

Unfortunately, the time sync no longer works correctly on Android 14, Google Pixel 6a. It used to work perfectly in the past. For some reason, the app now time syncs to UTC +0 time and no longer to my time zone. I would get perfect time sync with +7 seconds compensation with my home NTP server compared to another atomic synced watch with Fort Collins, Colorado time signal radio.

Another bug, the NTP logs don't show. I believe the developer said it was due to dark mode setting.

Other comments: The map tab is "clunky". It does work, but it seems to use an awful lot of storage. I had to upload an mbtiles to truly use the map offline. I wish there was another way, or use another map. There is no undo feature after selecting a waypoint as well. These problems is why I asked the developer to create a way to upload waypoints using a table which is an absolutely excellent way to do it. I currently make my waypoints using another map application, and I manually upload the coordinates to the table, and then use szilamer007's app to upload it to my watch. Very nice.

I wouldn't be using the g shock connected app any more if the time sync still worked. However, I do feel that overall the app could be made 'prettier'.

Just to clarify, does this app, Gshock Smart Sync, connect to your watch, or are you describing the the connection issue with the RangemanSync app. I'm curous if my app can connect to your phone.

The connection issue I was describing previously was with the RangemanSync app.

Interesting. I just tried your app and yes, it does connect to my watch. It even says GPR-B1000 in the status on the bottom. It also syncs the time too. I synced the time from RangemanSync app which now sets it wrong, then used your app and it set it fairly correct for the most part. I also tried using my bluetooth sync button on my watch and it also connects to your app, does the actions, and uploads the time to my watch, however it doesn't send the GPS coordinates to my watch unfortunately. When I do the same task with RangemanSync app, it sends the GPS coordinates as well. Your app also set the timer setting. I haven't tried every feature of your app with my watch, but it does mostly appear to work.

Perhaps if you see the RangemanSync app's time sync code, you'll see that not only does it send the time, but it also sends the GPS coordinates to the GPR-B1000. I believe that is so the watch can set the current moon phase. That is based on GPS coordinates I believe.

Perhaps your app can add some of the features of the RangemanSync app. Already your app is working nicely with my watch! I'd like to see the time sync GPS issue fixed, an ability to upload waypoints using a table very much like RangemanSync app, a way to save waypoints to a GPX file, a way to download the GPX file from the watch to the phone, sync time using my own NTP server of my choosing and adjust time compensation to my choosing, and also set the high tide settings to the watch. Those features are mostly already working on the RangemanSync app but the time sync no longer works correctly.

Okay, I will take a look at the code for RangemanSync and see how they've implemented it. I can't commit to completing it because it's very challenging to develop without having access to the watch. I hope someone can assist with some of that work. I've reached out to RangemanSync to inquire if they're willing to incorporate some of that functionality into my app, and I'm available to assist them with theirs as well, but I haven't heard back from them yet. Nevertheless, I'm pleased that the basic functions are working with your watch.

@mattnin Do you have an example of a waypoint table file you can provide? If so, please attach here.

@izivkov I have GPX files from the RangemanSync app, which are also problematic as they aren't completely standard and have their own issues. I asked the developer to fix the problem but he never got around to it. I believe the GPX I have are parsed from the waypoint table file that you are really looking for.

Perhaps you can tell me how I can get all the files from the watch itself?

OK, let us put the RangemanSync aside for now. Can you educate me on the following:

  1. Can you load and export files with the official app? What types of files does the official app support?
  2. Ideally, what file format would you like to see? According to ChatGPT, some of the standard Waypoint file formats are:
  • GPX (GPS Exchange Format)
  • KML/KMZ (Keyhole Markup Language)
  • CSV (Comma-Separated Values)
  • TCX (Training Center XML)
  • LOC (Geocaching.com)
  • JSON (JavaScript Object Notation)
  • Which one would be ideal?
  1. I can probably send longitude/latitude coordinates to the watch while sending time. Would that be useful as a first step?
  2. What triggers the watch to upload and download a waypoint file? Is there a specific button to press?
  3. I often do prototyping work in Python because it is easier to iterate and make changes. Here is a project I have created to communicate with the watch using Python. What is your comfort level with running Python programs?
  1. I cannot load and export files using the official app unfortunately. This was one of the major complaints regarding the official app.
  2. GPX file format I feel would be most used by the community
  3. Sending coordinates to the watch while sending the time would be useful as the first step.
  4. While the watch is connected to the official app or the RangemanSync app, the app itself initiates the download of the waypoint file.
  5. I should be able to run a python program. While I don't have it setup at the moment, I'll review your project right now and get it running.

I just heard back from the developer of the RangemanSync app and he will be contacting you shortly

OK, what then triggers the file upload/download in the RangemanSync app?

Ideally, I would like to integrate the app with Google Maps or another open-source map. For example, you can set up your route in Google Maps, and then this app will simply read it and upload it to the watch—similar to what I do with Google Calendar. Also, the app can export waypoints saved on the watch when setting time to Google Maps. There may be some cost associated with using the Google Maps API, which, of course, is a non-starter. I will need to investigate. What do you think?

Failing that, let us use the most common file format possible, which can be easily exported from Google Maps. This will depend on the answer to 1.

I don't want to raise your hopes too high, though. Not having the watch to work with is a major hurdle, so all this may come to nothing. But I'm willing to give it a try.

The RangemanSync app has a button that is used to request the data from the watch. The RangemanSync app has a button that says "Download Headers", and then "Download / Save as GPX". The official G Shock Connected app has a button that says "Log Import". The official G Shock app does not have a way to download the GPX file.

Setting up a route using Google Maps or another open source map is great. However, I prefer to use another map application entirely that has my purchased Topo maps with satellite imagery and high zoom and get GPS coordinates in this form, "40.0000001, -100.0000001". It's very simple for me to copy/paste from that app into the RangemanSync app and get exactly the point uploaded to the watch. I love the simple table that Szilamer007 made for that app to upload waypoints. However, if I had access to a sufficient quality map with enough zoom, and topo and/or satellite imagery with enough zoom, I may use that too.

The Rangeman Sync app does it this way:

| Node Name | GPS Coordinates ( lat,lon) | Description |
| 1 | 40.0000001, -100.0000001 | Start |
| 2 | 40.0000002, -100.0000002 | Trailhead |
and so on...
| G | 41.0000001, -101.0000001 | Goal, Final Destination |

His app also has an ability to save those so I can pull them up later when I go back. Those are a simple xml file.

[{"NodeName":"S","Coordinates":"40.0000001, -100.0000001","CoordinateName":"Start"}, and so on

OK, I'll wait for RangemanSync to contact me, and we can discuss later.

@izivkov

I received an error using the GShockTimeServer

If Auto-time set on watch, the watch will connect and run automatically up to 4 times per day.
==============================================================================================

2023-12-08 10:22:01,710 asyncio  ERROR: Exception in callback Connection.notification_handler(<bleak.backen...001C378657770>)(bytearray(b'\...\xff\xff\xff'))
handle: <Handle Connection.notification_handler(<bleak.backen...001C378657770>)(bytearray(b'\...\xff\xff\xff'))>
Traceback (most recent call last):
  File "C:\Users\mattn\AppData\Local\Programs\Python\Python312\Lib\asyncio\events.py", line 84, in _run
    self._context.run(self._callback, *self._args)
  File "C:\Users\mattn\AppData\Local\Programs\Python\Python312\Lib\site-packages\gshocktimeserver\connection.py", line 23, in notification_handler
    data_watcher.emit_event(name, value)
  File "C:\Users\mattn\AppData\Local\Programs\Python\Python312\Lib\site-packages\gshocktimeserver\data_watcher.py", line 55, in emit_event
    subject.on_next(event)
  File "C:\Users\mattn\AppData\Local\Programs\Python\Python312\Lib\site-packages\reactivex\subject\subject.py", line 59, in on_next
    super().on_next(value)
  File "C:\Users\mattn\AppData\Local\Programs\Python\Python312\Lib\site-packages\reactivex\observer\observer.py", line 39, in on_next
    self._on_next_core(value)
  File "C:\Users\mattn\AppData\Local\Programs\Python\Python312\Lib\site-packages\reactivex\subject\subject.py", line 66, in _on_next_core
    observer.on_next(value)
  File "C:\Users\mattn\AppData\Local\Programs\Python\Python312\Lib\site-packages\reactivex\observer\autodetachobserver.py", line 28, in on_next
    self._on_next(value)
  File "C:\Users\mattn\AppData\Local\Programs\Python\Python312\Lib\site-packages\gshocktimeserver\gshock_api.py", line 241, in handle_message
    res = result_queue.dequeue(key)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\mattn\AppData\Local\Programs\Python\Python312\Lib\site-packages\gshocktimeserver\result_queue.py", line 22, in dequeue
    value = self.keyed_result_map[key]
            ~~~~~~~~~~~~~~~~~~~~~^^^^^
KeyError: '1D00'

@mattnin Can you try again please. Just pull the latest from GitHub. I just made a quick fix, but I was planning to bring this repo up to date later. If it does not work for, will have to leave it for now until I got more time to work on it.

Tnanks.

@izivkov It got further but still had an error

==============================================================================================
Short-press lower-right button on your watch to set time...

If Auto-time set on watch, the watch will connect and run automatically up to 4 times per day.
==============================================================================================

write: 10
write: 22
write: 1d00
write: 1d02
2023-12-08 12:28:42,379 asyncio  ERROR: Exception in callback Connection.notification_handler(<bleak.backen...0019C4E6D5250>)(bytearray(b'\...\xff\xff\xff'))
handle: <Handle Connection.notification_handler(<bleak.backen...0019C4E6D5250>)(bytearray(b'\...\xff\xff\xff'))>
Traceback (most recent call last):
  File "C:\Users\mattn\AppData\Local\Programs\Python\Python312\Lib\asyncio\events.py", line 84, in _run
    self._context.run(self._callback, *self._args)
  File "C:\Users\mattn\AppData\Local\Programs\Python\Python312\Lib\site-packages\gshocktimeserver\connection.py", line 23, in notification_handler
    data_watcher.emit_event(name, value)
  File "C:\Users\mattn\AppData\Local\Programs\Python\Python312\Lib\site-packages\gshocktimeserver\data_watcher.py", line 55, in emit_event
    subject.on_next(event)
  File "C:\Users\mattn\AppData\Local\Programs\Python\Python312\Lib\site-packages\reactivex\subject\subject.py", line 59, in on_next
    super().on_next(value)
  File "C:\Users\mattn\AppData\Local\Programs\Python\Python312\Lib\site-packages\reactivex\observer\observer.py", line 39, in on_next
    self._on_next_core(value)
  File "C:\Users\mattn\AppData\Local\Programs\Python\Python312\Lib\site-packages\reactivex\subject\subject.py", line 66, in _on_next_core
    observer.on_next(value)
  File "C:\Users\mattn\AppData\Local\Programs\Python\Python312\Lib\site-packages\reactivex\observer\autodetachobserver.py", line 28, in on_next
    self._on_next(value)
  File "C:\Users\mattn\AppData\Local\Programs\Python\Python312\Lib\site-packages\gshocktimeserver\gshock_api.py", line 241, in handle_message
    res = result_queue.dequeue(key)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\mattn\AppData\Local\Programs\Python\Python312\Lib\site-packages\gshocktimeserver\result_queue.py", line 22, in dequeue
    value = self.keyed_result_map[key]
            ~~~~~~~~~~~~~~~~~~~~~^^^^^
KeyError: '1D00'

I just checked your app with my GPR-B1000 and all the settings work except for language selection.

I also noticed that the time sync is off by 1 second on my watch compared to other atomic sync casio watches I have. When I try the g-shock connected app, the time sync is exact compared to my atomic watches.

My phone itself is about 1/2 second too fast compared to my atomic watch. After syncing my watch to your app, my watch is now about 1 second behind my atomic watch. So my watch time isn't exact compared to the phone either.

I also noticed that the time sync fluctuates using your app. I just synced a moment ago, and it was almost exact with my atomic watch. I just tried syncing again, it is back to being almost exactly 1 second behind. Just tried again, and it is almost exact again, perhaps just 1/4 second behind. And for good measure, I just tried it again, and it is a whole 2 seconds behind.

When Szilamer007 RangemanSync app worked, it was almost perfect time sync with atomic time. His app synced using an NTP server. Someone could choose time.google.com, I would choose my own and I loved being able to choose my own NTP server. He also implemented a feature called time compensation. I found +7 seconds to be about perfect time sync with my atomic watches. Perhaps you can get some hints from his app to get a better time sync? I was very happy with his time sync until it stopped working with Android 14.

Hey @mattnin, thank you for the info.

About the time, the app does not use NTP. It gets the time from the phone. Most phones are synced from their service provider, so they are pretty accurate. I think I adjust this time by 3 seconds to compensate for the data transfer to the watch.

The reason I don't use NTP is twofold:

  1. The app should work without a network connection. This is one of the premises of this app.
  2. Simplicity. Adding NTP is obviously more accurate, but the transmission time is variable and negates this extra accuracy.

Funny about the language not working. Does it not set it at all, or does it set it to the wrong language? Can you tell me which languages your watch supports? I would like to resolve this issue, if possible, if it is not too hard. Possibly I will send you a special APK, or we get the Python app to work in the future. I tested the Python app, by the way, and it seems to work for me. I have never run it on Windows, just on Linux.

I had a discussion with @szilamer007. We discussed the possibility of seamless integration with Google Maps (or similar). It is possible in theory, but he no longer has this watch. I will have to park this idea for now until I find somebody to help. I cannot justify buying this watch since it is expensive, and I am not a collector.

  1. It would be nice if you gave us the option, I would prefer to use NTP. The app could still work without a network connection (If NTP doesn't exist, then use phone time)
  2. Transmission time could be adjusted via the end user. I would like the option to input my own time compensation.

Language did not set at all. I changed it to spanish, and there was no change on the watch. I looked in my watch manual and I did not see any option to change the language, so my watch may not support any other languages.

I'll be happy to test your python app some more. I have a raspberry pi and I just found out it has BLE, so I should be able to get your python app running there. I'll let you know my results once I have it running.

Yeah, I wish he still had the watch because his app was getting better and better and hardly used any battery. His app was working pretty good up until Android 14, now for some reason it syncs time wrong, so I had to go back to G Shock Connected just for the time sync. I hope someone helps with his app in the future and can fix that problem. I still use his app to upload waypoints though, it does a great job of that.

I hope you consider NTP some more and consider giving us the option to adjust our own time compensation and give us the option to select an NTP server, if that is what we choose. Szilamer007 spoiled us with his time sync and giving us the ability to choose any NTP server we wish.

About the Python app, I hope you get it working, but I think it may be just a difference in the watch model. After successfully sending a few commands, the app gets something it did not expect. Also, make sure you are using the latest version of Python. I have Python 3.10.9. Try a few times if it fails the first time.

I also did not find a "language" setting for your watch, so I think it is not supported. This menu should be hidden for your watch. I will add this in the next release.

RangemanSync program is written in C#. This is not common for Android apps, and I did not even know it could be done. I'm not familiar with C#, although I can read the code. Also, it requires a Windows environment, which I do not have (I run Linux). So it would be difficult to fix.

About the NTP, I get feedback from the users, and frankly, most people do not care about this much accuracy. Another issue is that I do not like to keep app settings, like delay time (7 seconds), because if you remove your app and install it again, your settings will have to be reset. People appreciate the simplicity of using this app. There are some trade-offs that I'm making, and I lean towards ease of use.

@mattnin Di you think you can send me a screenshot of your main screen on the app? I like ot see if any menues are missing.

Thanks

Thanks for the screenshot. I wanted to check if you have a "Reminders" tab at the bottom of your app, which you do not have. This app integrates Google Calendar with reminders, but looks like your watch does not support them, so this is OK.

@mattnin BTW, is your battery really at 0% or is the app not reading it propely?

The battery is full, so it appears the app isn't reading it properly. It may be possible that the watch doesn't report the battery level at all because it doesn't show the battery level in the official app either.

I tried running gshocktimeserver on a raspberry pi 3 and got some error. I'm not sure what I did. I installed the dependencies and setuptools setuptools_scm wheel

pi@raspberrypi:/usr/local/lib/python3.7/dist-packages/gshocktimeserver $ python3 gshock_server.py
==============================================================================================
Short-press lower-right button on your watch to set time...

If Auto-time set on watch, the watch will connect and run automatically up to 4 times per day.
==============================================================================================

2023-12-11 19:43:07,584 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3564" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,595 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3565" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,605 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3566" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,616 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3567" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,627 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3568" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,637 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3569" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,648 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3570" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,658 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3571" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,669 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3572" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,679 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3573" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,690 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3574" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,700 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3575" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,711 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3576" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,722 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3577" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,732 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3578" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,743 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3579" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,753 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3580" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,764 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3581" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,774 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3582" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,785 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3583" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,795 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3584" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,806 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3585" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,816 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3586" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,827 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3587" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,837 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3588" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,848 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3589" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
2023-12-11 19:43:07,858 logger   ERROR: ('Got error: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.3590" (uid=1000 pid=794 comm="python3 gshock_server.py ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=738 comm="/usr/lib/bluetooth/bluetoothd --noplugin=sap ")',)
^CTraceback (most recent call last):
  File "gshock_server.py", line 74, in <module>
    asyncio.run(main(sys.argv[1:]))
  File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.7/asyncio/base_events.py", line 571, in run_until_complete
    self.run_forever()
  File "/usr/lib/python3.7/asyncio/base_events.py", line 539, in run_forever
    self._run_once()
  File "/usr/lib/python3.7/asyncio/base_events.py", line 1775, in _run_once
    handle._run()
  File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "gshock_server.py", line 21, in main
    await run_time_server()
  File "gshock_server.py", line 44, in run_time_server
    device = await scanner.scan(address)
  File "/usr/local/lib/python3.7/dist-packages/gshocktimeserver/scanner.py", line 20, in scan
    timeout=5 * 60.0
  File "/usr/local/lib/python3.7/dist-packages/bleak/__init__.py", line 363, in find_device_by_filter
    found_device_queue: asyncio.Queue[BLEDevice] = asyncio.Queue()
  File "/usr/lib/python3.7/asyncio/queues.py", line 44, in __init__
    self._finished = locks.Event(loop=self._loop)
KeyboardInterrupt
pi@raspberrypi:/usr/local/lib/python3.7/dist-packages/gshocktimeserver $ ^C
pi@raspberrypi:/usr/local/lib/python3.7/dist-packages/gshocktimeserver $ sudo service bluetooth status
● bluetooth.service - Bluetooth service
   Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2023-12-11 19:33:01 MST; 10min ago
     Docs: man:bluetoothd(8)
 Main PID: 738 (bluetoothd)
   Status: "Running"
    Tasks: 1 (limit: 1631)
   CGroup: /system.slice/bluetooth.service
           └─738 /usr/lib/bluetooth/bluetoothd --noplugin=sap

Dec 11 19:33:01 raspberrypi systemd[1]: Starting Bluetooth service...
Dec 11 19:33:01 raspberrypi bluetoothd[738]: Bluetooth daemon 5.50
Dec 11 19:33:01 raspberrypi systemd[1]: Started Bluetooth service.
Dec 11 19:33:01 raspberrypi bluetoothd[738]: Starting SDP server
Dec 11 19:33:01 raspberrypi bluetoothd[738]: Excluding (cli) sap
Dec 11 19:33:01 raspberrypi bluetoothd[738]: Bluetooth management interface 1.18 initialized
pi@raspberrypi:/usr/local/lib/python3.7/dist-packages/gshocktimeserver $ python3 --version
Python 3.7.3

It ran under sudo, I did try adding pi to bluetooth group but that didn't work.

If Auto-time set on watch, the watch will connect and run automatically up to 4 times per day.
==============================================================================================

write: 10
write: 22
write: 1d00
write: 1e00
write: 1e01
write: 1f00
write: 1f01
Time set at 2023-12-11 19:55:17.647008 on CASIO GPR-B1000

scratch that, I must've tried adding bluetooth to pi incorrectly, it now works, thanks!

It's so weird, now it's not working. It did just a moment ago

pi@raspberrypi:/usr/local/lib/python3.7/dist-packages/gshocktimeserver $ python3 gshock_server.py
==============================================================================================
Short-press lower-right button on your watch to set time...

If Auto-time set on watch, the watch will connect and run automatically up to 4 times per day.
==============================================================================================

2023-12-11 19:59:52,718 logger   ERROR: ("Got error: 'Logger' object has no attribute 'warning'",)
write: 10
write: 22
write: 1d00
write: 1d02
2023-12-11 19:59:56,275 root     ERROR: A message handler raised an exception: '1D00'
Traceback (most recent call last):
  File "src/dbus_fast/message_bus.py", line 785, in dbus_fast.message_bus.BaseMessageBus._process_message
  File "/usr/local/lib/python3.7/dist-packages/bleak/backends/bluezdbus/manager.py", line 874, in _parse_msg
    on_value_changed(message.path, self_interface["Value"])
  File "/usr/local/lib/python3.7/dist-packages/bleak/backends/bluezdbus/client.py", line 172, in on_value_changed
    callback(bytearray(value))
  File "/usr/local/lib/python3.7/dist-packages/gshocktimeserver/connection.py", line 23, in notification_handler
    data_watcher.emit_event(name, value)
  File "/usr/local/lib/python3.7/dist-packages/gshocktimeserver/data_watcher.py", line 55, in emit_event
    subject.on_next(event)
  File "/usr/local/lib/python3.7/dist-packages/reactivex/subject/subject.py", line 59, in on_next
    super().on_next(value)
  File "/usr/local/lib/python3.7/dist-packages/reactivex/observer/observer.py", line 39, in on_next
    self._on_next_core(value)
  File "/usr/local/lib/python3.7/dist-packages/reactivex/subject/subject.py", line 66, in _on_next_core
    observer.on_next(value)
  File "/usr/local/lib/python3.7/dist-packages/reactivex/observer/autodetachobserver.py", line 28, in on_next
    self._on_next(value)
  File "/usr/local/lib/python3.7/dist-packages/gshocktimeserver/gshock_api.py", line 241, in handle_message
    res = result_queue.dequeue(key)
  File "/usr/local/lib/python3.7/dist-packages/gshocktimeserver/result_queue.py", line 22, in dequeue
    value = self.keyed_result_map[key]
KeyError: '1D00'

Okay, I just tried uncommenting line 22, but I am now getting this error and it won't sync time any more.

pi@raspberrypi:/usr/local/lib/python3.7/dist-packages/gshocktimeserver $ sudo nano gshock_server.py
pi@raspberrypi:/usr/local/lib/python3.7/dist-packages/gshocktimeserver $ python3 gshock_server.py
==============================================================================================
Short-press lower-right button on your watch to set time...

If Auto-time set on watch, the watch will connect and run automatically up to 4 times per day.
==============================================================================================

write: 10
write: 22
write: 1d00
write: 1d02
2023-12-11 20:07:56,901 root     ERROR: A message handler raised an exception: '1D00'
Traceback (most recent call last):
  File "src/dbus_fast/message_bus.py", line 785, in dbus_fast.message_bus.BaseMessageBus._process_message
  File "/usr/local/lib/python3.7/dist-packages/bleak/backends/bluezdbus/manager.py", line 874, in _parse_msg
    on_value_changed(message.path, self_interface["Value"])
  File "/usr/local/lib/python3.7/dist-packages/bleak/backends/bluezdbus/client.py", line 172, in on_value_changed
    callback(bytearray(value))
  File "/usr/local/lib/python3.7/dist-packages/gshocktimeserver/connection.py", line 23, in notification_handler
    data_watcher.emit_event(name, value)
  File "/usr/local/lib/python3.7/dist-packages/gshocktimeserver/data_watcher.py", line 55, in emit_event
    subject.on_next(event)
  File "/usr/local/lib/python3.7/dist-packages/reactivex/subject/subject.py", line 59, in on_next
    super().on_next(value)
  File "/usr/local/lib/python3.7/dist-packages/reactivex/observer/observer.py", line 39, in on_next
    self._on_next_core(value)
  File "/usr/local/lib/python3.7/dist-packages/reactivex/subject/subject.py", line 66, in _on_next_core
    observer.on_next(value)
  File "/usr/local/lib/python3.7/dist-packages/reactivex/observer/autodetachobserver.py", line 28, in on_next
    self._on_next(value)
  File "/usr/local/lib/python3.7/dist-packages/gshocktimeserver/gshock_api.py", line 241, in handle_message
    res = result_queue.dequeue(key)
  File "/usr/local/lib/python3.7/dist-packages/gshocktimeserver/result_queue.py", line 22, in dequeue
    value = self.keyed_result_map[key]
KeyError: '1D00'

Python 3.7.3

The watch is disconnected according to the main screen. I made the watch go back to the main screen and restarted the app and I received the error

I got the same error. I double checked too and I have the same changes you just made in your repo to logger.py and connection.py on my raspberry pi.

I used
sudo pip3 install "git+https://github.com/izivkov/GShockTimeServer.git"
to update

I can likely install the new python but that will take me some time to make sure I do it right. I'll let you know my results once I have it running.

same error running it as su.
It's just so weird because it worked once, and now it hasn't worked since

I'll keep playing with it. I tried restarting the service, I tried restarting the pi, same error.

I just got it to work, I changed name of config.ini to config.ini.bak, and it just worked.

pi@raspberrypi:/usr/local/lib/python3.7/dist-packages/gshocktimeserver $ sudo python3 gshock_server.py
==============================================================================================
Short-press lower-right button on your watch to set time...

If Auto-time set on watch, the watch will connect and run automatically up to 4 times per day.
==============================================================================================

write: 10
write: 22
write: 1d00
write: 1e00
write: 1e01
write: 1f00
write: 1f01
Time set at 2023-12-11 20:50:02.480500 on CASIO GPR-B1000

So it works every time I delete config.ini. If I delete config.ini and run it as regular user, the app cannot create config.ini and it continues to work. If I run it as sudo, the app will create a config.ini and it will fail until I delete it.

pi@raspberrypi:/usr/local/lib/python3.7/dist-packages/gshocktimeserver $ sudo rm config.ini
pi@raspberrypi:/usr/local/lib/python3.7/dist-packages/gshocktimeserver $ python3 gshock_server.py
==============================================================================================
Short-press lower-right button on your watch to set time...

If Auto-time set on watch, the watch will connect and run automatically up to 4 times per day.
==============================================================================================

2023-12-11 20:58:24,741 logger   ERROR: ("Got error: [Errno 13] Permission denied: 'config.ini'",)
write: 10
write: 22
write: 1d00
write: 1e00
write: 1e01
write: 1f00
write: 1f01
Time set at 2023-12-11 20:58:30.567453 on CASIO GPR-B1000

It appears that will require su

pi@raspberrypi:/usr/local/lib/python3.7/dist-packages/gshocktimeserver $ python3 gshock_server.py --multi-watch
==============================================================================================
Short-press lower-right button on your watch to set time...

If Auto-time set on watch, the watch will connect and run automatically up to 4 times per day.
==============================================================================================

2023-12-11 21:05:58,854 logger   ERROR: ("Got error: [Errno 13] Permission denied: 'config.ini'",)

It would be interesting to add latitude and longitude here, at least for a rangeman owner somehow. https://github.com/zspuspoki/RangemanSync/blob/main/Rangeman/Services/WatchDataSender/RemoteWatchController.cs
He shows how it is done here

Thanks, I will change that ownership now

It didn't like it when I changed ownership of config.ini and ran the app as owner pi

-rw-r--r-- 1 pi staff 73 Dec 11 21:13 config.ini

pi@raspberrypi:/usr/local/lib/python3.7/dist-packages/gshocktimeserver $ python3 gshock_server.py
==============================================================================================
Short-press lower-right button on your watch to set time...

If Auto-time set on watch, the watch will connect and run automatically up to 4 times per day.
==============================================================================================

write: 10
write: 22
write: 1d00
write: 1d02
2023-12-11 21:14:46,839 root     ERROR: A message handler raised an exception: '1D00'
Traceback (most recent call last):
  File "src/dbus_fast/message_bus.py", line 785, in dbus_fast.message_bus.BaseMessageBus._process_message
  File "/usr/local/lib/python3.7/dist-packages/bleak/backends/bluezdbus/manager.py", line 874, in _parse_msg
    on_value_changed(message.path, self_interface["Value"])
  File "/usr/local/lib/python3.7/dist-packages/bleak/backends/bluezdbus/client.py", line 172, in on_value_changed
    callback(bytearray(value))
  File "/usr/local/lib/python3.7/dist-packages/gshocktimeserver/connection.py", line 23, in notification_handler
    data_watcher.emit_event(name, value)
  File "/usr/local/lib/python3.7/dist-packages/gshocktimeserver/data_watcher.py", line 55, in emit_event
    subject.on_next(event)
  File "/usr/local/lib/python3.7/dist-packages/reactivex/subject/subject.py", line 59, in on_next
    super().on_next(value)
  File "/usr/local/lib/python3.7/dist-packages/reactivex/observer/observer.py", line 39, in on_next
    self._on_next_core(value)

python3 gshock_server.py --multi-watch
That works with config.ini owned by pi

The program did get stuck once at "write 10". I had to shut down the python app and restart.

Is there a way to set the time compensation? The time sync doesn't fluctuate like the android app. The python app is consistently, and approximately one second behind atomic time. I kind of like the idea of having this time server running all the time at my home, but I think my watch needs the lat/lon so it properly updates the moon phase.

I'll look at the code and see what I can do, but I'm no programmer. I last programmed turbo pascal, which I was very good at, a long time ago. I did some programming in C in a class in college which I have since long forgot, but I can read the code somewhat and sometimes modify things and get them to work.

It's not the moon phase that is calculated by lat/lon, it's the sunrise/sunset. After syncing time to the python app, that calculation is completely wrong on the watch. It showed sunrise after noon time.

It didn't update the lat,lon. I did see it request lat and lon, it gave a bytearray, but it did not update my watch with the lat and lon, but the time sync still worked.

I pulled your changes, double checked, I do have them, and ran it and it did not work. The watch does not show updated lat/lon during a time sync. Are there logs I can provide you?

Closing