mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-06-05 21:49:48 +02:00
Change CRC16 method
Be able to use a custom crc value for initialization. Keeping compatibility with previous method.
This commit is contained in:
@@ -45,8 +45,10 @@ public class CheckSums {
|
||||
|
||||
//thanks http://stackoverflow.com/questions/13209364/convert-c-crc16-to-java-crc16
|
||||
public static int getCRC16(byte[] seq) {
|
||||
int crc = 0xFFFF;
|
||||
|
||||
return getCRC16(seq, 0xFFFF);
|
||||
}
|
||||
|
||||
public static int getCRC16(byte[] seq, int crc) {
|
||||
for (byte b : seq) {
|
||||
crc = ((crc >>> 8) | (crc << 8)) & 0xffff;
|
||||
crc ^= (b & 0xff);//byte to int, trunc sign
|
||||
|
Reference in New Issue
Block a user