Bonjour,
J'ai un projet qui à pour but de créer un code en python 3 sur ma Raspberry PI 3 qui à pour but de lire des trames d'octets envoyées depuis un pc qui utilise un dongle bluetooth par ma RPI en utilisant son bluetooth intégré (pas le port série RPI mais bluetooth).
J'ai donc fais plusieurs recherches, mais je n'arrive même pas à faire un bon test pour voir si mon bluetooth marche, le bluetooth RPI marche très bien en ligne de commande, mais le test en code ne marche pas et je reçois une erreur: voici le code:
Code python : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #!/usr/bin/env python # -*- coding: UTF-8 -*- import bluetooth from random import randint bd_addr = "XX:XX:XX:XX:XX:XX" #j'ai mis l'add mac du raspberry que j'ai pris avec la la ligne de commande (bluetoothctl) port = 1 sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM ) sock.connect((bd_addr, port)) rnd = randint(1,3) toSend = "profil:%d" % rnd sock.send(toSend) data = sock.recv(1024) print "received [%s]" % data sock.close()
Voici l'erreur:
sock.connect((bd_addr, port))
File "<string>", line 5, in connect
bluetooth.btcommon.BluetoothError: (113, 'No route to host')
Des indications sur l'erreur?
Des indications(tutos, documentations, codes, ...) sur le but de mon projet?
Je vous remercie
Partager