/usr/share/doc/python-bluez/examples/simple/l2capserver.py is in python-bluez 0.18-1build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # file: l2capclient.py
# desc: Demo L2CAP server for pybluez.
# $Id: l2capserver.py 524 2007-08-15 04:04:52Z albert $
import bluetooth
server_sock=bluetooth.BluetoothSocket( bluetooth.L2CAP )
port = 0x1001
server_sock.bind(("",port))
server_sock.listen(1)
#uuid = "94f39d29-7d6d-437d-973b-fba39e49d4ef"
#bluetooth.advertise_service( server_sock, "SampleServerL2CAP",
# service_id = uuid,
# service_classes = [ uuid ]
# )
client_sock,address = server_sock.accept()
print "Accepted connection from ",address
data = client_sock.recv(1024)
print "Data received:", data
while data:
client_sock.send('Echo =>' + data)
data = client_sock.recv(1024)
print "Data received:",data
client_sock.close()
server_sock.close()
|