gshock-api 2.0.7__tar.gz → 2.0.9__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.7/src/gshock_api.egg-info → gshock_api-2.0.9}/PKG-INFO +1 -1
- {gshock_api-2.0.7 → gshock_api-2.0.9}/pyproject.toml +1 -1
- {gshock_api-2.0.7 → gshock_api-2.0.9}/setup.py +1 -1
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/connection.py +7 -3
- gshock_api-2.0.9/src/gshock_api/exceptions.py +13 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/iolib/time_io.py +3 -4
- {gshock_api-2.0.7 → gshock_api-2.0.9/src/gshock_api.egg-info}/PKG-INFO +1 -1
- gshock_api-2.0.7/src/gshock_api/exceptions.py +0 -9
- {gshock_api-2.0.7 → gshock_api-2.0.9}/LICENSE.txt +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/README.rst +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/setup.cfg +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/__init__.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/alarms.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/app_notification.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/cancelable_result.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/casio_constants.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/configurator.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/event.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/gshock_api.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/iolib/__init__.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/iolib/alarms_io.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/iolib/app_info_io.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/iolib/app_notification_io.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/iolib/button_pressed_io.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/iolib/dst_for_world_cities_io.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/iolib/dst_watch_state_io.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/iolib/error_io.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/iolib/events_io.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/iolib/settings_io.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/iolib/time_adjustement_io.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/iolib/timer_io.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/iolib/unknown_io.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/iolib/watch_condition_io.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/iolib/watch_name_io.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/iolib/world_cities_io.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/logger.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/mailsener.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/message_dispatcher.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/scanner.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/settings.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/utils.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api/watch_info.py +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api.egg-info/SOURCES.txt +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api.egg-info/dependency_links.txt +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api.egg-info/not-zip-safe +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api.egg-info/requires.txt +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/src/gshock_api.egg-info/top_level.txt +0 -0
- {gshock_api-2.0.7 → gshock_api-2.0.9}/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.9"
|
|
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" }]
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import asyncio, time
|
|
2
2
|
from tracemalloc import start
|
|
3
3
|
from bleak import BleakClient
|
|
4
|
+
from bleak.exc import BleakDBusError
|
|
4
5
|
from bleak.backends.characteristic import BleakGATTCharacteristic
|
|
5
6
|
from gshock_api.casio_constants import CasioConstants
|
|
6
7
|
from gshock_api import message_dispatcher
|
|
@@ -9,7 +10,7 @@ from gshock_api.logger import logger
|
|
|
9
10
|
from gshock_api.watch_info import watch_info
|
|
10
11
|
from bleak.backends.device import BLEDevice
|
|
11
12
|
from gshock_api.scanner import scanner
|
|
12
|
-
from gshock_api.exceptions import GShockConnectionError
|
|
13
|
+
from gshock_api.exceptions import GShockIgnorableException, GShockConnectionError
|
|
13
14
|
|
|
14
15
|
class Connection:
|
|
15
16
|
def __init__(self, address = None):
|
|
@@ -81,8 +82,11 @@ class Connection:
|
|
|
81
82
|
)
|
|
82
83
|
|
|
83
84
|
except Exception as e:
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
e.args = (type(e).__name__,)
|
|
86
|
+
if isinstance(e, (BleakDBusError, EOFError)):
|
|
87
|
+
raise GShockIgnorableException(e)
|
|
88
|
+
else:
|
|
89
|
+
raise GShockConnectionError(f"Unable to send time to watch: {e}")
|
|
86
90
|
|
|
87
91
|
async def request(self, request):
|
|
88
92
|
await self.write(0xC, request)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# gshock_api/exceptions.py
|
|
2
|
+
|
|
3
|
+
class GShockError(Exception):
|
|
4
|
+
"""Base exception for all G-Shock errors."""
|
|
5
|
+
pass
|
|
6
|
+
|
|
7
|
+
class GShockConnectionError(GShockError):
|
|
8
|
+
"""Raised when BLE connection to G-Shock device fails."""
|
|
9
|
+
pass
|
|
10
|
+
|
|
11
|
+
class GShockIgnorableException(GShockConnectionError):
|
|
12
|
+
"""Raised when BLE connection to G-Shock device fails."""
|
|
13
|
+
pass
|
|
@@ -7,7 +7,7 @@ from gshock_api.logger import logger
|
|
|
7
7
|
|
|
8
8
|
from gshock_api.utils import to_compact_string, to_hex_string
|
|
9
9
|
from gshock_api.casio_constants import CasioConstants
|
|
10
|
-
import
|
|
10
|
+
from gshock_api.exceptions import GShockIgnorableException
|
|
11
11
|
|
|
12
12
|
CHARACTERISTICS = CasioConstants.CHARACTERISTICS
|
|
13
13
|
|
|
@@ -38,12 +38,11 @@ class TimeIO:
|
|
|
38
38
|
)
|
|
39
39
|
try:
|
|
40
40
|
await TimeIO.connection.write(0xE, to_compact_string(time_command))
|
|
41
|
-
except (
|
|
41
|
+
except (GShockIgnorableException) as e:
|
|
42
42
|
# Ignore this exception if the LOWER-RIGHT button is pressed.
|
|
43
43
|
# In this case, the connection will be closed before the call completes with a response, and we get an EOFError.
|
|
44
44
|
# The call actually works, though.
|
|
45
|
-
|
|
46
|
-
logger.info(f"Error {e} ignored due to timeout limitation")
|
|
45
|
+
logger.info(f"Ignoring {e}")
|
|
47
46
|
|
|
48
47
|
class TimeEncoder:
|
|
49
48
|
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
|
|
File without changes
|