Hallo,
hier mal ein Beispiel in Python auf einem RaspPi für einen Zugriff auf ein Hub
Die Zeile
hub = pexpect.spawn("gatttool -I")
ruft GATTTOOL auf (das LEGO Protokoll baut auf GATT auf)
Das hier sendet ein connect für die MAC-Adresse des Hub
hub.sendline("connect {0}".format("90:84:2B:10:79:0A"))
Und wartet bis zu 35sec auf eine positive Rückmeldung
hub.expect("Connection successful", timeout=35)
Danach werden einfach Kommandos geschickt.....
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pexpect
from time import sleep
# connect
print("Connecting to Hub ....... "),
hub = pexpect.spawn("gatttool -I")
hub.sendline("connect {0}".format("90:84:2B:10:79:0A"))
hub.expect("Connection successful", timeout=35)
print("Connected!")
# drive
print "Start Motor"
hub.sendline("char-write-cmd 0x0e 0800810000510030")
sleep(2)
print "Change color"
hub.sendline("char-write-cmd 0x0e 0800813200510007")
sleep(2)
print "Stop Motor"
hub.sendline("char-write-cmd 0x0e 0800810000510000")
# disconnect
sleep(1)
print "Disconnect"
hub.sendline("char-write-cmd 0x0e 04000201")
print "End"
##char-write-cmd 0x0e 08008132005100CC // CC = Color
##char-write-cmd 0x0e 0800813200510004 LED
##
##char-write-cmd 0x0e 080081PP005100VV // PP = Port VV = geschwindigkeit
##char-write-cmd 0x0e 0800810000510030 PortA
##char-write-cmd 0x0e 0800810100510050 PortB
hier noch der Link zu JS und Heise
https://www.1000steine.de...amp;id=413562#id413562
und zum BAP unter Win 10 (C#)
https://www.eurobricks.co...ith-a-single-software/
Die Software liegt in einer Dropbox, einfach mal von hinten nach vorne durchblättern, User Cosmick42
Und hier im Kommandozeilenmodus unter LINUX mit installiertem gatttool
gatttool -I
connect 90:84:2B:10:79:0A
// char-write-cmd 0x0e 08008132005100CC
char-write-cmd 0x0e 0800813200510004 LED
// char-write-cmd 0x0e 080081PP005100VV
char-write-cmd 0x0e 0800810000510030 PortA
char-write-cmd 0x0e 0800810100510050 PortB
JuL gefällt das