gshock-api 2.0.3__tar.gz → 2.0.5__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.3/src/gshock_api.egg-info → gshock_api-2.0.5}/PKG-INFO +1 -1
- {gshock_api-2.0.3 → gshock_api-2.0.5}/pyproject.toml +1 -1
- {gshock_api-2.0.3 → gshock_api-2.0.5}/setup.cfg +2 -2
- {gshock_api-2.0.3 → gshock_api-2.0.5}/setup.py +1 -1
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/connection.py +18 -5
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/message_dispatcher.py +0 -1
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/scanner.py +4 -6
- {gshock_api-2.0.3 → gshock_api-2.0.5/src/gshock_api.egg-info}/PKG-INFO +1 -1
- {gshock_api-2.0.3 → gshock_api-2.0.5}/LICENSE.txt +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/README.rst +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/__init__.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/alarms.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/app_notification.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/cancelable_result.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/casio_constants.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/configurator.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/event.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/gshock_api.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/iolib/__init__.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/iolib/alarms_io.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/iolib/app_info_io.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/iolib/app_notification_io.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/iolib/button_pressed_io.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/iolib/dst_for_world_cities_io.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/iolib/dst_watch_state_io.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/iolib/error_io.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/iolib/events_io.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/iolib/settings_io.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/iolib/time_adjustement_io.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/iolib/time_io.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/iolib/timer_io.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/iolib/unknown_io.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/iolib/watch_condition_io.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/iolib/watch_name_io.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/iolib/world_cities_io.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/logger.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/mailsener.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/settings.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/utils.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api/watch_info.py +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api.egg-info/SOURCES.txt +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api.egg-info/dependency_links.txt +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api.egg-info/not-zip-safe +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api.egg-info/requires.txt +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/src/gshock_api.egg-info/top_level.txt +0 -0
- {gshock_api-2.0.3 → gshock_api-2.0.5}/tests/test_code.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "gshock_api" # Change to your project name
|
|
7
|
-
version = "2.0.
|
|
7
|
+
version = "2.0.5"
|
|
8
8
|
description = "Pythgon API for GShock Watches using BLE"
|
|
9
9
|
readme = "README.rst"
|
|
10
10
|
authors = [{ name = "Ivo Zivkov", email = "izivkov@gmail.com" }]
|
|
@@ -5,12 +5,15 @@ from gshock_api.casio_constants import CasioConstants
|
|
|
5
5
|
from gshock_api import message_dispatcher
|
|
6
6
|
from gshock_api.utils import to_casio_cmd
|
|
7
7
|
from gshock_api.logger import logger
|
|
8
|
+
from gshock_api.watch_info import watch_info
|
|
9
|
+
from bleak.backends.device import BLEDevice
|
|
10
|
+
from gshock_api.scanner import scanner
|
|
8
11
|
|
|
9
12
|
class Connection:
|
|
10
|
-
def __init__(self,
|
|
13
|
+
def __init__(self, address = None):
|
|
11
14
|
self.handles_map = self.init_handles_map()
|
|
12
|
-
self.
|
|
13
|
-
self.client =
|
|
15
|
+
self.address = address
|
|
16
|
+
self.client: BleakClient = None
|
|
14
17
|
self.characteristics_map = {}
|
|
15
18
|
|
|
16
19
|
def notification_handler(
|
|
@@ -27,17 +30,27 @@ class Connection:
|
|
|
27
30
|
for char in service.characteristics:
|
|
28
31
|
self.characteristics_map[char.uuid] = char.uuid # Store in map
|
|
29
32
|
|
|
30
|
-
async def connect(self):
|
|
33
|
+
async def connect(self) -> bool:
|
|
31
34
|
try:
|
|
35
|
+
# Scan for device if address not provided
|
|
36
|
+
device = await scanner.scan(device_address=self.address if self.address else None)
|
|
37
|
+
self.address = device.address # Always update with actual device found
|
|
38
|
+
logger.info(f"Found device: {device.name} ({self.address})")
|
|
39
|
+
|
|
40
|
+
self.client = BleakClient(self.address)
|
|
32
41
|
await self.client.connect()
|
|
42
|
+
|
|
33
43
|
await self.init_characteristics_map()
|
|
44
|
+
|
|
34
45
|
await self.client.start_notify(
|
|
35
46
|
CasioConstants.CASIO_ALL_FEATURES_CHARACTERISTIC_UUID,
|
|
36
47
|
self.notification_handler,
|
|
37
48
|
)
|
|
49
|
+
|
|
38
50
|
return True
|
|
51
|
+
|
|
39
52
|
except Exception as e:
|
|
40
|
-
logger.
|
|
53
|
+
logger.warning(f"[GShock Connect] Connection failed: {e}")
|
|
41
54
|
return False
|
|
42
55
|
|
|
43
56
|
async def disconnect(self):
|
|
@@ -4,12 +4,12 @@ from bleak import BleakScanner
|
|
|
4
4
|
from gshock_api.configurator import conf
|
|
5
5
|
from gshock_api.watch_info import watch_info
|
|
6
6
|
from gshock_api.logger import logger
|
|
7
|
-
|
|
7
|
+
from bleak.backends.device import BLEDevice
|
|
8
8
|
|
|
9
9
|
class Scanner:
|
|
10
10
|
CASIO_SERVICE_UUID = "00001804-0000-1000-8000-00805f9b34fb"
|
|
11
11
|
|
|
12
|
-
async def scan(self, device_address=None):
|
|
12
|
+
async def scan(self, device_address=None) -> BLEDevice:
|
|
13
13
|
scanner = BleakScanner()
|
|
14
14
|
logger.info("Scanning for devices...")
|
|
15
15
|
|
|
@@ -22,9 +22,7 @@ class Scanner:
|
|
|
22
22
|
logger.info(f"device: {device}")
|
|
23
23
|
if device is None:
|
|
24
24
|
continue
|
|
25
|
-
|
|
26
|
-
# watch_info.set_name(device.name)
|
|
27
|
-
# watch_info.set_address(device.address)
|
|
25
|
+
|
|
28
26
|
watch_info.set_name_and_model(device.name)
|
|
29
27
|
|
|
30
28
|
conf.put("device.address", device.address)
|
|
@@ -35,8 +33,8 @@ class Scanner:
|
|
|
35
33
|
device = await scanner.find_device_by_address(
|
|
36
34
|
device_address, sys.float_info.max
|
|
37
35
|
)
|
|
36
|
+
watch_info.set_name_and_model(device.name)
|
|
38
37
|
|
|
39
38
|
return device
|
|
40
39
|
|
|
41
|
-
|
|
42
40
|
scanner = Scanner()
|
|
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
|