Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 31 additions & 16 deletions AAP Definitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@

AAP runs on top of L2CAP, with a PSM of 0x1001 or 4097.

# Handshake
## Handshake

This packet is necessary to establish a connection with the AirPods. Or else, the AirPods will not respond to any packets.

```plaintext
00 00 04 00 01 00 02 00 00 00 00 00 00 00 00 00
```

# Setting specific features for AirPods Pro 2
## Setting specific features for AirPods Pro 2

> *may work for airpods 4 anc also, not tested*

Since apple likes to wall off some features behind specific OS versions, and apple silicon devices, some packets are necessary to enable these features.
Since apple likes to wall off some features behind specific OS versions, and apple silicon devices, some packets are
necessary to enable these features.

I captured the following packet only accidentally, because Apple being Apple decided to hide *this* and *the handshake* from packetlogger, but sometimes it shows up.
I captured the following packet only accidentally, because Apple being Apple decided to hide *this* and *the
handshake* from packetlogger, but sometimes it shows up.

*Captured using PacketLogger on an Intel Mac running macOS Sequoia 15.0.1*
```plaintext
Expand All @@ -24,11 +27,13 @@ I captured the following packet only accidentally, because Apple being Apple dec

This packet enables conversational awareness when playing audio. (CA works without this packet only when no audio is playing)

It also enables the Adaptive Transparency feature. (We can set Adaptive Transparency, but it doesn't respond with the same packet See [Noise Cancellation](#changing-noise-control))
It also enables the Adaptive Transparency feature. (We can set Adaptive Transparency, but it doesn't respond with the
same packet See [Noise Cancellation](#changing-noise-control))

# Requesting notifications
## Requesting notifications

This packet is necessary to receive notifications from the AirPods like ear detection, noise control mode, conversational awareness, battery status, etc.
This packet is necessary to receive notifications from the AirPods like ear detection, noise control mode,
conversational awareness, battery status, etc.

*Captured using PacketLogger on an Intel Mac running macOS Sequoia 15.0.1*
```plaintext
Expand All @@ -41,7 +46,7 @@ This packet also works.
04 00 04 00 0F 00 FF FF FF FF
```

# Notifications
## Notifications

## Battery

Expand Down Expand Up @@ -92,7 +97,8 @@ Example packet from AirPods Pro 2

## Noise Control

The AirPods Pro 2 send noise control packets when the noise control mode is changed (either by a stem long press or by the connected device, see [Changing noise control](#changing-noise-control)). The packet format is as follows:
The AirPods Pro 2 send noise control packets when the noise control mode is changed (either by a stem long press or
by the connected device, see [Changing noise control](#changing-noise-control)). The packet format is as follows:

```plaintext
04 00 04 00 09 00 0D [mode] 00 00 00
Expand All @@ -108,11 +114,13 @@ The AirPods Pro 2 send noise control packets when the noise control mode is chan
## Ear Detection

AirPods send ear detection packets when the ear detection status changes. The packet format is as follows:

```plaintext
04 00 04 00 06 00 [primary pod] [secondary pod]
```

If primary is removed, mic will be changed and the secondary will be the new primary, so the primary will be the one in the ear, and the packet will be sent again.
If primary is removed, mic will be changed and the secondary will be the new primary, so the primary will be the one
in the ear, and the packet will be sent again.

| Pod Status | Byte value |
|------------|------------|
Expand All @@ -134,9 +142,11 @@ AirPods send conversational awareness packets when the person wearing them start
| 03 | Person Stopped Speaking; increase volume back to normal |
| Intermediate values | Intermediate volume levels |
| 08/09 | Normal Volume |

### Reading Conversational Awareness State

After requesting notifications, the AirPods send a packet indicating the current state of Conversational Awareness (CA). This packet is only sent once after notifications are requested, not when the CA state is changed.
After requesting notifications, the AirPods send a packet indicating the current state of Conversational Awareness
(CA). This packet is only sent once after notifications are requested, not when the CA state is changed.

The packet format is:

Expand All @@ -150,9 +160,11 @@ The packet format is:
- Any other value — Unknown/undetermined state

**Example:**

```plaintext
04 00 04 00 09 00 28 01 00 00 00
```

Here, `01` at the 8th byte (offset 7) means CA is enabled.

## Metadata
Expand All @@ -166,7 +178,7 @@ This packet contains device information like name, model number, etc. The packet
The strings are null-terminated UTF-8 strings in the following order:

1. Bluetooth advertising name (varies in length)
2. Model number
2. Model number
3. Manufacturer
4. Serial number
5. Firmware version
Expand All @@ -180,15 +192,16 @@ The strings are null-terminated UTF-8 strings in the following order:
13. Additional encrypted data

Example packet:

```plaintext
040004001d0002d5000400416972506f64732050726f004133303438004170706c6520496e632e0051584e524848595850360036312e313836383034303030323030303030302e323731330036312e313836383034303030323030303030302e3237313300312e302e3000636f6d2e6170706c652e6163636573736f72792e757064617465722e6170702e3731004859394c5432454632364a59004833504c5748444a32364b3000363335373533360089312a6567a5400f84a3ca234947efd40b90d78436ae5946748d70273e66066a2589300035333935303630363400```

The packet contains device identification and version information followed by some encrypted data whose format is not known.
```

# Writing to the AirPods
## Writing to the AirPods

## Changing Noise Control
### Changing Noise Control

We can send a packet to change the noise control mode. The packet format is as follows:

Expand All @@ -205,7 +218,8 @@ We can send a packet to change the noise control mode. The packet format is as f

The airpods will respond with the same packet after the mode has been changed.

> But if your airpods support Adaptive Transparency, and you haven't sent that [special packet](#setting-specific-features-for-airpods-pro-2) to enable it, the airpods will respond with the same packet but with a different mode (like 0x02).
> But if your airpods support Adaptive Transparency, and you haven't sent that [special packet](#setting-specific-features-for-airpods-pro-2)
to enable it, the airpods will respond with the same packet but with a different mode (like 0x02).

## Renaming AirPods

Expand All @@ -217,7 +231,8 @@ We can send a packet to rename the AirPods. The packet format is as follows:

## Toggle case charging sounds

> *This feature is only for cases with a speaker, i.e. the AirPods Pro 2 and the new AirPods 4. Tested only on AirPods Pro 2*
> *This feature is only for cases with a speaker, i.e. the AirPods Pro 2 and the new AirPods 4. Tested only on
AirPods Pro 2*

We can send a packet to toggle if sounds should be played when the case is connected to a charger. The packet format is as follows:

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
## LibrePods root module changelog

_[See here](https://github.com/kavishdevar/librepods/releases)_
76 changes: 58 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

## What is LibrePods?

LibrePods unlocks Apple's exclusive AirPods features on non-Apple devices. Get access to noise control modes, adaptive transparency, ear detection, hearing aid, customized transparency mode, battery status, and more - all the premium features you paid for but Apple locked to their ecosystem.
Troubleshooting
LibrePods unlocks Apple's exclusive AirPods features on non-Apple devices. Get access to noise control modes,
adaptive transparency, ear detection, hearing aid, customized transparency mode, battery status, and more - all the
premium features you paid for but Apple locked to their ecosystem.

## Device Compatibility

Expand All @@ -13,12 +16,15 @@ LibrePods unlocks Apple's exclusive AirPods features on non-Apple devices. Get a
| ✅ | AirPods Max | Fully supported (client shows unsupported features) |
| ⚠️ | Other AirPods models | Basic features (battery status, ear detection) should work |

Most features should work with any AirPods. Currently, I've only got AirPods Pro 2 to test with. But, I believe the protocol remains the same for all other AirPods (based on analysis of the bluetooth stack on macOS).
Most features should work with any AirPods. Currently, I've only got AirPods Pro 2 to test with. But, I believe the
protocol remains the same for all other AirPods (based on analysis of the bluetooth stack on macOS).

## Key Features

- **Noise Control Modes**: Easily switch between noise control modes without having to reach out to your AirPods to long press
- **Ear Detection**: Controls your music automatically when you put your AirPods in or take them out, and switch to phone speaker when you take them out
- **Noise Control Modes**: Easily switch between noise control modes without having to reach out to your AirPods to
long press
- **Ear Detection**: Controls your music automatically when you put your AirPods in or take them out, and switch to
phone speaker when you take them out
- **Battery Status**: Accurate battery levels
- **Head Gestures**: Answer calls just by nodding your head
- **Conversational Awareness**: Volume automatically lowers when you speak
Expand All @@ -36,7 +42,20 @@ Most features should work with any AirPods. Currently, I've only got AirPods Pro
## Platform Support

### Linux
for the old version see the [Linux README](/linux/README.md). (doesn't have many features, maintainer didn't have time to work on it)

#### How are you install librepods on Linux?

First, you need to clone the entire Git repository. After this, create a build folder inside `linux/` **not in the
root of the repository.**

Once the folder structure is prepared, run CMake inside the build directory, pointing to the `CMakeLists.txt` file
located in the `linux` folder.

Next, compile the generated Makefiles created by the previous step. After the compilation finishes, you should have a
`librepods` executable. Running this file completes the setup and starts LibrePods.

If you need more help, check the [Linux README](/linux/README.md), which provides a more detailed,
copy-and-paste-ready instruction. (doesn't have many features, maintainer didn't have time to work on it)

new version in development ([#241](https://github.com/kavishdevar/librepods/pull/241))

Expand All @@ -61,44 +80,63 @@ https://github.com/user-attachments/assets/43911243-0576-4093-8c55-89c1db5ea533

#### Root Requirement

If you are using ColorOS/OxygenOS 16, you don't need root except for customizing transparency mode, setting up hearing aid, and use Bluetooth Multipoint. Changing ANC, conversational awareness, ear detection, and other customizations will work without root. For everyone else:
If you are using ColorOS/OxygenOS 16, you don't need root except for customizing transparency mode, setting up
hearing aid, and use Bluetooth Multipoint. Changing ANC, conversational awareness, ear detection, and other
customizations will work without root. For everyone else:

> [!CAUTION]
> **You must have a rooted device with Xposed to use LibrePods on Android.** This is due to a [bug in the Android Bluetooth stack](https://issuetracker.google.com/issues/371713238). Please upvote the issue by clicking the '+1' icon on the IssueTracker page. I don't know a fix for Android versions <13 either. So, this needs a phone running A13+.
>
> **You must have a rooted device with Xposed to use LibrePods on Android.** This is due to a [bug in the Android
Bluetooth stack](https://issuetracker.google.com/issues/371713238). Please upvote the issue by clicking the '+1' icon
on the IssueTracker page. I don't know a fix for Android versions <13 either. So, this needs a phone running A13+.
>
> There are **no exceptions** to the root requirement until Google/your OEM figures out a fix.

Until then, you must xposed. I used to provide a non-xposed method too, where the module used overlayfs to replace the bluetooth library with a locally patched one, but that was broken due to how various devices handled overlayfs and a patched library. With xposed, you can also enable the DID hook enabling a few extra features.
Until then, you must xposed. I used to provide a non-xposed method too, where the module used overlayfs to replace
the bluetooth library with a locally patched one, but that was broken due to how various devices handled overlayfs
and a patched library. With xposed, you can also enable the DID hook enabling a few extra features.

## Changing VendorID in the DID profile to that of Apple

Turns out, if you change the VendorID in DID Profile to that of Apple, you get access to several special features!

You can do this on Linux by editing the DeviceID in `/etc/bluetooth/main.conf`. Add this line to the config file `DeviceID = bluetooth:004C:0000:0000`. For android you can enable the `act as Apple device` setting in the app's settings.
You can do this on Linux by editing the DeviceID in `/etc/bluetooth/main.conf`. Add this line to the config file
`DeviceID = bluetooth:004C:0000:0000`. For android you can enable the `act as Apple device` setting in the app's settings.

### Multi-device Connectivity

Upto two devices can be simultaneously connected to AirPods, for audio and control both. Seamless connection switching. The same notification shows up on Apple device when Android takes over the AirPods as if it were an Apple device ("Move to iPhone"). Android also shows a popup when the other device takes over.
Upto two devices can be simultaneously connected to AirPods, for audio and control both. Seamless connection
switching. The same notification shows up on Apple device when Android takes over the AirPods as if it were an Apple
device ("Move to iPhone"). Android also shows a popup when the other device takes over.

### Accessibility Settings and Hearing Aid

Accessibility settings like customizing transparency mode (amplification, balance, tone, conversation boost, and ambient noise reduction), and loud sound reduction can be configured.
Accessibility settings like customizing transparency mode (amplification, balance, tone, conversation boost, and
ambient noise reduction), and loud sound reduction can be configured.

All hearing aid customizations can be done from Android (linux soon), including setting the audiogram result. The app doesn't provide a way to take a hearing test because it requires much more precision. It is much better to use an already available audiogram result.
All hearing aid customizations can be done from Android (linux soon), including setting the audiogram result. The app
doesn't provide a way to take a hearing test because it requires much more precision. It is much better to use an
already available audiogram result.

#### A few notes

- Due to recent AirPods' firmware upgrades, you must enable `Off listening mode` to switch to `Off`. This is because in this mode, loud sounds are not reduced.
- Due to recent AirPods' firmware upgrades, you must enable `Off listening mode` to switch to `Off`. This is because
in this mode, loud sounds are not reduced.

- If you have take both AirPods out, the app will automatically switch to the phone speaker. But, Android might keep on trying to connect to the AirPods because the phone is still connected to them, just the A2DP profile is not connected. The app tries to disconnect the A2DP profile as soon as it detects that Android has connected again if they're not in the ear.
- If you have take both AirPods out, the app will automatically switch to the phone speaker. But, Android might keep
on trying to connect to the AirPods because the phone is still connected to them, just the A2DP profile is not
connected. The app tries to disconnect the A2DP profile as soon as it detects that Android has connected again if
they're not in the ear.

- When renaming your AirPods through the app, you'll need to re-pair them with your phone for the name change to take effect. This is a limitation of how Bluetooth device naming works on Android.
- When renaming your AirPods through the app, you'll need to re-pair them with your phone for the name change to take
effect. This is a limitation of how Bluetooth device naming works on Android.

- If you want the AirPods icon and battery status to show in Android Settings app, install the app as a system app by using the root module.
- If you want the AirPods icon and battery status to show in Android Settings app, install the app as a system app by
using the root module.

## Supporters

A huge thank you to everyone supporting the project!

- @davdroman
- @tedsalmon
- @wiless
Expand All @@ -107,6 +145,7 @@ A huge thank you to everyone supporting the project!
- @ressiwage

## Special thanks

- @tyalie for making the first documentation on the protocol! ([tyalie/AAP-Protocol-Definition](https://github.com/tyalie/AAP-Protocol-Defintion))
- @rithvikvibhu and folks over at lagrangepoint for helping with the hearing aid feature ([gist](https://gist.github.com/rithvikvibhu/45e24bbe5ade30125f152383daf07016))
- @devnoname120 for helping with the first root patch
Expand Down Expand Up @@ -141,4 +180,5 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

All trademarks, logos, and brand names are the property of their respective owners. Use of them does not imply any affiliation with or endorsement by them. All AirPods images, symbols, and the SF Pro font are the property of Apple Inc.
All trademarks, logos, and brand names are the property of their respective owners. Use of them does not imply any
affiliation with or endorsement by them. All AirPods images, symbols, and the SF Pro font are the property of Apple Inc.
Loading