Skip to content

Commit 402f84d

Browse files
committed
Add time.nist.gov as alt time server
Signed-off-by: John Walicki <[email protected]>
1 parent df6158a commit 402f84d

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

firmware/WatsonIoT/src/main.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ bool fifoFull = false;
115115
int fifoCount = 0;
116116
int STA_len = 32; // can change to 125
117117
int LTA_len = 320; // can change to 1250
118-
int QUE_len = LTA_len + STA_len;
118+
int QUE_len = LTA_len + STA_len;
119119

120120
// --------------------------------------------------------------------------------------------
121121
// Variables to hold accelerometer data
@@ -658,7 +658,7 @@ void NetworkEvent(WiFiEvent_t event) {
658658
// MQTT SSL requires a relatively accurate time between broker and client
659659
void SetTimeESP32() {
660660
// Set time from NTP servers
661-
configTime(TZ_OFFSET * 3600, TZ_DST * 60, "pool.ntp.org", "0.pool.ntp.org");
661+
configTime(TZ_OFFSET * 3600, TZ_DST * 60, "time.nist.gov", "pool.ntp.org");
662662
Serial.println("\nWaiting for time");
663663
while(time(nullptr) <= 100000) {
664664
NeoPixelStatus( LED_FIRMWARE_DFU ); // blink yellow
@@ -778,8 +778,8 @@ double stalta[3] = { 0, 0, 0 };
778778
double sample[3] = { 0, 0, 0 };
779779
double sampleSUM[3] = { 0, 0, 0 };
780780
double ltSUM[3] = { 0, 0, 0 };
781-
double sample1[3] = { 0, 0, 0 };
782-
double LTAsample1[3] = { 0, 0, 0 };
781+
double sample1[3] = { 0, 0, 0 };
782+
double LTAsample1[3] = { 0, 0, 0 };
783783
double offset[3] = { 0, 0, 0 };
784784
double sampleABS[3] = { 0, 0, 0 };
785785
double sample1ABS = 0;
@@ -845,17 +845,17 @@ void loop() {
845845
// But why are the first two z samples bad ?
846846
// Serial.printf(".sample[2] = %f ", sample[2]);
847847
for (int j = 0; j < 3; j++) {
848-
sampleSUM[j] += sample[j];
849-
}
848+
sampleSUM[j] += sample[j];
849+
}
850850
}
851851
}
852852
// Serial.printf(".offset = ");
853853
for (int j = 0; j < 3; j++) {
854-
offset[j] = sampleSUM[j] / (QUE_len-2);
855-
// Serial.printf( " %f ", offset[j]);
854+
offset[j] = sampleSUM[j] / (QUE_len-2);
855+
// Serial.printf( " %f ", offset[j]);
856856
}
857857
// Serial.printf("\n");
858-
858+
859859
//// find lta
860860
sampleSUM[0] = 0;
861861
sampleSUM[1] = 0;
@@ -867,14 +867,14 @@ void loop() {
867867
sampleABS[1] = abs( AccelRecord.y - offset[1] );
868868
sampleABS[2] = abs( AccelRecord.z - offset[2] );
869869
for (int j = 0; j < 3; j++) {
870-
sampleSUM[j] += sampleABS[j];
870+
sampleSUM[j] += sampleABS[j];
871871
}
872872
}
873873
}
874874
// Serial.printf(".sum32abs = ");
875875
for (int j = 0; j < 3; j++) {
876-
ltav[j] = sampleSUM[j] / (LTA_len-2);
877-
// Serial.printf( " %f ", sampleSUM[j]);
876+
ltav[j] = sampleSUM[j] / (LTA_len-2);
877+
// Serial.printf( " %f ", sampleSUM[j]);
878878
}
879879

880880
//// find sta
@@ -888,22 +888,22 @@ void loop() {
888888
sampleABS[1] = abs( AccelRecord.y - offset[1] );
889889
sampleABS[2] = abs( AccelRecord.z - offset[2] );
890890
for (int j = 0; j < 3; j++) {
891-
sampleSUM[j] += sampleABS[j];
891+
sampleSUM[j] += sampleABS[j];
892892
}
893893
}
894894
}
895895
for (int j = 0; j < 3; j++) {
896-
stav[j] = sampleSUM[j] / STA_len;
896+
stav[j] = sampleSUM[j] / STA_len;
897897
stalta[j] = stav[j] / ltav[j];
898-
if ( bPossibleEarthQuake==false ) {
898+
if ( bPossibleEarthQuake==false ) {
899899
if ( stalta[j] >= thresh ) {
900900
// Whoa - STA/LTA algorithm detected some anomalous shaking
901901
Serial.printf("%f = %f / %f (%i) s0\n", stalta[j], stav[j], ltav[j], j );
902902
}
903-
}
904-
}
903+
}
904+
}
905905

906-
//// find sta / lta for the other 31 samples but without doing the summing again
906+
//// find sta / lta for the other 31 samples but without doing the summing again
907907

908908
for (int idx = LTA_len+1; idx < QUE_len; idx++) {
909909
AccelReading AccelRecord;
@@ -920,7 +920,7 @@ void loop() {
920920
if( StaLtaQue.peekIdx( &AccelRecord, idx-LTA_len) ) {
921921
LTAsample1[0] = AccelRecord.x;
922922
LTAsample1[1] = AccelRecord.y;
923-
LTAsample1[2] = AccelRecord.z;
923+
LTAsample1[2] = AccelRecord.z;
924924
}
925925
for (int j = 0; j < 3; j++) {
926926
sampleABS[j] = abs(sample[j] - offset[j]);
@@ -929,16 +929,16 @@ void loop() {
929929
stav[j] += ( sampleABS[j] - sample1ABS) / STA_len;
930930
ltav[j] += ( sampleABS[j] - LTAsample1ABS) / LTA_len;
931931
stalta[j] = stav[j] / ltav[j];
932-
if ( bPossibleEarthQuake==false ) {
932+
if ( bPossibleEarthQuake==false ) {
933933
if ( stalta[j] >= thresh ) {
934934
// Whoa - STA/LTA algorithm detected some anomalous shaking
935935
Serial.printf("%f = %f / %f (%i)\n", stalta[j], stav[j], ltav[j], j );
936936
bPossibleEarthQuake = true ;
937937
}
938938
}
939-
}
939+
}
940940
}
941-
}
941+
}
942942

943943
// If STA/LTA algorithm detected some anomalous shaking
944944
if( bPossibleEarthQuake ) {
@@ -1212,7 +1212,7 @@ void NeoPixelStatus( int status ) {
12121212

12131213

12141214
void NeoPixelBreathe() {
1215-
if( breatheintensity < 0)
1215+
if( breatheintensity < 0)
12161216
breatheintensity = 0;
12171217
strip.setBrightness( breatheintensity ); // slow breathe the LED
12181218
// Serial.printf("Brightness is %d\n",breatheintensity);

0 commit comments

Comments
 (0)