You are not logged in.
Pages: 1
This is a far cry from Archlinux-specific but I've been playing with Bluetooth lately and I made this up as a sort of testing ground. I've seen a few articles around about setting up BT on Arch for a few different uses and figured some people might get some use out of this.
It's a very primitive console, run it with the address of a device and it'll connect and basically let you push instructions through a socket to the device and then it displays the response. I use it to test AT commands and see what the phone says back so I can parse it etc...
It depends on pybluez, there is convenientally a pkgbuild for that in AUR
#!/usr/bin/env python
import sys, time
import bluetooth as bt
if len(sys.argv) < 2:
print "usage: console.py <btaddr>"
sys.exit(0)
def _send(sock, string):
sock.send("%sr" % string)
rs = ''
while True:
try:
data = sock.recv(1024)
if data.strip() == 'OK':
break
else:
rs += data
except bt.BluetoothError, e:
print "error receiving: %s" % str(e)
break
return rs.strip()
sock = bt.BluetoothSocket( bt.RFCOMM )
port = bt.get_available_port( bt.RFCOMM )
sock.connect((sys.argv[1], port))
device = bt.lookup_name(sys.argv[1])
print "connected to %s... /quit to exit" % device
while True:
data = raw_input('>>> ')
if data.strip() == '/quit':
print "disconnecting from %s... have a nice day!" % device
sock.close()
sys.exit(0)
rs = _send(sock, data.strip())
print rs
Offline
Pages: 1