Bluetooth Low Energy

Raspberry Pi 3B + Blinka

https://learn.adafruit.com/circuitpython-ble-libraries-on-any-computer/getting-python-on-your-host-computer

以下 pip3 を sudo なしで使えと書かれている

pip3 install したものは .local/lib/python3.7/site-packages あたりに入る。

$ pip3 install --upgrade adafruit-blinka-bleio adafruit-circuitpython-ble
$ sudo usermod -a -G bluetooth $USER
$ sudo reboot
$ python3
Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import adafruit_ble
>>> from adafruit_ble.advertising.standard import Advertisement
>>> ble = adafruit_ble.BLERadio()
>>> for adv in ble.start_scan(Advertisement, timeout=5):
...     name = adv.complete_name
...     if not name:
...         continue
...     if name == "ITAG":
...         con = ble.connect(adv)
...         print("connected")
...         break
...
connected
>>> ble.stop_scan()
>>> con
<adafruit_ble.BLEConnection object at 0x752f7950>
>>> con.connected
True
>>> con.pair
<bound method BLEConnection.pair of <adafruit_ble.BLEConnection object at 0x752f7950>>
>>> con.disconnect()

動いているようだ。

bluetooth_low_energy.txt · 最終更新: 2021/09/21 14:47 by Takuya Nishimoto
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0