public class XBeeChecksum extends Object
To test data integrity, a checksum is calculated and verified on non-escaped API data.
To calculate
Not including frame delimiters and length, add all bytes keeping only the
lowest 8 bits of the result and subtract the result from 0xFF
.
To verify
Add all bytes (include checksum, but not the delimiter and length). If the
checksum is correct, the sum will equal 0xFF
.
Constructor and Description |
---|
XBeeChecksum() |
Modifier and Type | Method and Description |
---|---|
void |
add(byte[] data)
Adds the given data to the checksum.
|
void |
add(int value)
Adds the given byte to the checksum.
|
int |
generate()
Generates the checksum byte for the API packet.
|
void |
reset()
Resets the checksum.
|
boolean |
validate()
Validates the checksum.
|
public XBeeChecksum()
public void add(byte[] data)
data
- Byte array to add.public void add(int value)
value
- Byte to add.public int generate()
public void reset()
public boolean validate()
true
if checksum is valid, false
otherwise.© Copyright 2014–2014 Digi International Inc. All rights reserved.