From 27509e21ee7d838ac4f8362e4b630723227a85c0 Mon Sep 17 00:00:00 2001 From: Carl Klemm Date: Mon, 3 Feb 2020 14:54:31 +0100 Subject: [PATCH] Switch 433 data rechiver to new baud rate and fixed checksum system --- W433DataReciver.cpp | 3 ++- W433DataReciver.h | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/W433DataReciver.cpp b/W433DataReciver.cpp index 4a9173d..be62235 100644 --- a/W433DataReciver.cpp +++ b/W433DataReciver.cpp @@ -196,7 +196,8 @@ void W433DataReciver::interrupt() volatile uint8_t* buffer = reinterpret_cast(&packet); uint8_t computedChecksum = 0; - for(uint8_t j = 0; j < sizeof(packet); j++) for(uint8_t i = 0; i < 8; i++) computedChecksum = computedChecksum + (buffer[j] & ( 1 << (8 - i))); + for(uint8_t j = 0; j < sizeof(packet); j++) for(uint8_t i = 0; i < 8; i++) computedChecksum = computedChecksum + ((buffer[j] & ( 1 << (8 - i))) >> (8 - i)); + //for(uint8_t j = 0; j < sizeof(packet); j++) for(uint8_t i = 0; i < 8; i++) computedChecksum = computedChecksum + (buffer[j] & ( 1 << (8 - i))); if(computedChecksum == recivedChecksum) { diff --git a/W433DataReciver.h b/W433DataReciver.h index 5673467..ed0676b 100644 --- a/W433DataReciver.h +++ b/W433DataReciver.h @@ -23,9 +23,9 @@ private: //constants static constexpr uint8_t CLOCK_DEVIDER = 1; - static constexpr uint16_t SYNC_TIME = 800; - static constexpr uint16_t LARGE_TIME = 2000; - static constexpr uint16_t SMALL_TIME = 500; + static constexpr uint16_t LARGE_TIME = 500; + static constexpr uint16_t SMALL_TIME = 125; + static constexpr uint16_t SYNC_TIME = SMALL_TIME; static constexpr uint8_t SYNC_TIME_TOLERANCE = SYNC_TIME*0.20; static constexpr uint16_t SYNC_END_TIME_TOLERANCE = SYNC_TIME*0.80; static constexpr uint16_t LARGE_TIME_TOLERANCE = LARGE_TIME*0.30;