Full C++ and Python impl

This commit is contained in:
2026-04-05 01:10:49 +02:00
parent 1ae2f521c1
commit a2887b187f
5 changed files with 153 additions and 1 deletions

22
telemetry_common.cpp Normal file
View File

@@ -0,0 +1,22 @@
// Copyright (C) 2026 Hector van der Aa <hector@h3cx.dev>
// Copyright (C) 2026 Association Exergie <association.exergie@gmail.com>
// SPDX-License-Identifier: MIT
#include "telemetry_common.h"
#include <stdlib.h>
uint16_t crc16_ccitt(const uint8_t *data, uint16_t length) {
uint16_t crc = 0xFFFF;
for (uint16_t i = 0; i < length; i++) {
crc ^= (uint16_t)data[i] << 8;
for (uint8_t j = 0; j < 8; j++) {
if (crc & 0x8000)
crc = (crc << 1) ^ 0x1021;
else
crc <<= 1;
}
}
return crc;
}