@@ -37,6 +37,7 @@ class AirPodsTrayApp : public QObject {
3737 Q_PROPERTY (bool notificationsEnabled READ notificationsEnabled WRITE setNotificationsEnabled NOTIFY notificationsEnabledChanged)
3838 Q_PROPERTY (int retryAttempts READ retryAttempts WRITE setRetryAttempts NOTIFY retryAttemptsChanged)
3939 Q_PROPERTY (bool hideOnStart READ hideOnStart CONSTANT)
40+ Q_PROPERTY (bool oneBudANCMode READ oneBudANCMode WRITE setOneBudANCMode NOTIFY oneBudANCModeChanged)
4041
4142public:
4243 AirPodsTrayApp (bool debugMode, bool hideOnStart, QQmlApplicationEngine *parent = nullptr )
@@ -146,6 +147,7 @@ class AirPodsTrayApp : public QObject {
146147 void setNotificationsEnabled (bool enabled) { trayManager->setNotificationsEnabled (enabled); }
147148 int retryAttempts () const { return m_retryAttempts; }
148149 bool hideOnStart () const { return m_hideOnStart; }
150+ bool oneBudANCMode () const { return m_oneBudANCMode; }
149151
150152private:
151153 bool debugMode;
@@ -227,6 +229,29 @@ public slots:
227229 emit conversationalAwarenessChanged (enabled);
228230 }
229231
232+ void setOneBudANCMode (bool enabled)
233+ {
234+ if (m_oneBudANCMode == enabled)
235+ {
236+ LOG_INFO (" One Bud ANC mode is already " << (enabled ? " enabled" : " disabled" ));
237+ return ;
238+ }
239+
240+ LOG_INFO (" Setting One Bud ANC mode to: " << (enabled ? " enabled" : " disabled" ));
241+ QByteArray packet = enabled ? AirPodsPackets::OneBudANCMode::ENABLED
242+ : AirPodsPackets::OneBudANCMode::DISABLED;
243+
244+ if (writePacketToSocket (packet, " One Bud ANC mode packet written: " ))
245+ {
246+ m_oneBudANCMode = enabled;
247+ emit oneBudANCModeChanged (enabled);
248+ }
249+ else
250+ {
251+ LOG_ERROR (" Failed to send One Bud ANC mode command: socket not open" );
252+ }
253+ }
254+
230255 void setRetryAttempts (int attempts)
231256 {
232257 if (m_retryAttempts != attempts)
@@ -440,6 +465,7 @@ private slots:
440465 trayManager->showNotification (
441466 tr (" AirPods Disconnected" ),
442467 tr (" Your AirPods have been disconnected" ));
468+ trayManager->resetTrayIcon ();
443469 }
444470
445471 void bluezDeviceDisconnected (const QString &address, const QString &name)
@@ -697,6 +723,19 @@ private slots:
697723 }
698724 emit airPodsStatusChanged ();
699725 }
726+ else if (data.startsWith (AirPodsPackets::OneBudANCMode::HEADER)) {
727+ auto result = AirPodsPackets::OneBudANCMode::parseState (data);
728+ if (result.has_value ())
729+ {
730+ m_oneBudANCMode = result.value ();
731+ LOG_INFO (" One Bud ANC mode received: " << m_conversationalAwareness);
732+ emit oneBudANCModeChanged (m_conversationalAwareness);
733+ }
734+ else
735+ {
736+ LOG_ERROR (" Failed to parse One Bud ANC mode" );
737+ }
738+ }
700739 else
701740 {
702741 LOG_DEBUG (" Unrecognized packet format: " << data.toHex ());
@@ -926,6 +965,7 @@ private slots:
926965 void crossDeviceEnabledChanged (bool enabled);
927966 void notificationsEnabledChanged (bool enabled);
928967 void retryAttemptsChanged (int attempts);
968+ void oneBudANCModeChanged (bool enabled);
929969
930970private:
931971 QBluetoothSocket *socket = nullptr ;
@@ -953,6 +993,7 @@ private slots:
953993 bool m_secoundaryInEar = false ;
954994 QByteArray m_magicAccIRK;
955995 QByteArray m_magicAccEncKey;
996+ bool m_oneBudANCMode = false ;
956997};
957998
958999int main (int argc, char *argv[]) {
0 commit comments