X-Git-Url: http://git.techno-innov.fr/?a=blobdiff_plain;f=host%2Fexanh_datalog%2Fmain.c;h=424a1dc78ed925281553bc1b07c8a4f6d16651a8;hb=HEAD;hp=870d7aa7d63a6649c7d920564dcf1f2294fadaba;hpb=bdbab0310828ef5453ef5592309f2ba6b2bd2716;p=soft%2Flpc82x%2Fexanh diff --git a/host/exanh_datalog/main.c b/host/exanh_datalog/main.c index 870d7aa..424a1dc 100644 --- a/host/exanh_datalog/main.c +++ b/host/exanh_datalog/main.c @@ -3,10 +3,8 @@ * * main.c * - * * Copyright 2013-2014 Nathael Pajani * - * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -23,11 +21,6 @@ ****************************************************************************/ -/* this protocol handler is designed to run on a host replacing the DTPlug, - * but should be easy to use as a source for the protocol handling code for - * the DTPlug itself. - */ - #include #include @@ -518,21 +511,39 @@ int main(int argc, char* argv[]) struct sensor_info info; /* Valid packet received, parse data */ parse_packet(&info); + if (debug == 2) { + printf("Packet from sensor %d\n", info.addr); + } if (info.seqnum == last_seq_num[info.addr]) { /* Ignore duplicated packet */ + if (debug == 2) { + printf("Dup packet from sensor %d (seq: %d)\n", info.addr, info.seqnum); + } break; } /* Check data validity */ if ((info.raw_humidity < 1000) || (info.raw_humidity > 4000)) { + if (debug == 2) { + printf("Invalid raw soil humidity [1000 .. 4000] : %d\n", info.raw_humidity); + } break; } if ((info.pressure < 800) || (info.pressure > 1200)) { + if (debug == 2) { + printf("Invalid pressure [800 .. 1200] : %d\n", info.pressure); + } break; } if ((info.comp_temp < -400) || (info.comp_temp > 1000)) { + if (debug == 2) { + printf("Invalid temperature [-400 .. 1000] : %d\n", info.comp_temp); + } break; } if (info.humidity > 1000) { + if (debug == 2) { + printf("Invalid air rel humidity [0 .. 1000] : %d\n", info.humidity); + } break; } @@ -543,6 +554,9 @@ int main(int argc, char* argv[]) /* New device ? store address */ if ((info.addr < NB_ADDRESS) && (addr_list[info.addr] == 0)) { addr_list[info.addr] = info.addr; + if (debug == 2) { + printf("New device detected : %d\n", info.addr); + } } /* Store data to log file */