From 3303c77e2a46bab857ef57d6171a93eb2833bd7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Tue, 10 Nov 2015 22:32:28 +0100 Subject: [PATCH] add CRC in receiver --- rpi/spark_counter_receiver.cpp | 60 ++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/rpi/spark_counter_receiver.cpp b/rpi/spark_counter_receiver.cpp index ef6fe58..2ff4a6a 100644 --- a/rpi/spark_counter_receiver.cpp +++ b/rpi/spark_counter_receiver.cpp @@ -19,7 +19,6 @@ * they are then stored in an InfluxDB time series database using the HTTP API * to send values to the database the curl library is required */ - #include #include #include @@ -29,6 +28,9 @@ #include // http://tmrh20.github.io/RF24 library to communicate to the nRF24L01+ #include // curl library to send the measurement data to the influxDB. #include "aes.h" // AES library (from tiny-AES128-C) +#include "crc16.h" // CRC Computations (from AVR libc) + +//#define DEBUG 1 // Setup for RPi B1 GPIO 22 CE and CE0 CSN with SPI Speed @ 8Mhz RF24 radio(RPI_V2_GPIO_P1_22, BCM2835_SPI_CS0, BCM2835_SPI_SPEED_8MHZ); @@ -77,32 +79,76 @@ int main(int argc, char** argv){ uint8_t size = radio.getDynamicPayloadSize(); radio.read(&payload,size); -/* +#ifdef DEBUG printf("got %d bytes:",size); for (uint8_t i=0; i