Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
fa04183
Create python-package-conda.yml
izivkov Jun 6, 2023
678a9f6
Added anaconda build
izivkov Jun 6, 2023
78ff3fa
Added anaconda build
izivkov Jun 6, 2023
fc31201
Added anaconda build
izivkov Jun 6, 2023
02d138b
Added anaconda build
izivkov Jun 6, 2023
ac328db
Added anaconda build
izivkov Jun 6, 2023
b7279ed
Added anaconda build
izivkov Jun 6, 2023
1a6c19e
Added anaconda build
izivkov Jun 6, 2023
11d48b9
Added anaconda build
izivkov Jun 6, 2023
d6bf947
Added anaconda build
izivkov Jun 6, 2023
0b4fe60
Added anaconda build
izivkov Jun 6, 2023
d25eaa6
Update README
izivkov Jun 6, 2023
bb1f22b
Update README
izivkov Jun 6, 2023
5d1f8fa
Update README
izivkov Jun 6, 2023
9abf4f5
Update README
izivkov Jun 6, 2023
76be99a
Update README
izivkov Jun 6, 2023
b2de285
Update README.rst
izivkov Jun 6, 2023
dc7095b
Update README.rst
izivkov Jun 6, 2023
ee93e91
Actions
izivkov Jun 6, 2023
bccf1fc
Cleanup code
izivkov Jun 7, 2023
c716a52
Cleanup code
izivkov Jun 7, 2023
eabbedb
Added build script
izivkov Jun 7, 2023
3038cfc
Added prompts when the program starts
izivkov Jun 7, 2023
a042d81
Update README.rst
izivkov Jun 7, 2023
05bfe05
Updated distribution script
izivkov Jun 8, 2023
75a29e3
Display when time updated
izivkov Jun 9, 2023
fe37801
Make compatible with Python 3.8
izivkov Jun 23, 2023
6b6ee05
Update README.rst
izivkov Jun 28, 2023
1e8b8d6
Update README.rst
izivkov Jun 28, 2023
74fd3dd
Update README.rst
Jul 17, 2023
168a04b
Merge pull request #4 from harlock974/main
izivkov Jul 17, 2023
95f7b57
Create protocol.md
Jul 17, 2023
bc76176
Update protocol.md
Jul 18, 2023
9526df8
Merge branch 'izivkov:main' into main
Jul 18, 2023
76196da
Update protocol.md
Jul 18, 2023
45798d8
Update protocol.md
Jul 18, 2023
59b971a
Update protocol.md
Jul 18, 2023
637c1f8
Update protocol.md
Jul 18, 2023
78413b2
Create gatttool_scripts
Jul 28, 2023
e5d1b91
Delete gatttool_scripts
Jul 28, 2023
4dea233
Create readme.md
Jul 28, 2023
c693d7e
Update readme.md
Jul 28, 2023
3cf3616
Update readme.md
Jul 28, 2023
6f47cd9
Update readme.md
Jul 28, 2023
04e245d
Update readme.md
Jul 28, 2023
05e5263
Update readme.md
Jul 29, 2023
6b1e32c
Update readme.md
Jul 29, 2023
a602381
Update readme.md
Jul 29, 2023
af2f1d8
Update protocol.md
Jul 29, 2023
cb0faf2
Update protocol.md
Jul 29, 2023
7fbd475
Add files via upload
Jul 29, 2023
79b4eec
Update readme.md
Jul 29, 2023
5c30f89
Update readme.md
Jul 29, 2023
ec2d57f
Merge pull request #5 from harlock974/main
izivkov Jul 29, 2023
f435d78
Add internal links to gatttool scripts and watch protocol
Aug 10, 2023
493e2be
Update README.rst
Aug 10, 2023
9149f83
Update README.rst
Aug 10, 2023
5813153
Update README.rst
Aug 10, 2023
1543ac1
Merge pull request #8 from harlock974/main
izivkov Aug 10, 2023
422188e
Update README.rst
izivkov Aug 11, 2023
f4d6475
Update README.rst
izivkov Aug 11, 2023
fa74fa9
Update README.rst
izivkov Sep 5, 2023
c47bf62
Model change
izivkov Dec 8, 2023
2add5e6
Merge branch 'main' of https://github.com/izivkov/GShockTimeServer
izivkov Dec 8, 2023
9a1961f
Added warning
izivkov Dec 12, 2023
db43b23
Adding location information when setting time
izivkov Dec 12, 2023
a8fe12c
Can save settings
izivkov Dec 13, 2023
a5bcc43
Cleanup
izivkov Dec 24, 2023
f83328c
WIP
izivkov Jan 8, 2024
985420d
WIP
izivkov Jan 10, 2024
6c7ccbf
WIP
izivkov Jan 10, 2024
9f9a361
Filished alarms
izivkov Jan 11, 2024
d71d910
Optimised setting time
izivkov Jan 13, 2024
415ecbd
Optimised setting time
izivkov Jan 13, 2024
49b5664
WIP
izivkov Jan 14, 2024
2e7f499
Remonders WIP
izivkov Jan 15, 2024
3cb520e
WIP
izivkov Jan 15, 2024
c7b9b19
Completed reminders
izivkov Jan 15, 2024
3ba9c9e
Added anction to skip to the next track
izivkov Jan 17, 2024
282f97a
Completed settings
izivkov Jan 18, 2024
d9e20ed
WIP
izivkov Jan 19, 2024
346c19e
Complted time adjustement
izivkov Jan 19, 2024
898e4d7
Added watch condition
izivkov Jan 20, 2024
9491e93
Added watch condition
izivkov Jan 21, 2024
c00468b
Perssed button completed.
izivkov Jan 21, 2024
abd9566
Completed optimization
izivkov Jan 21, 2024
47bc397
Completed optimization
izivkov Jan 21, 2024
c805906
Fixed logging
izivkov Jan 22, 2024
3c28f4e
Fixed logging
izivkov Jan 22, 2024
45a3566
Optomized code
izivkov Jan 22, 2024
7893e8f
Optomized code
izivkov Jan 22, 2024
cf6d6cf
Optomized code
izivkov Jan 22, 2024
da5ded0
WIP
izivkov Jan 23, 2024
934b1db
Cleanup
izivkov Jan 31, 2024
1cad3da
WIP
izivkov May 17, 2024
07825b4
cleanup
izivkov May 17, 2024
08ec433
WIP
izivkov May 18, 2024
a21b6cf
Added conda configuration
izivkov May 23, 2024
4e44df8
WIP
izivkov May 24, 2024
a8da250
Fix conda file
izivkov Jun 2, 2024
6a235ee
Fix conda file
izivkov Jun 2, 2024
c446a7b
WIP
izivkov Jun 4, 2024
6b228fb
Run server instead ot tests
izivkov Jun 13, 2024
2aeaf8b
Reverted to before splitting API
izivkov Jun 13, 2024
0099490
Merge branch 'main' into HEAD
izivkov Jun 13, 2024
9a1891e
Cleanup
izivkov Jun 13, 2024
52ef03c
Update python-package-conda.yml
izivkov Jun 13, 2024
6d90e67
Fix time setting error
izivkov Jun 19, 2024
dca3a67
Cleanup
izivkov Jun 30, 2024
c31a451
Added support for Edifice ECB-30
izivkov Jul 2, 2024
11e5fb3
Fix blocking on comand 10
izivkov Jul 4, 2024
827f32b
Updated README file
izivkov Jul 7, 2024
7a0af00
Updated README file
izivkov Jul 7, 2024
5d7c8a1
Updated README file
izivkov Jul 7, 2024
7700aca
Updated README file
izivkov Jul 7, 2024
001ecbe
Updated README file
izivkov Jul 7, 2024
ead0867
Updated README file
izivkov Jul 7, 2024
91edbea
Updated README file
izivkov Jul 7, 2024
4c1e7c8
Updated README file
izivkov Jul 7, 2024
44e86ad
Updated README file
izivkov Jul 7, 2024
ede86c5
Updated README file
izivkov Jul 7, 2024
3ec7147
Updated README file
izivkov Jul 8, 2024
edb0410
Updated README file
izivkov Jul 8, 2024
8464c1a
Updated README file
izivkov Jul 8, 2024
c3e751b
Removed RxPy dependency
izivkov Jul 8, 2024
a8f2098
Removed RxPy dependency
izivkov Jul 8, 2024
95560c0
Added GBM-2100 model (which is a GA-2100)
fdlamotte Nov 27, 2024
f3d9a4b
Added the FIND condition (long press on lower right)
fdlamotte Nov 27, 2024
d5380a8
Merge pull request #15 from fdlamotte/gbm-2100
izivkov Nov 27, 2024
cf9b742
Handle problems during connection with a timeout
fdlamotte Dec 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Python Package using Conda

on: [push]

jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
max-parallel: 5

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Install dependencies
run: |
conda update conda
conda env update --file environment.yml --name base
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Temporary and binary files
./build-and-install.sh
*~
*.py[cod]
*.so
Expand All @@ -22,6 +23,7 @@ __pycache__/*
.idea
.vscode
tags
config.ini

# Package files
*.egg
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ formats:
build:
os: ubuntu-22.04
tools:
python: "3.11"
python: "3.10"

python:
install:
Expand Down
11 changes: 11 additions & 0 deletions GShockTimeServer.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/.tox/lib/python3.10/site-packages/bleak/backends/p4android/java" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
20 changes: 0 additions & 20 deletions Pipfile.lock

This file was deleted.

20 changes: 13 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ GShockTimeServer

Overview:
=========
This project allows you to setup time on your Casio G-Shock B5000/B5600/B2100 watches.
This project allows you to set the correct time to your Casio G-Shock `B5600 <https://amzn.to/3Mt68Qb>`__ / `B5000 <https://amzn.to/4194M13>`_ / `B2100 <https://amzn.to/3MUDCGY>`__ watches.

In addition, this repository provides an API for developing application for the above watches. This is WIP,
but you can take a look at the ``api_tests.py`` file on how to use the API.
Expand All @@ -14,14 +14,22 @@ Usage:
This app can run on any device with Python and Bluetooth capabilities - from a desktop to a Raspberry Pi Zero.
It has been tested on Linux OS only, but should be compatible with Windows as well.

.. figure:: images/pizero.jpg
:alt: Pi Zero
:align: center
:width: 200px

The server running on a Pi Zero.

Here is how to use it:

1. Go to /src/gshocktimeserver directory.

2. run:

**python3 gshock_server.py [----multi-watch]**
(the --multi-watch parameter is used if you have multiple watches)
**python3 gshock_server.py [--multi-watch]** (the --multi-watch parameter is used if you have multiple watches)

3. To set the time on your G-Shock, press the ``lower-right`` button and the watch will connect to the app, allowing the app to set the watch's time.
3. To set the time on your G-Shock, short-press the ``lower-right`` button and the watch will connect to the app, allowing the app to set the watch's time.

4. If AUTO TIME ADJUSTEMENT is enabled on the watch, it will sync up to 4 times daily with the app and adjust its time accordingly.

Expand All @@ -34,13 +42,11 @@ Install the following dependencies:

pip3 install bleak

pip3 install reactivex

Troubleshooting:
================
If your watch cannot connect, and the ``--multi-watch`` parameter is not used, remove the "config.ini" file and try again.

To Do:
======
We are working on a professianal installition.
We are working on a professional installation.

6 changes: 6 additions & 0 deletions build-and-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
rm -rf ./dist
python3 setup.py bdist_wheel
scp ./dist/*.whl pi@pizero:/tmp/gshocktimeserver.zip
ssh pi@pizero /home/pi/update.sh


4 changes: 0 additions & 4 deletions config.ini

This file was deleted.

24 changes: 24 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: gshock-time-server
channels:
- defaults
- conda-forge
- pytorch
dependencies:
- python=3.10
- pip
- pip:
- -e . # install git checkout of demo-dsproject in editable mode
- pytz
- bleak
- reactivex

# DEVELOPMENT ONLY PACKAGES (could also be kept in a separate environment file)
- jupyterlab
- pytest
- pytest-cov
- tox
- pre_commit
- nbdime
- nbstripout
- sphinx
- recommonmark
Binary file added images/pizero.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
215 changes: 215 additions & 0 deletions protocol.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
# GShock GAB-2100 BLE protocol

## Overview
Casio bluetooth watches protocol has not been published by the constructor. The following description comes from experiments on the watch and analysis of the code of open source softwares dedicated to communicate with these watches :
* [Ivo Zivkov's GShock API](https://github.com/izivkov/GShockAPI)
* [Ivo Zivkov's GShock time server](https://github.com/izivkov/GShockTimeServer)
* [Gadgetbridge](https://codeberg.org/Freeyourgadget/Gadgetbridge)
* [Gadgetbridge time zone description](https://codeberg.org/johannesk/Gadgetbridge/src/branch/casio-gw-b5600/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gwb5600/CasioGWB5600TimeZone.java)

Syntax and examples come from [gatttool](http://tvaira.free.fr/flower-power/gatttool.txt).

## Commands
### Read (char-read-hnd)
* 0x4 : watch name
* 0x6 : device type
* 0x9 : TX Power level

### Write command (char-write-cmd)
#### 0xc
* 10 : Get button pressed (and other informations ?)
* 22 : Get app info
* 1D00 : Get time zones and DST state of watch
* 1e00 : Get local time zone parameters
* 1e01 : Get WT time zone parameters
* 1f00 : Get local time zone name
* 1f01 : Get WT time zone name

### Write request (char-write-req)
#### 0xe
* 1D00... : Set time zones and DST state of watch
* 1e00... : Set local time zone parameters
* 1e01... : Set WT time zone parameters
* 1f00... : Set local time zone name
* 1f01... : Set WT time zone name

#### 0xf
* 100 : ?

## Data packets

### 10 : button pressed
```
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
10 29 33 9a 4f 60 d3 7f 04 03 0f ff ff ff ff 24 00 00 00
```
8 : 04 : RIGHT BUTTON, 01 : LEFT BUTTON


### 1D00 : time zones and DST state of watch

```
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
1d 00 01 02 03 5b 00 dc 00 ff ff ff ff ff ff
```

0 : 1d

1 : local TZ index

2 : WT TZ index

3 : local TZ DST :
* 02 : No DST
* 03 : DST

4 : WT TZ DST

5-6 : 2 bytes integer (little-endian) : local City numeric identifier = b06 × 256 + b05

7-8 : WT city numeric identifier

### 1E : Time zone parameters

```
0 1 2 3 4 5 6
1e 01 52 00 16 04 00
```

0 : 1e

1 : TZ index :

* 00 : local
* 01 : WT

2-3 : city numeric identifier

4 : signed byte : time difference in quarter of an hour (divide by 4 to get it in hour)

5 : DST offset in quarter of hour : 00 for UTC and 04 for other TZ

6 : DST rules ? :

* 00 : UTC and cities without DST
* 01 : USA cities
* 02 : European cities (LON, PAR, ATH)
* 04 : Australia
* 05 : New Zealand (Wellington)
* 12 : Lord Howe Island
* 17 : Chatam Islands
* 2b : Teheran

## Examples with gatttool
### Installation
gatttool is part of the bluez package. On Debian and derivatives, it could be installed with :

`sudo apt install bluez`

### gatttool usage

Gatttool syntax with examples is described [here](http://tvaira.free.fr/flower-power/gatttool.txt).

Beware of handle and data values, gatttool documentation is confusing. Write command syntax in interactive mode is :

`char-write-cmd <handle> <data>`

* Handle value should be writen in hexadecimal base with 0x prefix.
* Data value should be writen in hexadecimal base **without** 0x prefix.

Example : `char-write-cmd 0xc 1d00`

In non interactive mode, the syntax is :

`gatttool -b <address> --char-write-req -a <handle> -n <data> --listen`

Here handle value can be written either in hexadecimal with prefix or decimal, but data value should be in hexadecimal base **without** prefix.

### Examples

```shell
$ gatttool -b D3:60:4F:9A:33:29 -I -t random
[D3:60:4F:9A:33:29] connect
Attempting to connect to D3:60:4F:9A:33:29
Connection successful
[D3:60:4F:9A:33:29][LE]> char-write-cmd 0xc 10
Notification handle = 0x000e value: 10 29 33 9a 4f 60 d3 7f 04 03 0f ff ff ff ff 24 00 00 00
[D3:60:4F:9A:33:29][LE]> char-read-hnd 0x04
Characteristic value/descriptor: 43 41 53 49 4f 20 47 41 2d 42 32 31 30 30 00 00
[D3:60:4F:9A:33:29][LE]> disconnect
[D3:60:4F:9A:33:29][LE]> quit
```

## Character table

The GAB-2100 character table is a mix of [ASCII](https://en.wikipedia.org/wiki/ASCII) and [JIS X 0201](https://en.wikipedia.org/wiki/JIS_X_0201) with additions:


| | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c | d | e | f |
|-------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| **0** | | | | | | | | | | | | | | | | |
| **1** | | | | | | | | | | | | | | | | |
| **2** | | | | # | $ | % | & | ' | ( | ) | * | + | , |---| . | / |
| **3** | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | : | ; | < | = | > | ? |
| **4** | @ | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O |
| **5** | P | Q | R | S | T | U | V | W | X | Y | Z | [ | \ | ] | ^ | _ |
| **6** | ` | a | b | c | d | e | f | g | h | i | j | k | l | m | n | o |
| **7** | p | q | r | s | t | u | v | w | x | y | z | { | \| | } | ~ | |
| **8** | ¥ | ╏ | « | ¬ |---| ⎺ | ° | ± | ´ | · | ¸ | » | ♦ | ♪ | ■ | < |
| **9** | 【 | 】| ◀ | ▶ | √ | y | | | | | | | | | | |
| **a** | . | 。 | 「 | 」 | 、 | ・ | ヲ | ァ | ィ | ゥ | ェ | ォ | ャ | ュ | ョ | ッ |
| **b** | ー | ア | イ | ウ | エ | オ | カ | キ | ク | ケ | コ | サ | シ | ス | セ | ソ |
| **c** | タ | チ | ツ | テ | ト | ナ | ニ | ヌ | ネ | ノ | ハ | ヒ | フ | ヘ | ホ | マ |
| **d** | ミ | ム | メ | モ | ヤ | ユ | ヨ | ラ | リ | ル | レ | ロ | ワ | ン | ~ | ▫ |
| **e** | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . |
| **f** | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . |

To be completed :
- empty cells are non used blocks
- dots are fields to be completed.

## City list

| Index | HB | LB | NAME | OFFSET | DST_OFFSET | DST_RULE |
| ------|----|----|------|--------|------------|----------|
| 313 | 1 | 39 | BAKER_ISLAND | -12 | 1 | 00 |
| 215 | 0 | D7 | PAGO_PAGO | -11 | 1 | 00 |
| 123 | 0 | 7B | HONOLULU | -10 | 1 | 00 |
| 314 | 1 | 3A | MARQUESAS_ISLANDS | -9.5 | 1 | 00 |
| 12 | 0 | 0C | ANCHORAGE | -9 | 1 | 01 |
| 161 | 0 | A1 | LOS_ANGELES | -8 | 1 | 01 |
| 84 | 0 | 54 | DENVER | -7 | 1 | 01 |
| 66 | 0 | 42 | CHICAGO | -6 | 1 | 01 |
| 202 | 0 | CA | NEW_YORK | -5 | 1 | 01 |
| 113 | 0 | 71 | HALIFAX | -4 | 1 | 01 |
| 268 | 1 | 0C | ST.JOHN'S | -3.5 | 1 | 01 |
| 241 | 0 | F1 | RIO_DE_JANEIRO | -3 | 1 | 00 |
| 98 | 0 | 62 | F.DE_NORONHA | -2 | 1 | 00 |
| 233 | 0 | E9 | PRAIA | -1 | 1 | 00 |
| 0 | 0 | 00 | UTC | 0 | 0 | 00 |
| 160 | 0 | A0 | LONDON | 0 | 1 | 02 |
| 220 | 0 | DC | PARIS | 1 | 1 | 02 |
| 19 | 0 | 13 | ATHENS | 2 | 1 | 02 |
| 133 | 0 | 85 | JEDDAH | 3 | 1 | 00 |
| 278 | 1 | 16 | TEHRAN | 3.5 | 1 | 2B |
| 91 | 0 | 5B | DUBAI | 4 | 1 | 00 |
| 136 | 0 | 88 | KABUL | 4.5 | 1 | 00 |
| 139 | 0 | 8B | KARACHI | 5 | 1 | 00 |
| 82 | 0 | 52 | DELHI | 5.5 | 1 | 00 |
| 140 | 0 | 8C | KATHMANDU | 5.75 | 1 | 00 |
| 86 | 0 | 56 | DHAKA | 6 | 1 | 00 |
| 303 | 1 | 2F | YANGON | 6.5 | 1 | 00 |
| 28 | 0 | 1C | BANGKOK | 7 | 1 | 00 |
| 122 | 0 | 7A | HONG_KONG | 8 | 1 | 00 |
| 234 | 0 | EA | PYONGYANG | 9 | 1 | 00 |
| 310 | 1 | 36 | EUCLA | 8.75 | 1 | 00 |
| 281 | 1 | 19 | TOKYO | 9 | 1 | 00 |
| 5 | 0 | 05 | ADELAIDE | 9.5 | 1 | 04 |
| 271 | 1 | 0F | SYDNEY | 10 | 1 | 04 |
| 311 | 1 | 37 | LORD_HOWE_ISLAND | 10.5 | 0.5 | 12 |
| 205 | 0 | CD | NOUMEA | 11 | 1 | 00 |
| 299 | 1 | 2B | WELLINGTON | 12 | 1 | 05 |
| 63 | 0 | 3F | CHATHAM_ISLANDS | 12.75 | 1 | 17 |
| 208 | 0 | D0 | NUKUALOFA | 13 | 1 | 00 |
| 147 | 0 | 93 | KIRITIMATI | 14 | 1 | 00 |

Loading