Class MeshParserUtils
java.lang.Object
org.openremote.agent.protocol.bluetooth.mesh.utils.MeshParserUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final Loggerstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]addKeyIndexPadding(Integer keyIndex) static StringbytesToHex(byte[] bytes, boolean add0x) static StringbytesToHex(byte[] bytes, int start, int length, boolean add0x) static intbytesToInt(@javax.validation.constraints.NotNull byte[] b) static intcalculateSeqZero(byte[] sequenceNumber) static byte[]concatenateSegmentedMessages(Map<Integer, byte[]> segmentedMessages) static intconvert24BitsToInt(@javax.validation.constraints.NotNull byte[] byteArray) static byte[]createVendorOpCode(int opCode, int companyIdentifier) Returns the vendor opcode packed with company identifier If the MSB = 0 then the length is 1 If the MSB = 1 then the length is 2 If the MSB = 2 then the length is 3static StringformatTimeStamp(long timestamp) Formats the timestampstatic StringformatUuid(@NotNull String uuidHex) Formats a hex string without dashes to a uuid stringstatic intgetBitValue(int value, int position) static intgetCompanyIdentifier(int modelId) static byte[]getDstAddress(byte[] pdu) static NodeKeygetNodeKey(@NotNull List<NodeKey> keys, int index) static intgetOpCode(byte[] accessPayload, int opCodeCount) Returns the opcode within the access payloadstatic byte[]getOpCode(int opCode) Returns an array of opcodes.static intgetOpCodeLength(int mostSignificantOpcodeByte) Returns the length of the opcode.static StringgetRemainingTime(int remainingTime) Returns the remaining time as a stringstatic intgetRemainingTime(int resolution, int steps) Returns the remaining time in millisecondsstatic StringgetRemainingTransitionTime(int stepResolution, int numberOfSteps) Returns the remaining time as a stringstatic byte[]getSequenceNumberBytes(int sequenceNumber) static intgetSequenceNumberFromPDU(byte[] pdu) static byte[]getSrcAddress(byte[] pdu) static UUIDReturns a type4 UUID from a uuid string without dashesstatic intgetValue(byte[] bytes) static intstatic byte[]intToBytes(int i) static booleanisDefaultPublishTtl(int publishTtl) Checks if the default publish ttl is used for publicationstatic booleanisNodeKeyExists(@NotNull List<NodeKey> keys, int index) static booleanisUuidPattern(@NotNull String uuidHex) static booleanisValidDefaultTtl(int ttl) Checks if the ttl value is within the allowed range.static booleanisValidHeartbeatCountLog(int countLog) Validates heart beat count log.static booleanisValidHeartbeatPublicationTtl(int ttl) Validates heart beat publication ttl.static booleanisValidOpcode(int opCode) Checks if the opcode is validstatic booleanisValidParameters(byte[] parameters) Checks if the parameters are within the valid rangestatic booleanisValidSequenceNumber(int sequenceNumber) static booleanisValidTtl(int ttl) Checks if the Publication ttl value is within the allowed range where the range is 0x00 - 0x7F.static booleanisVendorModel(int modelId) Returns if the model id is a vendor modelstatic byteparseUpdateFlags(int keyRefreshFlag, int ivUpdateFlag) static intremoveKeyIndexPadding(byte[] keyIndex) static byte[]toByteArray(String hexString) static intunsignedBytesToInt(byte b0, byte b1) Convert signed bytes to a 16-bit unsigned int.static intunsignedByteToInt(byte b) Convert a signed byte to an unsigned int.static byte[]uuidToBytes(@NotNull UUID uuid) Returns UUID in bytesstatic StringReturns UUID as a hexstatic StringReturns UUID as a hexstatic booleanvalidateIvIndexInput(Integer ivIndex) Validates the IV Index inputstatic booleanvalidateIvIndexInput(String input) Validates the IV Index inputstatic booleanvalidateKeyIndexInput(String input) Validates the Key Index inputstatic booleanvalidateKeyInput(@NotNull String key) Validates the key inputstatic booleanvalidateNetworkKeyInput(@NotNull String networkKey) Validates the network key inputstatic booleanvalidatePublishRetransmitIntervalSteps(int intervalSteps) Checks if the publish retransmit interval steps is within the allowed rangestatic booleanvalidateRetransmitCount(int retransmitCount) Checks if the retransmit count is within the allowed range
-
Field Details
-
LOG
-
USE_DEFAULT_TTL
public static final int USE_DEFAULT_TTL- See Also:
-
RESOLUTION_100_MS
public static final int RESOLUTION_100_MS- See Also:
-
RESOLUTION_1_S
public static final int RESOLUTION_1_S- See Also:
-
RESOLUTION_10_S
public static final int RESOLUTION_10_S- See Also:
-
RESOLUTION_10_M
public static final int RESOLUTION_10_M- See Also:
-
GENERIC_ON_OFF_5_MS
public static final int GENERIC_ON_OFF_5_MS- See Also:
-
-
Constructor Details
-
MeshParserUtils
public MeshParserUtils()
-
-
Method Details
-
bytesToHex
-
bytesToHex
-
toByteArray
-
parseUpdateFlags
public static byte parseUpdateFlags(int keyRefreshFlag, int ivUpdateFlag) -
getBitValue
public static int getBitValue(int value, int position) -
addKeyIndexPadding
-
removeKeyIndexPadding
public static int removeKeyIndexPadding(byte[] keyIndex) -
validateNetworkKeyInput
public static boolean validateNetworkKeyInput(@NotNull @NotNull String networkKey) throws IllegalArgumentException Validates the network key input- Parameters:
networkKey- Network Key input- Returns:
- true if the Network Key is a valid value
- Throws:
IllegalArgumentException- in case of an invalid was entered as an input and the message containing the error
-
validateKeyIndexInput
Validates the Key Index input- Parameters:
input- Key Index input- Returns:
- true if the Key Index is a valid value
- Throws:
IllegalArgumentException- in case of an invalid was entered as an input and the message containing the error
-
validateIvIndexInput
Validates the IV Index input- Parameters:
input- IV Index input- Returns:
- true if the the value is valid
- Throws:
IllegalArgumentException- in case of an invalid was entered as an input and the message containing the error
-
validateIvIndexInput
Validates the IV Index input- Parameters:
ivIndex- IV Index input- Returns:
- true if the the value is valid
- Throws:
IllegalArgumentException- in case of an invalid was entered as an input and the message containing the error
-
validateKeyInput
public static boolean validateKeyInput(@NotNull @NotNull String key) throws IllegalArgumentException Validates the key input- Parameters:
key- key- Returns:
- true if the Key is a valid value
- Throws:
IllegalArgumentException- in case of an invalid was entered as an input and the message containing the error
-
isValidSequenceNumber
public static boolean isValidSequenceNumber(int sequenceNumber) -
getSequenceNumberBytes
public static byte[] getSequenceNumberBytes(int sequenceNumber) -
convert24BitsToInt
public static int convert24BitsToInt(@NotNull @javax.validation.constraints.NotNull byte[] byteArray) -
getSequenceNumberFromPDU
public static int getSequenceNumberFromPDU(byte[] pdu) -
calculateSeqZero
public static int calculateSeqZero(byte[] sequenceNumber) -
getSrcAddress
public static byte[] getSrcAddress(byte[] pdu) -
getDstAddress
public static byte[] getDstAddress(byte[] pdu) -
concatenateSegmentedMessages
-
getOpCode
public static int getOpCode(byte[] accessPayload, int opCodeCount) Returns the opcode within the access payload- Parameters:
accessPayload- payload- Returns:
- array of opcodes
-
getOpCode
public static byte[] getOpCode(int opCode) Returns an array of opcodes. If the MSB = 0 then the length is 1 If the MSB = 1 then the length is 2 If the MSB = 2 then the length is 3- Parameters:
opCode- operation code
-
getOpCodeLength
public static int getOpCodeLength(int mostSignificantOpcodeByte) Returns the length of the opcode. If the MSB = 0 then the length is 1 If the MSB = 1 then the length is 2 If the MSB = 2 then the length is 3- Parameters:
mostSignificantOpcodeByte- operation code- Returns:
- length of opcodes
-
createVendorOpCode
public static byte[] createVendorOpCode(int opCode, int companyIdentifier) Returns the vendor opcode packed with company identifier If the MSB = 0 then the length is 1 If the MSB = 1 then the length is 2 If the MSB = 2 then the length is 3- Parameters:
opCode- operation code- Returns:
- length of opcodes
-
isValidOpcode
Checks if the opcode is valid- Parameters:
opCode- opCode of mesh message- Returns:
- if the opcode is valid
- Throws:
IllegalArgumentException
-
isValidParameters
Checks if the parameters are within the valid range- Parameters:
parameters- opCode of mesh message- Returns:
- if the opcode is valid
- Throws:
IllegalArgumentException
-
isValidTtl
public static boolean isValidTtl(int ttl) Checks if the Publication ttl value is within the allowed range where the range is 0x00 - 0x7F.- Parameters:
ttl- ttl- Returns:
- true if valid and false otherwise
-
isValidDefaultTtl
public static boolean isValidDefaultTtl(int ttl) Checks if the ttl value is within the allowed range.0x00, 0x02 - 0x7F are the Default TTL states. 0x01, 0x80 and 0xFF are Prohibited.
- Parameters:
ttl- ttl- Returns:
- true if valid and false otherwise
-
isDefaultPublishTtl
public static boolean isDefaultPublishTtl(int publishTtl) Checks if the default publish ttl is used for publication- Parameters:
publishTtl- publish ttl- Returns:
- true if valid and false otherwise
-
validateRetransmitCount
public static boolean validateRetransmitCount(int retransmitCount) Checks if the retransmit count is within the allowed range- Parameters:
retransmitCount- publish ttl- Returns:
- true if valid and false otherwise
-
validatePublishRetransmitIntervalSteps
public static boolean validatePublishRetransmitIntervalSteps(int intervalSteps) Checks if the publish retransmit interval steps is within the allowed range- Parameters:
intervalSteps- publish ttl- Returns:
- true if valid and false otherwise
-
getRemainingTime
Returns the remaining time as a string- Parameters:
remainingTime- remaining time that for the transition to finish- Returns:
- remaining time as string.
-
getRemainingTransitionTime
Returns the remaining time as a string- Returns:
- remaining time as string.
-
getRemainingTime
public static int getRemainingTime(int resolution, int steps) Returns the remaining time in milliseconds- Parameters:
resolution- time resolutionsteps- number of steps- Returns:
- time in milliseconds
-
getValue
public static int getValue(byte[] bytes) -
unsignedByteToInt
public static int unsignedByteToInt(byte b) Convert a signed byte to an unsigned int. -
unsignedBytesToInt
public static int unsignedBytesToInt(byte b0, byte b1) Convert signed bytes to a 16-bit unsigned int. -
bytesToInt
public static int bytesToInt(@NotNull @javax.validation.constraints.NotNull byte[] b) -
hexToInt
-
intToBytes
public static byte[] intToBytes(int i) -
isVendorModel
public static boolean isVendorModel(int modelId) Returns if the model id is a vendor model- Parameters:
modelId- model identifier
-
getCompanyIdentifier
public static int getCompanyIdentifier(int modelId) -
uuidToHex
Returns UUID as a hex- Parameters:
uuid- UUID
-
uuidToHex
Returns UUID as a hex- Parameters:
uuid- UUID
-
uuidToBytes
Returns UUID in bytes- Parameters:
uuid- UUID
-
formatUuid
Formats a hex string without dashes to a uuid string- Parameters:
uuidHex- Hex string
-
isUuidPattern
-
getUuid
Returns a type4 UUID from a uuid string without dashes- Parameters:
uuidHex- Hex string
-
formatTimeStamp
Formats the timestamp- Parameters:
timestamp- timestamp
-
isNodeKeyExists
-
getNodeKey
-
isValidHeartbeatCountLog
public static boolean isValidHeartbeatCountLog(int countLog) Validates heart beat count log.- Parameters:
countLog- Heartbeat publication count.- Returns:
- true if valid.
- Throws:
IllegalArgumentException- if the countLog value is not a value from 0 to 17 or 255
-
isValidHeartbeatPublicationTtl
public static boolean isValidHeartbeatPublicationTtl(int ttl) Validates heart beat publication ttl.- Parameters:
ttl- Heartbeat publication ttl.- Returns:
- true if valid or false otherwise.
-