Skip to content

Commit

Permalink
Updates for Railway (longer token, accept trend in addition to direct…
Browse files Browse the repository at this point in the history
…ion, response count limited to 10).
  • Loading branch information
mlukasek committed Oct 2, 2022
1 parent d8ea9a4 commit 92dd8a4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Binary file modified Binaries/BASIC_Gray_Fire/M5_NightscoutMon.ino.bin
Binary file not shown.
Binary file modified Binaries/Core2/M5_NightscoutMon.ino.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion M5NSconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

struct tConfig {
char url[128];
char token[32]; // security token
char token[64]; // security token
char bootPic[64];
char userName[32];
char deviceName[32];
Expand Down
14 changes: 7 additions & 7 deletions M5_NightscoutMon.ino
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ SHT3X sht30;
#include "microdot.h"
MicroDot MD;

String M5NSversion("2021060101");
String M5NSversion("2022100201");

#ifdef ARDUINO_M5STACK_Core2
#define CONFIG_I2S_BCK_PIN 12
Expand Down Expand Up @@ -965,15 +965,12 @@ int readNightscout(char *url, char *token, struct NSinfo *ns) {
is_https_Heroku = (strstr(NSurl,"https://") != NULL) && (strstr(NSurl,"herokuapp.com") != NULL);
Serial.print("is_https_Heroku "); Serial.println(is_https_Heroku);
if(cfg.sgv_only) {
strcat(NSurl,"/api/v1/entries.json?find[type][$eq]=sgv");
strcat(NSurl,"/api/v1/entries.json?find[type][$eq]=sgv&count=10");
} else {
strcat(NSurl,"/api/v1/entries.json");
strcat(NSurl,"/api/v1/entries.json?count=10");
}
if ((token!=NULL) && (strlen(token)>0)) {
if(strchr(NSurl,'?'))
strcat(NSurl,"&token=");
else
strcat(NSurl,"?token=");
strcat(NSurl,"&token=");
strcat(NSurl,token);
}
}
Expand Down Expand Up @@ -1103,6 +1100,9 @@ int readNightscout(char *url, char *token, struct NSinfo *ns) {
ns->rawtime = JSONdoc[sgvindex]["date"].as<long long>(); // sensTime is time in milliseconds since 1970, something like 1555229938118
ns->sensTime = ns->rawtime / 1000; // no milliseconds, since 2000 would be - 946684800, but ok
strlcpy(ns->sensDir, JSONdoc[sgvindex]["direction"] | "N/A", 32);
if(strcmp(ns->sensDir, "N/A")==0) { // Railway uses "trend" instead of "direction"
strlcpy(ns->sensDir, JSONdoc[sgvindex]["trend"] | "N/A", 32);
}
ns->sensSgv = JSONdoc[sgvindex]["sgv"]; // get value of sensor measurement
for(int i=0; i<=9; i++) {
ns->last10sgv[i]=JSONdoc[i]["sgv"];
Expand Down

0 comments on commit 92dd8a4

Please sign in to comment.