@@ -51,8 +51,8 @@ ChronosESP32::ChronosESP32()
5151 _notifications[0 ].app = " Chronos" ;
5252 _notifications[0 ].message = " Download from Google Play to sync time and receive notifications" ;
5353
54- _infoTimer.duration = 3 * 1000 ; // 3 seconds for info timer
55- _findTimer.duration = 30 * 1000 ; // 30 seconds for find phone
54+ _infoTimer.duration = 3 * 1000 ; // 3 seconds for info timer
55+ _findTimer.duration = 30 * 1000 ; // 30 seconds for find phone
5656}
5757
5858/* !
@@ -180,7 +180,6 @@ void ChronosESP32::loop()
180180 sendESP ();
181181 }
182182 }
183-
184183}
185184
186185/* !
@@ -751,11 +750,10 @@ void ChronosESP32::setNotifyBattery(bool state)
751750void ChronosESP32::sendRealtimeSteps (uint32_t steps, uint32_t calories)
752751{
753752 uint8_t stepsCmd[] = {
754- 0xAB , 0x00 , 0x0E , 0xFF , 0x51 , 0x08 ,
755- (uint8_t )(steps >> 16 ), (uint8_t )(steps >> 8 ), (uint8_t )(steps),
753+ 0xAB , 0x00 , 0x0E , 0xFF , 0x51 , 0x08 ,
754+ (uint8_t )(steps >> 16 ), (uint8_t )(steps >> 8 ), (uint8_t )(steps),
756755 (uint8_t )(calories >> 16 ), (uint8_t )(calories >> 8 ), (uint8_t )(calories),
757- 0x00 , 0x00 , 0x00 , 0x00 , 0x00
758- };
756+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
759757 sendCommand (stepsCmd, 17 );
760758}
761759/* !
@@ -768,8 +766,7 @@ void ChronosESP32::sendRealtimeHeartRate(uint8_t heartRate)
768766{
769767 // AB 00 05 FF 31 0A 49 1B
770768 uint8_t heartCmd[] = {
771- 0xAB , 0x00 , 0x05 , 0xFF , 0x31 , 0x0A , heartRate, 0x1B
772- };
769+ 0xAB , 0x00 , 0x05 , 0xFF , 0x31 , 0x0A , heartRate, 0x1B };
773770 sendCommand (heartCmd, 8 );
774771}
775772
@@ -785,8 +782,7 @@ void ChronosESP32::sendRealtimeBloodPressure(uint8_t systolic, uint8_t diastolic
785782{
786783 // AB 00 05 FF 31 22 71 4C
787784 uint8_t pressureCmd[] = {
788- 0xAB , 0x00 , 0x05 , 0xFF , 0x31 , 0x22 , systolic, diastolic
789- };
785+ 0xAB , 0x00 , 0x05 , 0xFF , 0x31 , 0x22 , systolic, diastolic};
790786 sendCommand (pressureCmd, 8 );
791787}
792788
@@ -800,8 +796,7 @@ void ChronosESP32::sendRealtimeBloodOxygen(uint8_t bloodOxygen)
800796{
801797 // AB 00 05 FF 31 12 62 30
802798 uint8_t oxygenCmd[] = {
803- 0xAB , 0x00 , 0x05 , 0xFF , 0x31 , 0x12 , bloodOxygen, 0x30
804- };
799+ 0xAB , 0x00 , 0x05 , 0xFF , 0x31 , 0x12 , bloodOxygen, 0x30 };
805800 sendCommand (oxygenCmd, 8 );
806801}
807802
@@ -821,8 +816,7 @@ void ChronosESP32::sendRealtimeHealthData(uint8_t heartRate, uint8_t bloodOxygen
821816{
822817 // AB 00 07 FF 32 80 44 61 72 4B
823818 uint8_t healthCmd[] = {
824- 0xAB , 0x00 , 0x07 , 0xFF , 0x32 , 0x80 , heartRate, bloodOxygen, systolic, diastolic
825- };
819+ 0xAB , 0x00 , 0x07 , 0xFF , 0x32 , 0x80 , heartRate, bloodOxygen, systolic, diastolic};
826820 sendCommand (healthCmd, 10 );
827821}
828822
@@ -852,13 +846,12 @@ void ChronosESP32::sendRealtimeHealthData(uint8_t heartRate, uint8_t bloodOxygen
852846void ChronosESP32::sendStepsRecord (uint32_t steps, uint32_t calories, uint8_t hour, uint8_t day, uint8_t month, uint32_t year, uint8_t heartRate, uint8_t bloodOxygen, uint8_t systolic, uint8_t diastolic)
853847{
854848 uint8_t stepsCmd[] = {
855- 0xAB , 0x00 , 0x16 , 0xFF , 0x51 , 0x20 ,
856- (uint8_t )(year - 2000 ), month, day, hour,
857- (uint8_t )(steps >> 16 ), (uint8_t )(steps >> 8 ), (uint8_t )(steps),
849+ 0xAB , 0x00 , 0x16 , 0xFF , 0x51 , 0x20 ,
850+ (uint8_t )(year - 2000 ), month, day, hour,
851+ (uint8_t )(steps >> 16 ), (uint8_t )(steps >> 8 ), (uint8_t )(steps),
858852 (uint8_t )(calories >> 16 ), (uint8_t )(calories >> 8 ), (uint8_t )(calories),
859853 heartRate, bloodOxygen, systolic, diastolic,
860- 0x00 , 0x00 , 0x00 , 0x00 , 0x00
861- };
854+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
862855 sendCommand (stepsCmd, 25 );
863856}
864857
@@ -880,10 +873,9 @@ void ChronosESP32::sendStepsRecord(uint32_t steps, uint32_t calories, uint8_t ho
880873void ChronosESP32::sendHeartRateRecord (uint8_t heartRate, uint8_t minute, uint8_t hour, uint8_t day, uint8_t month, uint32_t year)
881874{
882875 uint8_t heartCmd[] = {
883- 0xAB , 0x00 , 0x0A , 0xFF , 0x51 , 0x11 ,
884- (uint8_t )(year - 2000 ), month, day, hour, minute,
885- heartRate, 0x00
886- };
876+ 0xAB , 0x00 , 0x0A , 0xFF , 0x51 , 0x11 ,
877+ (uint8_t )(year - 2000 ), month, day, hour, minute,
878+ heartRate, 0x00 };
887879 sendCommand (heartCmd, 13 );
888880}
889881
@@ -907,10 +899,9 @@ void ChronosESP32::sendHeartRateRecord(uint8_t heartRate, uint8_t minute, uint8_
907899void ChronosESP32::sendBloodPressureRecord (uint8_t systolic, uint8_t diastolic, uint8_t minute, uint8_t hour, uint8_t day, uint8_t month, uint32_t year)
908900{
909901 uint8_t pressureCmd[] = {
910- 0xAB , 0x00 , 0x0A , 0xFF , 0x51 , 0x14 ,
911- (uint8_t )(year - 2000 ), month, day, hour, minute,
912- systolic, diastolic
913- };
902+ 0xAB , 0x00 , 0x0A , 0xFF , 0x51 , 0x14 ,
903+ (uint8_t )(year - 2000 ), month, day, hour, minute,
904+ systolic, diastolic};
914905 sendCommand (pressureCmd, 13 );
915906}
916907
@@ -932,10 +923,9 @@ void ChronosESP32::sendBloodPressureRecord(uint8_t systolic, uint8_t diastolic,
932923void ChronosESP32::sendBloodOxygenRecord (uint8_t bloodOxygen, uint8_t minute, uint8_t hour, uint8_t day, uint8_t month, uint32_t year)
933924{
934925 uint8_t oxygenCmd[] = {
935- 0xAB , 0x00 , 0x0A , 0xFF , 0x51 , 0x12 ,
936- (uint8_t )(year - 2000 ), month, day, hour, minute,
937- bloodOxygen, 0x00
938- };
926+ 0xAB , 0x00 , 0x0A , 0xFF , 0x51 , 0x12 ,
927+ (uint8_t )(year - 2000 ), month, day, hour, minute,
928+ bloodOxygen, 0x00 };
939929 sendCommand (oxygenCmd, 13 );
940930}
941931
@@ -959,10 +949,9 @@ void ChronosESP32::sendBloodOxygenRecord(uint8_t bloodOxygen, uint8_t minute, ui
959949void ChronosESP32::sendSleepRecord (uint16_t sleepTime, SleepType type, uint8_t minute, uint8_t hour, uint8_t day, uint8_t month, uint32_t year)
960950{
961951 uint8_t sleepCmd[] = {
962- 0xAB , 0x00 , 0x0B , 0xFF , 0x52 , 0x80 ,
963- (uint8_t )(year - 2000 ), month, day, hour, minute,
964- (uint8_t )(type), highByte (sleepTime), lowByte (sleepTime)
965- };
952+ 0xAB , 0x00 , 0x0B , 0xFF , 0x52 , 0x80 ,
953+ (uint8_t )(year - 2000 ), month, day, hour, minute,
954+ (uint8_t )(type), highByte (sleepTime), lowByte (sleepTime)};
966955 sendCommand (sleepCmd, 14 );
967956}
968957
@@ -984,10 +973,9 @@ void ChronosESP32::sendSleepRecord(uint16_t sleepTime, SleepType type, uint8_t m
984973void ChronosESP32::sendTemperatureRecord (float temperature, uint8_t minute, uint8_t hour, uint8_t day, uint8_t month, uint32_t year)
985974{
986975 uint8_t tempCmd[] = {
987- 0xAB , 0x00 , 0x0A , 0xFF , 0x51 , 0x13 ,
988- (uint8_t )(year - 2000 ), month, day, hour, minute,
989- (uint8_t )(temperature), (uint8_t )((uint16_t )(temperature * 100.0 ) % 100 )
990- };
976+ 0xAB , 0x00 , 0x0A , 0xFF , 0x51 , 0x13 ,
977+ (uint8_t )(year - 2000 ), month, day, hour, minute,
978+ (uint8_t )(temperature), (uint8_t )((uint16_t )(temperature * 100.0 ) % 100 )};
991979 sendCommand (tempCmd, 13 );
992980}
993981
@@ -1315,18 +1303,22 @@ void ChronosESP32::onWrite(NimBLECharacteristic *pCharacteristic, NimBLEConnInfo
13151303 }
13161304}
13171305
1318- void ChronosESP32::splitTitle (const String &input, String &title, String &message, int icon) {
1319- int index = input.indexOf (' :' ); // Find the first occurrence of ':'
1320- int newlineIndex = input.indexOf (' \n ' ); // Find the first occurrence of '\n'
1306+ void ChronosESP32::splitTitle (const String &input, String &title, String &message, int icon)
1307+ {
1308+ int index = input.indexOf (' :' ); // Find the first occurrence of ':'
1309+ int newlineIndex = input.indexOf (' \n ' ); // Find the first occurrence of '\n'
13211310
1322- if (index != -1 && index < 30 && (newlineIndex == -1 || newlineIndex > index)) {
1323- // Split only if ':' is before index 30 and there's no '\n' before it
1324- title = input.substring (0 , index);
1325- message = input.substring (index + 1 );
1326- } else {
1327- title = appName (icon); // No valid ':' before index 30, or '\n' appears before ':'
1328- message = input; // Keep the full string in message
1329- }
1311+ if (index != -1 && index < 30 && (newlineIndex == -1 || newlineIndex > index))
1312+ {
1313+ // Split only if ':' is before index 30 and there's no '\n' before it
1314+ title = input.substring (0 , index);
1315+ message = input.substring (index + 1 );
1316+ }
1317+ else
1318+ {
1319+ title = appName (icon); // No valid ':' before index 30, or '\n' appears before ':'
1320+ message = input; // Keep the full string in message
1321+ }
13301322}
13311323
13321324/* !
@@ -1390,7 +1382,7 @@ void ChronosESP32::dataReceived()
13901382 }
13911383 break ;
13921384 }
1393-
1385+
13941386 break ;
13951387 case 0x52 :
13961388 switch (_incomingData.data [5 ])
@@ -1402,7 +1394,7 @@ void ChronosESP32::dataReceived()
14021394 }
14031395 break ;
14041396 }
1405-
1397+
14061398 break ;
14071399 case 0x53 :
14081400 if (configurationReceivedCallback != nullptr )
0 commit comments