Skip to content

Commit d6b98b7

Browse files
committed
linux: fix hearing aid control cmd value
closes #236
1 parent f62a57c commit d6b98b7

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

linux/airpods_packets.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,22 @@ namespace AirPodsPackets
110110
// Hearing Aid
111111
namespace HearingAid
112112
{
113-
using Type = BasicControlCommand<0x2C>;
114-
static const QByteArray ENABLED = Type::ENABLED;
115-
static const QByteArray DISABLED = Type::DISABLED;
116-
static const QByteArray HEADER = Type::HEADER;
117-
inline std::optional<bool> parseState(const QByteArray &data) { return Type::parseState(data); }
113+
static const QByteArray HEADER = ControlCommand::HEADER + static_cast<char>(0x2C);
114+
static const QByteArray ENABLED = ControlCommand::createCommand(0x2C, 0x01, 0x01);
115+
static const QByteArray DISABLED = ControlCommand::createCommand(0x2C, 0x02, 0x02);
116+
117+
inline std::optional<bool> parseState(const QByteArray &data)
118+
{
119+
if (!data.startsWith(HEADER) || data.size() < HEADER.size() + 2)
120+
return std::nullopt;
121+
122+
QByteArray value = data.mid(HEADER.size(), 2);
123+
if (value == QByteArray::fromHex("0101"))
124+
return true;
125+
if (value == QByteArray::fromHex("0202"))
126+
return false;
127+
return std::nullopt;
128+
}
118129
}
119130

120131
// Allow Off Option

0 commit comments

Comments
 (0)