Created
January 26, 2020 23:56
-
-
Save nehayward/28e5f4e3d22b2104b1f0203ee225fb2a to your computer and use it in GitHub Desktop.
Fellow Stagg EKG+ Bluetooth control with gatttool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set action [lindex $argv 0]; | |
set temp [lindex $argv 1]; | |
set on "efdd0a0000010100" | |
set off "efdd0a0100000100" | |
set writeCommand "char-write-cmd 0x000d" | |
spawn gatttool -b 00:1C:97:16:27:13 -I | |
sleep 3 | |
set timeout -1 | |
send -- "connect\r" | |
expect "Connection successful" | |
send -- "char-write-req 0x000e 0100\r" | |
expect "Characteristic value was written successfully" | |
send -- "char-write-cmd 0x000d efdd0b3031323334353637383930313233349a6d\r" | |
if { $action == "on"} { | |
send -- "$writeCommand $on\r" | |
} elseif { $action == "off"} { | |
send -- "$writeCommand $off\r" | |
} elseif { $action == "set"} { | |
set tempInHexidecimal [format %x $temp] | |
set checkSum [format %x [expr {$temp + 02}]] | |
set tempCommand "efdd0a0201${tempInHexidecimal}${checkSum}01" | |
send -- "$writeCommand $tempCommand\r" | |
} | |
send -- "exit\r" | |
expect eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh that's clever I like that solution. I'll give that a try.