Bluethooth Polor H7 Sensor
Verfasst: Mittwoch 8. Januar 2020, 11:46
Hallo,
ich bin mit python noch nicht sehr vertraut.
Ich möchte von meinem Polar H7 Herzfrequnz-Sensor den aktuellen Puls auf meinen PC(linux) ausgeben.
Mit dem Tool bluetoothctl kann ich den Sensor identifizieren und der aktuelle Puls wird auf der Konsole als hex-Wert dargestellt.
Auszug von bluetoothctl:
[CHG] Device 00:22:D0:E1:5E:00 RSSI: -82
[CHG] Device 00:22:D0:E1:5E:00 ManufacturerData Key: 0x006b
[CHG] Device 00:22:D0:E1:5E:00 ManufacturerData Value:
2f 06 42 40
Der Wert 40 ist der Puls als Hex-Wert, also Puls 64
Mein Gedanke war nun die Darstellung in python zu realisieren und den Pulswert als große Zahl auf dem Display darzustellen.
Als Beispiel-Code für die bluethooth Schnittstelle habe ich gefunden:
import socket
hostMACAddress = '08:D4:0C:B4:10:B2' # The MAC address of a Bluetooth adapter host.
port = 3 # 3 is an arbitrary choice. However, it must match the port used by the client.
backlog = 1
size = 1024
s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM)
s.bind((hostMACAddress,port))
s.listen(backlog)
try:
client, address = s.accept()
while 1:
data = client.recv(size)
if data:
print(data)
client.send(data)
except:
print("Closing socket")
client.close()
s.close()
Die Mac-Adressen hab ich entsprechend meines PC angepasst.
Leider erhalte ich keine Ausgabe
Frage: wo liegt hier mein Fehler?
ich bin mit python noch nicht sehr vertraut.
Ich möchte von meinem Polar H7 Herzfrequnz-Sensor den aktuellen Puls auf meinen PC(linux) ausgeben.
Mit dem Tool bluetoothctl kann ich den Sensor identifizieren und der aktuelle Puls wird auf der Konsole als hex-Wert dargestellt.
Auszug von bluetoothctl:
[CHG] Device 00:22:D0:E1:5E:00 RSSI: -82
[CHG] Device 00:22:D0:E1:5E:00 ManufacturerData Key: 0x006b
[CHG] Device 00:22:D0:E1:5E:00 ManufacturerData Value:
2f 06 42 40
Der Wert 40 ist der Puls als Hex-Wert, also Puls 64
Mein Gedanke war nun die Darstellung in python zu realisieren und den Pulswert als große Zahl auf dem Display darzustellen.
Als Beispiel-Code für die bluethooth Schnittstelle habe ich gefunden:
import socket
hostMACAddress = '08:D4:0C:B4:10:B2' # The MAC address of a Bluetooth adapter host.
port = 3 # 3 is an arbitrary choice. However, it must match the port used by the client.
backlog = 1
size = 1024
s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM)
s.bind((hostMACAddress,port))
s.listen(backlog)
try:
client, address = s.accept()
while 1:
data = client.recv(size)
if data:
print(data)
client.send(data)
except:
print("Closing socket")
client.close()
s.close()
Die Mac-Adressen hab ich entsprechend meines PC angepasst.
Leider erhalte ich keine Ausgabe
Frage: wo liegt hier mein Fehler?