开发者

Twisted and PyBluez working together?

开发者 https://www.devze.com 2023-03-22 02:37 出处:网络
I want to use twisted and bluetooth together. At the moment I am doing this with PyBluez running in an twisted thread.

I want to use twisted and bluetooth together. At the moment I am doing this with PyBluez running in an twisted thread.

PyBluez just creates some socket (or socket-like? it has a file descriptor like a normal socket) object, basically you do:

sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
sock.connect((device_id,1))

Can't I just insert that socke开发者_StackOverflow中文版t into the twisted reactor somehow and connect it with a Protocol?


You can write a class implementing IReadDescriptor (or IWriteDescriptor) and connect it to reactor, like in this example.


I found this project which combines pybluez with twisted: http://pydoc.net/airi/0.1.1/airi.twisted_bluetooth


This piece of code actually helped me a lot. I now have a working implementation in Twisted.

0

精彩评论

暂无评论...
验证码 换一张
取 消