File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments