Giter VIP home page Giter VIP logo

pbpctrl's Introduction

pbpctrl

Control Google Pixel Buds Pro from the Linux command line. Might or might not work on other Pixel Buds devices.

Allows reading of battery, hardware, software, and runtime information as well as reading and changing settings (ANC state, equalizer, ...).

Installation

Arch Linux

A pbpctrl package is provided via the AUR. Alternatively, the pbpctrl-git package can be used to directly build from the latest state on the main branch.

Installation via cargo

To build install the binary via cargo, run

cargo install pbpctrl --git https://github.com/qzed/pbpctrl/

Use the --tag option if you want to install a specific tag instead of the latest main branch.

Instructions

Pair and connect your Pixel Buds Pro before use. Run pbpctrl help for more information.

Notes on Battery Information

The Pixel Buds Pro support basic battery information via the AVCPR standard. Support for this is still experimental in BlueZ and needs to be enabled manually by editing /etc/bluetooth/main.conf and setting

[General]
Experimental = true

or by starting BlueZ with the --experimental flag. After this, battery status should be provided via UPower.

Note that this, however, will only provide a single battery meter for both buds combined, and none for the case. For more detailed information, use pbpctrl show battery. This also allows reading of the case battery as long as one bud is placed in the case (note that the case does not have a Bluetooth receiver itself).

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

pbpctrl's People

Contributors

qzed avatar

Stargazers

Sam Ollari avatar Ilya avatar  avatar leko avatar Tony Yang avatar  avatar Václav Chlumský avatar Flame Soulis avatar Andrey Gridchin avatar Oliver Marks avatar  avatar Kittipun Khantitrirat avatar Alexander Maslov avatar Sandip Dey avatar vbrabandt2005 avatar  avatar Ted Feng avatar  avatar Code. avatar Zach Schneider avatar Luke avatar István Donkó avatar sadspear avatar Seonghyun Park avatar Sebastian Urban avatar Maxim Therrien avatar Julián Mulet avatar genesaturn avatar dicedtomato avatar TheWanderingShinobi avatar Grant Bacon avatar Frank Chiarulli Jr. avatar Joseph Mignone avatar Tobias Witting avatar Andy Pan avatar Nicolas Barrios avatar  avatar  avatar Christos Veligkos avatar Alex avatar Hamza avatar Kabir Kwatra avatar Andreas Lien avatar Nicolas Fleiter avatar Ural Khamitov avatar cascade avatar Stephan avatar Raqbit avatar Vanilla avatar Caleb Rose avatar Adam Clark avatar Mike avatar  avatar Götz Görisch avatar Sebastian Hammerl avatar Iuri Jikidze avatar

Watchers

Adam Clark avatar Sebastian Hammerl avatar  avatar Kostas Georgiou avatar  avatar

pbpctrl's Issues

Installation issue on Fedora

I tried to install pbpctrl on Fedora Linux using cargo but it failed.

error: failed to run custom build command for maestro v0.1.1

Complete Output
Caused by:
process didn't exit successfully: 
`/tmp/cargo-installtFVNri/release/build/maestro-003457e9a4943146/build-script-build` (exit status: 1)
--- stderr

Error: Custom 
{ 
kind: Other, error: 
"protoc failed: google/protobuf/empty.proto: 
File not found.\nmaestro_pw.proto:5:1: 
Import \"google/protobuf/empty.proto\" was not found or had errors
.\nmaestro_pw.proto:211:25: \"google.protobuf.Empty\" is not defined
.\nmaestro_pw.proto:212:25: \"google.protobuf.Empty\" is not defined
.\nmaestro_pw.proto:213:30: \"google.protobuf.Empty\" is not defined
.\nmaestro_pw.proto:214:45: \"google.protobuf.Empty\" is not defined
.\nmaestro_pw.proto:215:48: \"google.protobuf.Empty\" is not defined
.\nmaestro_pw.proto:217:36: \"google.protobuf.Empty\" is not defined
.\nmaestro_pw.proto:218:32: \"google.protobuf.Empty\" is not defined
.\nmaestro_pw.proto:233:36: \"google.protobuf.Empty\" is not defined
.\nmaestro_pw.proto:234:66: \"google.protobuf.Empty\" is not defined
.\nmaestro_pw.proto:257:51: \"google.protobuf.Empty\" is not defined
.\nmaestro_pw.proto:258:49: \"google.protobuf.Empty\" is not defined.\n" 
}

Is there a way I can fix this? Any help is appreciated.

Plans for a GUI?

Hello, thank you so much for writing this tool, works perfectly with my Pixel Buds Pro!

Were you planning to also write a GUI for this, or are you leaving it up to the community to build a GUI around your tool?

A GUI would be incredibly useful for PostmarketOS or PureOS devices who run mainline Linux.

This is not a request, but merely a question on whether I (or someone else) should consider writing a GUI for pbpctrl, or if you were planning to write one

Doesn't work on A-Series

"Might or might not work on other Pixel Buds devices."

I own a Pixel Buds A-Series and the device isn't auto detected. Trying manually by providing the Bluetooth address and running any command throws a connection error:

pbpctrl --device 0C:C4:13:0B:39:11 show hardware
2023-08-01T12:36:55.947792Z  WARN pbpctrl::bt: connecting to profile failed, trying again (1/3) error=Error { kind: NotAvailable, message: "br-connection-profile-unavailable" }
2023-08-01T12:36:56.949647Z  WARN pbpctrl::bt: connecting to profile failed, trying again (2/3) error=Error { kind: NotAvailable, message: "br-connection-profile-unavailable" }
2023-08-01T12:36:57.951226Z  WARN pbpctrl::bt: connecting to profile failed, trying again (3/3) error=Error { kind: NotAvailable, message: "br-connection-profile-unavailable" }
Error: Bluetooth operation not available: br-connection-profile-unavailable

Anything I can provide to try and make A-Series work?

Can't connect

Help command isn't too useful, I get this error when running -d

josh@josh-desktop:~$ pbpctrl -d
error: a value is required for '--device <DEVICE>' but none was supplied

For more information, try '--help'.

But I get this error when I provide my MAC address

josh@josh-desktop:~$ pbpctrl --device "B8:7B:D4:0A:A8:13"
error: 'pbpctrl' requires a subcommand but one was not provided
  [subcommands: show, get, set, help]

Usage: pbpctrl [OPTIONS] <COMMAND>

For more information, try '--help'.

I'm using Ubuntu 22.04 with earbuds firmware version 5.9

No response from pbpctrl

Hi,

No matter what I try it seems that when I perform any pbpctrl command e.g., pbpctrl show battery, any pbpctrl get [...] command, even when specifying -d 24:29:34:AC:9F:D1, the program just sits with no output until I CTRL+C it.

I tried both the AUR version of pbpctrl and I also tried building with Cargo as instructed. My Pixel Buds Pro are definitely connected via Bluetooth. I can listen to music and use the microphone. bluetoothctl starts with the earbuds connected. My issue occurs with the Experimental option both on and off in Bluez' config.

Is there any way to increase the verbosity of pbpctrl or is that not implemented (potential feature suggestion)?

Thanks for making this project, I appreciate it. Thanks for taking the time to read through these issues as well.

Here's the info from bluetoothctl:

Device 24:29:34:AC:9F:D1 (public)
	Name: Olivia's Pixel Buds Pro
	Alias: Olivia's Pixel Buds Pro
	Class: 0x00240404 (2360324)
	Icon: audio-headset
	Paired: yes
	Bonded: yes
	Trusted: yes
	Blocked: no
	Connected: yes
	WakeAllowed: yes
	LegacyPairing: no
	UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)
	UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
	UUID: Advanced Audio Distribu.. (0000110d-0000-1000-8000-00805f9b34fb)
	UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
	UUID: Handsfree                 (0000111e-0000-1000-8000-00805f9b34fb)
	UUID: Human Interface Device... (00001124-0000-1000-8000-00805f9b34fb)
	UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
	UUID: Vendor specific           (25e97ff7-24ce-4c4c-8951-f764a708f7b4)
	UUID: Vendor specific           (25e97ff7-24ce-4c4c-8951-f764a708f7b5)
	UUID: Vendor specific           (74c34f02-a774-4f6d-ae2e-dab5030b5842)
	UUID: Vendor specific           (81c2e72a-0591-443e-a1ff-05f988593351)
	UUID: Vendor specific           (df21fe2c-2515-4fdb-8886-f12c4d67927c)
	UUID: Vendor specific           (f8d1fbe4-7966-4334-8024-ff96c9330e15)
	Modalias: bluetooth:v00E0p3004d0001
	Battery Percentage: 0x4c (76)

MacOS support

I tried to compile pbpctrl for MacOS.
To solve dependency issues, I installed the missing packages: brew install dbus protobuf.
Then I ran cargo build --release --target aarch64-apple-darwin, but as expected, no success.

Compile output
$ cargo build --release --target aarch64-apple-darwin
   Compiling bluer v0.15.4
error[E0432]: unresolved imports `libc::Ioctl`, `libc::SOCK_CLOEXEC`, `libc::SOCK_NONBLOCK`
 --> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/bluer-0.15.4/src/sock.rs:3:40
  |
3 | use libc::{c_int, sockaddr, socklen_t, Ioctl, SOCK_CLOEXEC, SOCK_NONBLOCK};
  |                                        ^^^^^  ^^^^^^^^^^^^  ^^^^^^^^^^^^^ no `SOCK_NONBLOCK` in the root
  |                                        |      |
  |                                        |      no `SOCK_CLOEXEC` in the root
  |                                        no `Ioctl` in the root
  |
help: a similar name exists in the module
  |
3 | use libc::{c_int, sockaddr, socklen_t, ioctl, SOCK_CLOEXEC, SOCK_NONBLOCK};
  |                                        ~~~~~
help: a similar name exists in the module
  |
3 | use libc::{c_int, sockaddr, socklen_t, Ioctl, O_CLOEXEC, SOCK_NONBLOCK};
  |                                               ~~~~~~~~~
help: a similar name exists in the module
  |
3 | use libc::{c_int, sockaddr, socklen_t, Ioctl, SOCK_CLOEXEC, O_NONBLOCK};
  |                                                             ~~~~~~~~~~

error[E0432]: unresolved imports `libc::SOCK_CLOEXEC`, `libc::SOCK_NONBLOCK`
 --> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/bluer-0.15.4/src/gatt/mod.rs:5:22
  |
5 | use libc::{AF_LOCAL, SOCK_CLOEXEC, SOCK_NONBLOCK, SOCK_SEQPACKET};
  |                      ^^^^^^^^^^^^  ^^^^^^^^^^^^^ no `SOCK_NONBLOCK` in the root
  |                      |
  |                      no `SOCK_CLOEXEC` in the root
  |
help: a similar name exists in the module
  |
5 | use libc::{AF_LOCAL, O_CLOEXEC, SOCK_NONBLOCK, SOCK_SEQPACKET};
  |                      ~~~~~~~~~
help: a similar name exists in the module
  |
5 | use libc::{AF_LOCAL, SOCK_CLOEXEC, O_NONBLOCK, SOCK_SEQPACKET};
  |                                    ~~~~~~~~~~

error[E0432]: unresolved imports `libc::AF_BLUETOOTH`, `libc::SOL_BLUETOOTH`, `libc::TIOCINQ`
  --> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/bluer-0.15.4/src/rfcomm/mod.rs:16:12
   |
16 |     c_int, AF_BLUETOOTH, EAGAIN, EINPROGRESS, MSG_PEEK, SHUT_RD, SHUT_RDWR, SHUT_WR, SOCK_RAW, SOCK_STREAM,
   |            ^^^^^^^^^^^^ no `AF_BLUETOOTH` in the root
17 |     SOL_BLUETOOTH, SOL_SOCKET, SO_ERROR, SO_RCVBUF, TIOCINQ, TIOCOUTQ,
   |     ^^^^^^^^^^^^^ no `SOL_BLUETOOTH` in the root    ^^^^^^^ no `TIOCINQ` in the root

error[E0425]: cannot find function `accept4` in crate `libc`
   --> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/bluer-0.15.4/src/sock.rs:147:15
    |
147 |         libc::accept4(socket.as_raw_fd(), saddr.as_mut_ptr() as *mut _, &mut length, SOCK_CLOEXEC | SOCK_NONBLOCK)
    |               ^^^^^^^ help: a function with a similar name exists: `accept`
    |
   ::: ~/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.139/src/unix/mod.rs:641:5
    |
641 |     pub fn accept(socket: ::c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> ::c_int;
    |     ---------------------------------------------------------------------------------------------- similarly named function `accept` defined here

Some errors have detailed explanations: E0425, E0432.
For more information about an error, try `rustc --explain E0425`.
error: could not compile `bluer` due to 4 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile `bluer` due to 4 previous errors

Is it possible to use something crossplatform for bluetooth bindings?

Does not work with latest firmware update (5.9)

Google just released a new firmware update 5.9 for the buds and unfortunately pbpctrl does no longer work for me. Every command just hangs and does not return.

Can you reproduce this? I really like your tool and would love being able to use it with the latest firmware.

Btw: there were also new features/toggles introduced with the new firmware like "transparent mode on when speaking". It would be cool if pbpctrl also would support them.

Thank you!

I just wanted to thank you for this project, I just tried it and it worked out of the box. Also the tip with enabling the experimental flag added the battery info to my bluetooth KDE widget which is nice!

Perhaps you might want to talk to the GadgetBridge people (https://codeberg.org/Freeyourgadget/Gadgetbridge/) they already have implemented some other buds and the Pixel Buds Pro would be a nice addition.

Regards, Sebastian

Firmware Update

Does pbpctrl support firmware updates, or was it deemed too risky to implement?

I think fw updates for the pixel buds are signed and checksum'd by Google, so it wouldn't be possible to send a corrupted update to brick the headphones.

Can't connect

Help command isn't too useful, I get this error when running -d

josh@josh-desktop:~$ pbpctrl -d
error: a value is required for '--device <DEVICE>' but none was supplied

For more information, try '--help'.

But I get this error when I provide my MAC address

josh@josh-desktop:~$ pbpctrl --device "B8:7B:D4:0A:A8:13"
error: 'pbpctrl' requires a subcommand but one was not provided
  [subcommands: show, get, set, help]

Usage: pbpctrl [OPTIONS] <COMMAND>

For more information, try '--help'.

I'm using Ubuntu 22.04 with earbuds firmware version 5.9

Option for cycling through anc options

It would be nice if pbpctrl set anc could have an option that allows you to cycle through ANC modes instead of only allowing you to set it. This would make it easy to create a keyboard shortcut to cycle through the ANC modes, following the order configured on the device.

Assistant capability and reverse-engineering thereof

I have had this idea for some time, but have very little information to do away with.

Thankfully, Pixel Buds Pro work well with GrapheneOS on Android, so I had been wondering: you know how these support AI assist via Google Assistant application? Now that there's many Mac Studio's and Ryzen DDR5-based inference environments in the market, on-premise cloud deployments have become more commonplace. Also: there has been improvements on-edge, namely whisper.cpp and llama.cpp builds via Android NDK are able to leverage local accelerators.

Is there a chance that the proprietary AI assist capability from Google isn't entirely proprietary?

I wonder if AI assist is ultimately implemented using some signalling protocol over Bluetooth that basically defers to recording and subsequent playback of arbitrary audio. Obviously, there's playback interrupt features but it's probably handled by the firmware itself. If this is the case, then we could potentially modify Pixel Buds application itself to use alternative inference providers.

Based on what you know about Bluetooth & Pixel Buds specifically, how hard could it be, and where would we want to start to learn specifically what's happening under the hood? If it should involve reverse-engineering the relevant apk's, would it also be tractable? If yes, what are the chances it would yield readable, meaningful results? I reckon they probably use NDK themselves, tapping into Android's bluetooth internals, and from the symbols & sniffing alone would it be possible to infer complete logic?

P.S. Great work, your code is quite tidy & indeed, would be worthwhile to investigate how what you do relates to what they do.

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.