@@ -181,13 +181,16 @@ String ChronosESP32::getAddress()
181181 @brief set the battery level
182182 @param level
183183 battery level
184+ @param charging
185+ charging state
184186*/
185- void ChronosESP32::setBattery (uint8_t level)
187+ void ChronosESP32::setBattery (uint8_t level, bool charging )
186188{
187- if (batteryLevel != level)
189+ if (batteryLevel != level || isCharging != charging )
188190 {
189191 batteryChanged = true ;
190192 batteryLevel = level;
193+ isCharging = charging;
191194 }
192195}
193196
@@ -470,7 +473,7 @@ void ChronosESP32::sendInfo()
470473*/
471474void ChronosESP32::sendBattery ()
472475{
473- uint8_t batCmd[] = {0xAB , 0x00 , 0x05 , 0xFF , 0x91 , 0x80 , 0x00 , batteryLevel};
476+ uint8_t batCmd[] = {0xAB , 0x00 , 0x05 , 0xFF , 0x91 , 0x80 , isCharging ? 0x01 : 0x00 , batteryLevel};
474477 pCharacteristicTX->setValue (batCmd, 8 );
475478 pCharacteristicTX->notify ();
476479 vTaskDelay (200 );
@@ -670,6 +673,7 @@ void ChronosESP32::dataReceived()
670673 case 0x72 :
671674 {
672675 int icon = incomingData.data [6 ];
676+ int state = incomingData.data [7 ];
673677
674678 String message = " " ;
675679 for (int i = 8 ; i < len; i++)
@@ -698,17 +702,19 @@ void ChronosESP32::dataReceived()
698702 }
699703 break ;
700704 }
701-
702- notificationIndex++;
703- notifications[notificationIndex % NOTIF_SIZE].icon = icon;
704- notifications[notificationIndex % NOTIF_SIZE].app = appName (icon);
705- notifications[notificationIndex % NOTIF_SIZE].time = this ->getTime (" %H:%M" );
706- notifications[notificationIndex % NOTIF_SIZE].message = message;
707-
708- if (notificationReceivedCallback != nullptr )
709- {
710- notificationReceivedCallback (notifications[notificationIndex % NOTIF_SIZE]);
705+ if (state == 0x02 ){
706+ notificationIndex++;
707+ notifications[notificationIndex % NOTIF_SIZE].icon = icon;
708+ notifications[notificationIndex % NOTIF_SIZE].app = appName (icon);
709+ notifications[notificationIndex % NOTIF_SIZE].time = this ->getTime (" %H:%M" );
710+ notifications[notificationIndex % NOTIF_SIZE].message = message;
711+
712+ if (notificationReceivedCallback != nullptr )
713+ {
714+ notificationReceivedCallback (notifications[notificationIndex % NOTIF_SIZE]);
715+ }
711716 }
717+
712718 }
713719 break ;
714720 case 0x73 :
0 commit comments