2010-01-29 6 views
0

HAI guyz,Envoyer AT-commande via Bluetooth à partir de l'application python

Comment puis-je envoyer AT-commande via Bluetooth à partir d'une application python?

OS: fedora 8

Toute personne s'il vous plaît me healp avec le code?

quel paquet j'ai besoin d'importer?

d'où puis-je le télécharger?

+0

double: http://stackoverflow.com/questions/2161197/send-receive-sms-using-at-command-from- fedora-in-python-application. –

+0

celui-ci spécifiquement pour la connexion bluetooth – RSK

Répondre

1

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() 
1

Pour obtenir une connexion via Bluetooth à votre modem IP, vous souhaitez utiliser le pilote Bluetooth rfcomm:

[email protected]:~> 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"; 
} 

Voici la configuration que j'utilise pour moi - YMMV.

[email protected]:~> 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.

Questions connexes