gshock-api 2.0.6__tar.gz → 2.0.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gshock_api-2.0.6/src/gshock_api.egg-info → gshock_api-2.0.7}/PKG-INFO +1 -1
- {gshock_api-2.0.6 → gshock_api-2.0.7}/pyproject.toml +1 -1
- {gshock_api-2.0.6 → gshock_api-2.0.7}/setup.py +1 -1
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/cancelable_result.py +2 -2
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/connection.py +5 -4
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/gshock_api.py +0 -2
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/iolib/time_io.py +9 -4
- {gshock_api-2.0.6 → gshock_api-2.0.7/src/gshock_api.egg-info}/PKG-INFO +1 -1
- {gshock_api-2.0.6 → gshock_api-2.0.7}/LICENSE.txt +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/README.rst +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/setup.cfg +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/__init__.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/alarms.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/app_notification.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/casio_constants.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/configurator.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/event.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/exceptions.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/iolib/__init__.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/iolib/alarms_io.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/iolib/app_info_io.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/iolib/app_notification_io.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/iolib/button_pressed_io.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/iolib/dst_for_world_cities_io.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/iolib/dst_watch_state_io.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/iolib/error_io.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/iolib/events_io.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/iolib/settings_io.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/iolib/time_adjustement_io.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/iolib/timer_io.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/iolib/unknown_io.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/iolib/watch_condition_io.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/iolib/watch_name_io.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/iolib/world_cities_io.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/logger.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/mailsener.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/message_dispatcher.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/scanner.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/settings.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/utils.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api/watch_info.py +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api.egg-info/SOURCES.txt +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api.egg-info/dependency_links.txt +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api.egg-info/not-zip-safe +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api.egg-info/requires.txt +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/src/gshock_api.egg-info/top_level.txt +0 -0
- {gshock_api-2.0.6 → gshock_api-2.0.7}/tests/test_code.py +0 -0
|
@@ -5,7 +5,7 @@ requires = ["setuptools>=61.0"]
|
|
|
5
5
|
|
|
6
6
|
[project]
|
|
7
7
|
name = "gshock_api" # Change to your project name
|
|
8
|
-
version = "2.0.
|
|
8
|
+
version = "2.0.7"
|
|
9
9
|
description = "Pythgon API for GShock Watches using BLE"
|
|
10
10
|
readme = "README.rst"
|
|
11
11
|
authors = [{ name = "Ivo Zivkov", email = "izivkov@gmail.com" }]
|
|
@@ -3,7 +3,7 @@ from typing import Any
|
|
|
3
3
|
from gshock_api.exceptions import GShockConnectionError
|
|
4
4
|
|
|
5
5
|
class CancelableResult:
|
|
6
|
-
def __init__(self, timeout: float =
|
|
6
|
+
def __init__(self, timeout: float = 10.0):
|
|
7
7
|
self._timeout = timeout
|
|
8
8
|
self._future: asyncio.Future[Any] = asyncio.Future()
|
|
9
9
|
|
|
@@ -14,7 +14,7 @@ class CancelableResult:
|
|
|
14
14
|
except asyncio.TimeoutError as e:
|
|
15
15
|
if not self._future.done():
|
|
16
16
|
self._future.set_result('') # or raise an exception instead
|
|
17
|
-
raise GShockConnectionError(f"Timeout occured
|
|
17
|
+
raise GShockConnectionError(f"Timeout occured waiting for response from the watch: {e}") from e
|
|
18
18
|
|
|
19
19
|
def set_result(self, result: Any) -> None:
|
|
20
20
|
if not self._future.done():
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import asyncio
|
|
1
|
+
import asyncio, time
|
|
2
|
+
from tracemalloc import start
|
|
2
3
|
from bleak import BleakClient
|
|
3
4
|
from bleak.backends.characteristic import BleakGATTCharacteristic
|
|
4
5
|
from gshock_api.casio_constants import CasioConstants
|
|
@@ -71,7 +72,7 @@ class Connection:
|
|
|
71
72
|
)
|
|
72
73
|
if (handle == 13):
|
|
73
74
|
logger.info(
|
|
74
|
-
"Your watch does not
|
|
75
|
+
"Your watch does not support notifications..."
|
|
75
76
|
)
|
|
76
77
|
return
|
|
77
78
|
|
|
@@ -80,8 +81,8 @@ class Connection:
|
|
|
80
81
|
)
|
|
81
82
|
|
|
82
83
|
except Exception as e:
|
|
83
|
-
|
|
84
|
-
raise GShockConnectionError(f"Unable to
|
|
84
|
+
print("Exception type:", type(e))
|
|
85
|
+
raise GShockConnectionError(f"Unable to write to G-Shock device: {e}") from e
|
|
85
86
|
|
|
86
87
|
async def request(self, request):
|
|
87
88
|
await self.write(0xC, request)
|
|
@@ -205,8 +205,6 @@ class GshockAPI:
|
|
|
205
205
|
if current_time == None:
|
|
206
206
|
current_time = time.time()
|
|
207
207
|
|
|
208
|
-
self.logger.info(f"=======> passed: ${current_time}, ${time.time()}")
|
|
209
|
-
|
|
210
208
|
await self.initialize_for_setting_time()
|
|
211
209
|
await self._set_time(current_time)
|
|
212
210
|
current_time = None
|
|
@@ -3,17 +3,16 @@ import datetime
|
|
|
3
3
|
import json
|
|
4
4
|
import time
|
|
5
5
|
from typing import Any
|
|
6
|
-
from gshock_api.cancelable_result import CancelableResult
|
|
7
6
|
from gshock_api.logger import logger
|
|
8
7
|
|
|
9
8
|
from gshock_api.utils import to_compact_string, to_hex_string
|
|
10
9
|
from gshock_api.casio_constants import CasioConstants
|
|
10
|
+
import bleak
|
|
11
11
|
|
|
12
12
|
CHARACTERISTICS = CasioConstants.CHARACTERISTICS
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class TimeIO:
|
|
16
|
-
result: CancelableResult = None
|
|
17
16
|
connection = None
|
|
18
17
|
|
|
19
18
|
@staticmethod
|
|
@@ -37,8 +36,14 @@ class TimeIO:
|
|
|
37
36
|
time_command = to_hex_string(
|
|
38
37
|
bytearray([CHARACTERISTICS["CASIO_CURRENT_TIME"]]) + time_data
|
|
39
38
|
)
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
try:
|
|
40
|
+
await TimeIO.connection.write(0xE, to_compact_string(time_command))
|
|
41
|
+
except (Exception) as e:
|
|
42
|
+
# Ignore this exception if the LOWER-RIGHT button is pressed.
|
|
43
|
+
# In this case, the connection will be closed before the call completes with a response, and we get an EOFError.
|
|
44
|
+
# The call actually works, though.
|
|
45
|
+
|
|
46
|
+
logger.info(f"Error {e} ignored due to timeout limitation")
|
|
42
47
|
|
|
43
48
|
class TimeEncoder:
|
|
44
49
|
def prepare_current_time(date: datetime.datetime):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|