Skip to content

Instantly share code, notes, and snippets.

@afedotov
Last active August 18, 2023 18:29
Show Gist options
  • Save afedotov/a025fa5796c9c727b04cf98b293a02f6 to your computer and use it in GitHub Desktop.
Save afedotov/a025fa5796c9c727b04cf98b293a02f6 to your computer and use it in GitHub Desktop.
GAN Smart Timer bluetooth protocol

GAN Smart Timer bluetooth protocol

BLE service

Main service = 0000fff0-0000-1000-8000-00805f9b34fb
    Timer state characteristic (notify) = 0000fff5-0000-1000-8000-00805f9b34fb
    Stored time characteristic (read) = 0000fff2-0000-1000-8000-00805f9b34fb

Data format

(Timestamp) type [4 bytes]:
    0: (uint8) minutes
    1: (uint8) seconds
    2: (uint16le) milliseconds
Stored time characteristic [16 bytes]:
    0: (Timestamp) Current time
    4: (Timestamp) Previous time
    8: (Timestamp) Previous time
   12: (Timestamp) Previous time
Timer state characteristic:
    0: Start prefix = 0xFE
    1: Remaining Data length in bytes
    [2..N]: Data
        2: Data prefix = 0x01
        3: Timer state (0x03 = RUNNING, 0x04 = STOPPED, 0x05 = IDLE, see below...)
        4?: (Timestamp) optional time value, exists only when timer state = 0x04 (STOPPED) or 0x05 (IDLE)
        N-1: (uint16le) CRC-16/CCITT-FALSE of Data part excluding CRC itself

Possible timer states

0x01 = GET_SET: Grace delay is expired and timer is ready to start.
0x02 = HANDS_OFF: Hands removed from the timer before grace delay expired.
0x03 = RUNNING: Timer is start running.
0x04 = STOPPED: Timer is stopped. This event includes recorded time.
0x05 = IDLE: Timer is reset and idle (GAN logo button was pressed). This event also includes time displayed before button was pressed.
0x06 = HANDS_ON: Both hands are placed on the timer.
0x07 = FINISHED: Timer moves to this state automatically after STOPPED state.

Sample event sequence data dump

[GanTimerDriver] Timer event received IDLE: fe 08 01 05 00 00 00 00 e7 68
[GanTimerDriver] Timer event received HANDS_ON: fe 04 01 06 f8 4e
[GanTimerDriver] Timer event received HANDS_OFF: fe 04 01 02 7c 0e
[GanTimerDriver] Timer event received HANDS_ON: fe 04 01 06 f8 4e
[GanTimerDriver] Timer event received GET_SET: fe 04 01 01 1f 3e
[GanTimerDriver] Timer event received RUNNING: fe 04 01 03 5d 1e
[GanTimerDriver] Timer event received STOPPED: fe 08 01 04 00 02 83 01 3c f2
[GanTimerDriver] Timer event received FINISHED: fe 04 01 07 d9 5e
[GanTimerDriver] Timer event received IDLE: fe 08 01 05 00 02 83 01 6d 58
[GanTimerDriver] Timer event received IDLE: fe 08 01 05 00 00 00 00 e7 68
@raphchta
Copy link

raphchta commented Aug 2, 2023

Hello,
I try to return the time with the event stopped, but I have a problem for find the place and the code uint8 for return my time in event STOPPED. I have a error when I try to modified the bite after "fe 08 01 04" in the Even stopped ?
Maybe I have an understanding some where !)
Thanks for your help.

@afedotov
Copy link
Author

afedotov commented Aug 2, 2023

Last two bytes of each event is CRC-16/CCITT-FALSE checksum, you should calculate and set it properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment