@@ -51,8 +51,8 @@ ChronosESP32::ChronosESP32()
51
51
_notifications[0 ].app = " Chronos" ;
52
52
_notifications[0 ].message = " Download from Google Play to sync time and receive notifications" ;
53
53
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
56
56
}
57
57
58
58
/* !
@@ -180,7 +180,6 @@ void ChronosESP32::loop()
180
180
sendESP ();
181
181
}
182
182
}
183
-
184
183
}
185
184
186
185
/* !
@@ -751,11 +750,10 @@ void ChronosESP32::setNotifyBattery(bool state)
751
750
void ChronosESP32::sendRealtimeSteps (uint32_t steps, uint32_t calories)
752
751
{
753
752
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),
756
755
(uint8_t )(calories >> 16 ), (uint8_t )(calories >> 8 ), (uint8_t )(calories),
757
- 0x00 , 0x00 , 0x00 , 0x00 , 0x00
758
- };
756
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
759
757
sendCommand (stepsCmd, 17 );
760
758
}
761
759
/* !
@@ -768,8 +766,7 @@ void ChronosESP32::sendRealtimeHeartRate(uint8_t heartRate)
768
766
{
769
767
// AB 00 05 FF 31 0A 49 1B
770
768
uint8_t heartCmd[] = {
771
- 0xAB , 0x00 , 0x05 , 0xFF , 0x31 , 0x0A , heartRate, 0x1B
772
- };
769
+ 0xAB , 0x00 , 0x05 , 0xFF , 0x31 , 0x0A , heartRate, 0x1B };
773
770
sendCommand (heartCmd, 8 );
774
771
}
775
772
@@ -785,8 +782,7 @@ void ChronosESP32::sendRealtimeBloodPressure(uint8_t systolic, uint8_t diastolic
785
782
{
786
783
// AB 00 05 FF 31 22 71 4C
787
784
uint8_t pressureCmd[] = {
788
- 0xAB , 0x00 , 0x05 , 0xFF , 0x31 , 0x22 , systolic, diastolic
789
- };
785
+ 0xAB , 0x00 , 0x05 , 0xFF , 0x31 , 0x22 , systolic, diastolic};
790
786
sendCommand (pressureCmd, 8 );
791
787
}
792
788
@@ -800,8 +796,7 @@ void ChronosESP32::sendRealtimeBloodOxygen(uint8_t bloodOxygen)
800
796
{
801
797
// AB 00 05 FF 31 12 62 30
802
798
uint8_t oxygenCmd[] = {
803
- 0xAB , 0x00 , 0x05 , 0xFF , 0x31 , 0x12 , bloodOxygen, 0x30
804
- };
799
+ 0xAB , 0x00 , 0x05 , 0xFF , 0x31 , 0x12 , bloodOxygen, 0x30 };
805
800
sendCommand (oxygenCmd, 8 );
806
801
}
807
802
@@ -821,8 +816,7 @@ void ChronosESP32::sendRealtimeHealthData(uint8_t heartRate, uint8_t bloodOxygen
821
816
{
822
817
// AB 00 07 FF 32 80 44 61 72 4B
823
818
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};
826
820
sendCommand (healthCmd, 10 );
827
821
}
828
822
@@ -852,13 +846,12 @@ void ChronosESP32::sendRealtimeHealthData(uint8_t heartRate, uint8_t bloodOxygen
852
846
void 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)
853
847
{
854
848
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),
858
852
(uint8_t )(calories >> 16 ), (uint8_t )(calories >> 8 ), (uint8_t )(calories),
859
853
heartRate, bloodOxygen, systolic, diastolic,
860
- 0x00 , 0x00 , 0x00 , 0x00 , 0x00
861
- };
854
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
862
855
sendCommand (stepsCmd, 25 );
863
856
}
864
857
@@ -880,10 +873,9 @@ void ChronosESP32::sendStepsRecord(uint32_t steps, uint32_t calories, uint8_t ho
880
873
void ChronosESP32::sendHeartRateRecord (uint8_t heartRate, uint8_t minute, uint8_t hour, uint8_t day, uint8_t month, uint32_t year)
881
874
{
882
875
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 };
887
879
sendCommand (heartCmd, 13 );
888
880
}
889
881
@@ -907,10 +899,9 @@ void ChronosESP32::sendHeartRateRecord(uint8_t heartRate, uint8_t minute, uint8_
907
899
void ChronosESP32::sendBloodPressureRecord (uint8_t systolic, uint8_t diastolic, uint8_t minute, uint8_t hour, uint8_t day, uint8_t month, uint32_t year)
908
900
{
909
901
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};
914
905
sendCommand (pressureCmd, 13 );
915
906
}
916
907
@@ -932,10 +923,9 @@ void ChronosESP32::sendBloodPressureRecord(uint8_t systolic, uint8_t diastolic,
932
923
void ChronosESP32::sendBloodOxygenRecord (uint8_t bloodOxygen, uint8_t minute, uint8_t hour, uint8_t day, uint8_t month, uint32_t year)
933
924
{
934
925
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 };
939
929
sendCommand (oxygenCmd, 13 );
940
930
}
941
931
@@ -959,10 +949,9 @@ void ChronosESP32::sendBloodOxygenRecord(uint8_t bloodOxygen, uint8_t minute, ui
959
949
void ChronosESP32::sendSleepRecord (uint16_t sleepTime, SleepType type, uint8_t minute, uint8_t hour, uint8_t day, uint8_t month, uint32_t year)
960
950
{
961
951
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)};
966
955
sendCommand (sleepCmd, 14 );
967
956
}
968
957
@@ -984,10 +973,9 @@ void ChronosESP32::sendSleepRecord(uint16_t sleepTime, SleepType type, uint8_t m
984
973
void ChronosESP32::sendTemperatureRecord (float temperature, uint8_t minute, uint8_t hour, uint8_t day, uint8_t month, uint32_t year)
985
974
{
986
975
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 )};
991
979
sendCommand (tempCmd, 13 );
992
980
}
993
981
@@ -1315,18 +1303,22 @@ void ChronosESP32::onWrite(NimBLECharacteristic *pCharacteristic, NimBLEConnInfo
1315
1303
}
1316
1304
}
1317
1305
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'
1321
1310
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
+ }
1330
1322
}
1331
1323
1332
1324
/* !
@@ -1390,7 +1382,7 @@ void ChronosESP32::dataReceived()
1390
1382
}
1391
1383
break ;
1392
1384
}
1393
-
1385
+
1394
1386
break ;
1395
1387
case 0x52 :
1396
1388
switch (_incomingData.data [5 ])
@@ -1402,7 +1394,7 @@ void ChronosESP32::dataReceived()
1402
1394
}
1403
1395
break ;
1404
1396
}
1405
-
1397
+
1406
1398
break ;
1407
1399
case 0x53 :
1408
1400
if (configurationReceivedCallback != nullptr )
0 commit comments