GithubHelp home page GithubHelp logo

mausy5043 / bluepy3 Goto Github PK

View Code? Open in Web Editor NEW
15.0 15.0 1.0 1.12 MB

A Python3 interface to Bluetooth LE on Linux.

Home Page: https://pypi.org/project/bluepy3

License: MIT License

Shell 1.29% Makefile 0.99% Python 36.71% C 61.00%
ble bluetooth bluetooth-low-energy pypi python python3 raspberry-pi

bluepy3's Introduction

Hi there ๐Ÿ‘‹

trophy

About me

Hobby-coder since 1982. Started with BASIC on a ZX81, now predominantly using Python 3 on Raspberry Pi and macOS. In real life I'm a chemical engineer with a wide range of experience in extrusion & gravure coating, photographic emulsion making (O/W & silver halide), power plant monitoring and emissions monitoring (using OSIsoft PIMS), fine chemicals manufacturing, process batch control (acc. ISA-88; using CENTUM CS3000 & Foxboro DCS), manufacturing execution (acc. ISA-95), the list goes on...
Currently, my focus is on process automation and batch control acc. ISA-88 and manufacturing execution system applications (MES acc. ISA-95).

Languages

Recently:

  • Python
  • bash
  • VBA
  • PlantUML

Long ago, in a previous life:

  • BASIC
  • MSX BASIC
  • Visual Basic
  • BBC Basic
  • C++

Computers / OSes

Recently:

  • Raspberry Pi
    • Debian Linux
    • Arch Linux
  • Apple Macbook Air / Pro
    • macOS
  • Lenovo T40
    • Windows 10

Long ago:

  • ZX81 / ZX Spectrum
  • Exidy Sorcerer
  • PLC (Ladder & SFC); various brands/models
  • MSX / MSX-2
  • BBC (Acorn) Archimedes
  • Acorn RiscPC
  • Linux
    • Linux 2.2.x - home-made
    • Ubuntu
    • Suse
    • Debian
  • FreeBSD

๐Ÿ”ฅ Flame bait ๐Ÿ”ฅ

  • spaces not tabs, four of them!
  • nano rather than vi/vim or emacs

bluepy3's People

Contributors

mausy5043 avatar pre-commit-ci[bot] avatar retsyx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

retsyx

bluepy3's Issues

Do not use variable-length arrays.

cpplint has a complaint:

bluepy3/bluepy3-helper.c:669:  Do not use variable-length arrays.  Use an appropriately named ('k' followed by CamelCase) compile-time constant for the size.  [runtime/arrays] [1]

[LibreELEC Linux 6.9.5, bluez 5.76] Failed to connect to peripheral

Hello,
maybe someone can help me or know more about the topic
I've build bluepy3 modules in LibreElec toolcain.
First I've used bluez-5.72 src, for building bluepy3, later 5.70, 5.66 - with same results :-(

I have got this issues on amlogic s922x, raspberry pi5 (current LibreElec).
I have got this issues on amlogic s922x - pip3 install (current armbian Ubuntu builds).

On Raspbian debian (bluez-5.66, kernel 6.6.y) it works normal.

what can I do?

see log:

LibreELEC:~/.kodi/addons/script.module.bluepy3/lib/bluepy3 # uname -a
Linux LibreELEC 6.9.5 #1 SMP PREEMPT Sun Jun 23 21:17:04 UTC 2024 aarch64 GNU/Linux
LibreELEC:~/.kodi/addons/script.module.bluepy3/lib/bluepy3 # ls /lib | grep blue
bluetooth
bluez
libbluetooth.so
libbluetooth.so.3
libbluetooth.so.3.19.14
LibreELEC:~/.kodi/addons/script.module.bluepy3/lib/bluepy3 # python btle.py 00:09:34:b2:ca:2b public
00002a00-0000-1000-8000-00805f9b34fb
Connecting to: 00:09:34:b2:ca:2b, address type: public
    -btle- Running /storage/.kodi/addons/script.module.bluepy3/lib/bluepy3/bluepy3-helper
    -btle- Sent:   conn 00:09:34:b2:ca:2b public
    -btle- Got:    # bluepy3-helper.c version undefined built at 16:25:38 on Aug  5 2024
    -btle- Got:    rsp=$stat; state=$tryconn; dst=00:09:34:b2:ca:2b; mtu=h0; sec=low
    -btle- Got:    rsp=$stat; state=$disc; mtu=h0; sec=low
    -btle- Stopping /storage/.kodi/addons/script.module.bluepy3/lib/bluepy3/bluepy3-helper
*** -btle-  Failed to connect. (5)

    -btle- Running /storage/.kodi/addons/script.module.bluepy3/lib/bluepy3/bluepy3-helper
    -btle- Sent:   conn 00:09:34:b2:ca:2b public
    -btle- Got:    # bluepy3-helper.c version undefined built at 16:25:38 on Aug  5 2024
    -btle- Got:    rsp=$stat; state=$tryconn; dst=00:09:34:b2:ca:2b; mtu=h0; sec=low
    -btle- Got:    rsp=$stat; state=$disc; mtu=h0; sec=low
    -btle- Stopping /storage/.kodi/addons/script.module.bluepy3/lib/bluepy3/bluepy3-helper
*** -btle-  Failed to connect. (4)

    -btle- Running /storage/.kodi/addons/script.module.bluepy3/lib/bluepy3/bluepy3-helper
    -btle- Sent:   conn 00:09:34:b2:ca:2b public
    -btle- Got:    # bluepy3-helper.c version undefined built at 16:25:38 on Aug  5 2024
    -btle- Got:    rsp=$stat; state=$tryconn; dst=00:09:34:b2:ca:2b; mtu=h0; sec=low
    -btle- Got:    rsp=$stat; state=$disc; mtu=h0; sec=low
    -btle- Stopping /storage/.kodi/addons/script.module.bluepy3/lib/bluepy3/bluepy3-helper
*** -btle-  Failed to connect. (3)

    -btle- Running /storage/.kodi/addons/script.module.bluepy3/lib/bluepy3/bluepy3-helper
    -btle- Sent:   conn 00:09:34:b2:ca:2b public
    -btle- Got:    # bluepy3-helper.c version undefined built at 16:25:38 on Aug  5 2024
    -btle- Got:    rsp=$stat; state=$tryconn; dst=00:09:34:b2:ca:2b; mtu=h0; sec=low
    -btle- Got:    rsp=$stat; state=$disc; mtu=h0; sec=low
    -btle- Stopping /storage/.kodi/addons/script.module.bluepy3/lib/bluepy3/bluepy3-helper
*** -btle-  Failed to connect. (2)

    -btle- Running /storage/.kodi/addons/script.module.bluepy3/lib/bluepy3/bluepy3-helper
    -btle- Sent:   conn 00:09:34:b2:ca:2b public
    -btle- Got:    # bluepy3-helper.c version undefined built at 16:25:38 on Aug  5 2024
    -btle- Got:    rsp=$stat; state=$tryconn; dst=00:09:34:b2:ca:2b; mtu=h0; sec=low
    -btle- Got:    rsp=$stat; state=$disc; mtu=h0; sec=low
    -btle- Stopping /storage/.kodi/addons/script.module.bluepy3/lib/bluepy3/bluepy3-helper
*** -btle-  Failed to connect. (1)

Traceback (most recent call last):
  File "/storage/.kodi/addons/script.module.bluepy3/lib/bluepy3/btle.py", line 1076, in <module>
    conn = Peripheral(my_device_address)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/storage/.kodi/addons/script.module.bluepy3/lib/bluepy3/btle.py", line 625, in __init__
    self._connect(addr, addrType, iface, timeout)
  File "/storage/.kodi/addons/script.module.bluepy3/lib/bluepy3/btle.py", line 710, in _connect
    raise BTLEConnectError(
BTLEConnectError: (btle) Failed to connect to peripheral 00:09:34:b2:ca:2b, addr type: public, interface None, timeout=32.1
LibreELEC:~/.kodi/addons/script.module.bluepy3/lib/bluepy3 # 
LibreELEC:~/.kodi/addons/script.module.bluepy3/lib/bluepy3 # 
LibreELEC:~/.kodi/addons/script.module.bluepy3/lib/bluepy3 # 
LibreELEC:~/.kodi/addons/script.module.bluepy3/lib/bluepy3 # hcitool lescan
LE Scan ...
00:09:34:B2:CA:2B DM Remote
00:09:34:B2:CA:2B DM Remote Advanced
00:09:34:B2:CA:2B DM Remote
00:09:34:B2:CA:2B DM Remote Advanced
^CLibreELEC:~/.kodi/addons/script.module.bluepy3/lib/bluepy3 # bluetoothctl
[bluetooth]# scan le
[bluetooth]# SetDiscoveryFilter success
[bluetooth]# hci0 type 6 discovering on
[bluetooth]# Discovery started
[bluetooth]# [CHG] Controller 43:54:A2:00:1F:AC Discovering: yes
[bluetooth]# [NEW] Device 00:09:34:B2:CA:2B DM Remote Advanced
[bluetooth]# [CHG] Device 00:09:34:B2:CA:2B RSSI: 0xffffffb4 (-76)
[bluetooth]# [CHG] Device 00:09:34:B2:CA:2B RSSI: 0xffffffb1 (-79)
[bluetooth]# [CHG] Device 00:09:34:B2:CA:2B RSSI: 0xffffffaa (-86)
[bluetooth]# [CHG] Device 00:09:34:B2:CA:2B RSSI: 0xffffffac (-84)
[bluetooth]# [CHG] Device 00:09:34:B2:CA:2B RSSI: 0xffffffb4 (-76)
[bluetooth]# [CHG] Device 00:09:34:B2:CA:2B RSSI: 0xffffffaf (-81)
[bluetooth]# [CHG] Device 00:09:34:B2:CA:2B ManufacturerData.Key: 0x06c4 (1732)
[bluetooth]# [CHG] Device 00:09:34:B2:CA:2B ManufacturerData.Value:
[bluetooth]#   00 00 00 00 00 00                                ......          
[CHG] Device 00:09:34:B2:CA:2B RSSI: 0xffffffb0 (-80)
[CHG] Device 00:09:34:B2:CA:2B RSSI: 0xffffffae (-82)
[bluetooth]# scan off
[bluetooth]# hci0 type 6 discovering off
[bluetooth]# Discovery stopped
[bluetooth]# [CHG] Device 00:09:34:B2:CA:2B RSSI is nil
[bluet00:09:34:B2:CA:2B9:34:B2:CA:2B
[bluetooth]# [CHG] Device 00:09:34:B2:CA:2B Trusted: yes
[bluetooth]# Changing 00:09:34:B2:CA:2B trust succeeded
[blue00:09:34:B2:CA:2B9:34:B2:CA:2B
Attempting to pair with 00:09:34:B2:CA:2B
[bluetooth]# hci0 00:09:34:B2:CA:2B type LE Public connected eir_len 30
[CHG] Device 00:09:34:B2:CA:2B Connected: yes
[DM Remote Advanced]# hci0 00:09:34:B2:CA:2B type LE Public disconnected with reason 1
[DM Remote Advanced]# Failed to pair: org.bluez.Error.AuthenticationTimeout
[CHG] Device 00:09:34:B2:CA:2B Connected: no
[bluetooth]# 

LibreELEC:~/.kodi/addons/script.module.bluepy3/lib/bluepy3 # dmesg | grep Bl
[    0.300044] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 244)
[    8.249019] Bluetooth: Core ver 2.22
[    8.249173] Bluetooth: HCI device and connection manager initialized
[    8.249476] Bluetooth: HCI socket layer initialized
[    8.249494] Bluetooth: L2CAP socket layer initialized
[    8.249845] Bluetooth: SCO socket layer initialized
[    8.487391] Bluetooth: HCI UART driver ver 2.3
[    8.487417] Bluetooth: HCI UART protocol H4 registered
[    8.487540] Bluetooth: HCI UART protocol Three-wire (H5) registered
[    8.487791] Bluetooth: HCI UART protocol Broadcom registered
[    8.487840] Bluetooth: HCI UART protocol QCA registered
[    8.886316] Bluetooth: hci0: BCM: chip id 101
[    8.887349] Bluetooth: hci0: BCM: features 0x2f
[    8.888876] Bluetooth: hci0: BCM4354A2
[    8.888889] Bluetooth: hci0: BCM4356A2 (001.003.015) build 0000
[    8.937416] Bluetooth: hci0: BCM4356A2 'brcm/BCM4356A2.hcd' Patch
[    9.838655] Bluetooth: hci0: BCM: features 0x2f
[    9.840383] Bluetooth: hci0: BCM4356 37.4MHz AMPAK AP6356-0055
[    9.840407] Bluetooth: hci0: BCM4356A2 (001.003.015) build 0266
[    9.861862] Bluetooth: MGMT ver 1.22

Unable to install on RPi Bookworm

I've been running Bluepy on several Bullseye based RPis for awhile. Recently I had to reformat the SD card on one of those Pis, and I decided to upgrade to Bookworm, as it's the latest Pi OS. All went well, except now I can't install Bluepy on the Pi. When I run the "normal" install process the OS throws an error...

sudo pip install bluepy3

results in:
error: externally-managed-environment

This environment is externally managed
To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install.

So I try...

sudo apt install python3-bluepy3

and the response is...

E: Unable to locate package python3-bluepy3

Is there some trick to getting Bluepy (or Bluepy3) installed on Bookworm?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.