forked from suborb/GalconController
-
Notifications
You must be signed in to change notification settings - Fork 0
/
galcon.py
44 lines (33 loc) · 1.35 KB
/
galcon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Simple script to demonstrate controlling a Galcon 9001BT valve
#
#https://github.com/suborb/GalconController
import binascii
import struct
import sys
from bluepy import btle
perip = btle.Peripheral(sys.argv[1])
# Needed to wake up device to get the right result
status = perip.getCharacteristics(uuid = "e86802019c4b11e4b5f70002a5d5c51b")[0]
value= status.write(bytes("\x01\x02","utf-8"))
# Read the status
status = perip.getCharacteristics(uuid = "e86801029c4b11e4b5f70002a5d5c51b")[0]
value = status.read()
print(value)
# Irrigation control - valve on
status = perip.getCharacteristics(uuid = "e86801039c4b11e4b5f70002a5d5c51b")[0]
value= status.write(bytes("\x00\x01\x00\x00\x00\x00\x00","utf-8"))
# Read the status
status = perip.getCharacteristics(uuid = "e86801029c4b11e4b5f70002a5d5c51b")[0]
value = status.read()
print(value)
# Irrigation control - valve off
status = perip.getCharacteristics(uuid = "e86801039c4b11e4b5f70002a5d5c51b")[0]
value= status.write(bytes("\x01\x00\x00\x00\x00\x00\x00","utf-8"))
# Read the status
status = perip.getCharacteristics(uuid = "e86801029c4b11e4b5f70002a5d5c51b")[0]
value = status.read()
print(value)
# Send pin code - all pairing is handled on the client side, so it's pointless
# pairing
#status = perip.getCharacteristics(uuid = "e86804019c4b11e4b5f70002a5d5c51b")[0]
#value= status.write(bytes("\x01\x02\x03\x04","utf-8"))