LoginSignup
0
2

More than 5 years have passed since last update.

bluetoothの研究 その4

Posted at

概要

bluetoothを理解したかった。
pythonでrfcommサーバしてみた。

環境
android nexus7
raspberry pi 1 b
raspbian jessie 8.0
bluetooth dongle cambridge silicon radio

設定

sudo nano /etc/systemd/system/dbus-org.bluez.service

ExecStart=/usr/lib/bluetooth/bluetoothd --compat
ExecStartPost=/usr/bin/sdptool add SP

インストール

sudo aptitude install python-bluez

pythonでrfcommサーバー

import bluetooth

server_sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
port = 1
server_sock.bind(("", port))
server_sock.listen(1)
client_sock, address = server_sock.accept()
print "Accepted connection from ", address
data = client_sock.recv(1024)
print "received [%s]" % data
client_sock.close()
server_sock.close()

以上。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2