Envoyer AT-commande via Bluetooth à partir de l'application python
-
23-09-2019 - |
Question
hai guyz,
Comment puis-je envoyer AT-commande via Bluetooth à partir d'une application python?
OS: feutré 8
Toute personne s'il vous plaît me healp avec le code?
quel paquet je dois importer?
Où puis-je télécharger?
La solution 2
Je pense que cela vaut mieux .......
import bluetooth
sockfd = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
sockfd.connect(('00:24:7E:9E:55:0D', 1)) # BT Address
sockfd.send('ATZ\r')
time.sleep(1)
sockfd.send(chr(26))
sockfd.close()
Autres conseils
Pour obtenir une connexion via Bluetooth à votre modem IP, vous souhaitez utiliser le bluetooth pilote rfcomm:
michael@challenger:~> cat /etc/bluetooth/rfcomm.conf
rfcomm0 {
# Automatically bind the device at startup
bind yes;
# Bluetooth address of the device
device 00:1C:CC:XX:XX:XX;
# RFCOMM channel for the connection
channel 1;
# Description of the connection
comment "Blackberry";
}
Ceci est la configuration que j'utilise pour moi - YMMV
.michael@challenger:~> cu -l /dev/rfcomm0
Connected.
ATI
Research in Motion BlackBerry IP Modem
OK
Une fois que vous avez le port rfcomm0, vous traiter le port comme un port série standard et vous êtes bon pour aller.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow