mirror of
https://github.com/eddyem/small_tel.git
synced 2026-05-07 13:27:06 +03:00
some fixes
This commit is contained in:
@@ -240,12 +240,12 @@ int format_sensval(const val_t *v, char *buf, int buflen, int Np){
|
||||
|
||||
// the same for measurement time formatting
|
||||
int format_msrmttm(time_t t, char *buf, int buflen){
|
||||
--buflen; // for trailing zero
|
||||
if(!buf || buflen < FULL_LEN) return -1;
|
||||
if(!buf || buflen < 1) return -1;
|
||||
char cmt[COMMENT_LEN+1];
|
||||
struct tm *T = localtime(&t);
|
||||
strftime(cmt, COMMENT_LEN, "%F %T", T);
|
||||
return snprintf(buf, buflen, "TMEAS=%zd / Last measurement time: %s", t, cmt);
|
||||
int got = snprintf(buf, buflen, "TMEAS=%zd / Last measurement time: %s", t, cmt);
|
||||
return (got < buflen) ? got : buflen;
|
||||
}
|
||||
|
||||
// find sensor's value by its name; @return index or -1 if not found
|
||||
|
||||
@@ -119,6 +119,7 @@ static void showdata(sl_sock_t *client){
|
||||
sl_sock_sendbyte(client, '\n');
|
||||
++nsum; Tsum += v.time;
|
||||
}
|
||||
DBG("nsum=%d", nsum);
|
||||
if(nsum > 0){
|
||||
oldest = (time_t)(Tsum / nsum);
|
||||
if(0 < format_msrmttm(oldest, buf, FULL_LEN)){ // send mean measuring time
|
||||
|
||||
Reference in New Issue
Block a user