Skip to content

Commit

Permalink
Properly wait until sync is over before disconnecting from infinitime
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Robinson committed Mar 2, 2021
1 parent c748e4b commit 10c1884
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 76 deletions.
23 changes: 12 additions & 11 deletions src/bluetooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,17 @@ def disconnect_succeeded(self):
super().disconnect_succeeded()
print("[%s] Disconnected" % (self.mac_address))

def characteristic_write_value_succeeded(self, characteristic):
self.disconnect()

def services_resolved(self):
super().services_resolved()

print("[%s] Resolved services" % (self.mac_address))
for service in self.services:
print("[%s] Service [%s]" % (self.mac_address, service.uuid))
for characteristic in service.characteristics:
if characteristic.uuid == "00002a2b-0000-1000-8000-00805f9b34fb":
print("Current Time")
value = get_current_time()
characteristic.write_value(value)
print("[%s] Characteristic [%s]" % (self.mac_address, characteristic.uuid))

serv = next(
s for s in self.services
if s.uuid == "00001805-0000-1000-8000-00805f9b34fb")
char = next(
c for c in serv.characteristics
if c.uuid == "00002a2b-0000-1000-8000-00805f9b34fb")

char.write_value(get_current_time())

62 changes: 0 additions & 62 deletions src/hex_time.py

This file was deleted.

1 change: 0 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def do_activate(self):
win = SigloWindow(application=self)
win.present()
self.manager.scan_for_infinitime()

win.done_scanning(self.manager)

def do_window_removed(self, window):
Expand Down
1 change: 0 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ siglo_sources = [
'main.py',
'window.py',
'bluetooth.py',
'hex_time.py',
]

install_data(siglo_sources, install_dir: moduledir)
7 changes: 6 additions & 1 deletion src/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class SigloWindow(Gtk.ApplicationWindow):
bbox_scan_fail = Gtk.Template.Child()
bbox_scan_pass = Gtk.Template.Child()
bt_spinner = Gtk.Template.Child()
sync_time_button = Gtk.Template.Child()

def __init__(self, **kwargs):
self.manager = None
Expand Down Expand Up @@ -43,4 +44,8 @@ def sync_time_button_clicked(self, widget):
print("Sync Time button clicked...")
device = InfiniTimeDevice(manager=self.manager, mac_address=self.manager.get_mac_address())
device.connect()
self.info_scan_pass.set_text("InfiniTime Syncing! You may now close Siglo.")
self.info_scan_pass.set_text("InfiniTime Syncing... Success!")
self.bbox_scan_pass.set_visible(False)
self.sync_time_button.set_visible(False)


0 comments on commit 10c1884

Please sign in to comment.