Skip to content

Instantly share code, notes, and snippets.

@nehayward
Created April 12, 2020 17:18
Show Gist options
  • Save nehayward/3f33a0df749cb07d84b789aa3a16f89e to your computer and use it in GitHub Desktop.
Save nehayward/3f33a0df749cb07d84b789aa3a16f89e to your computer and use it in GitHub Desktop.
Acaia Gatt Script
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:17:fc:78 -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 efdd06000000\r"
send -- "char-write-cmd 0x000d efdd0b2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d683b\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