Class MeshParserUtils
java.lang.Object
org.openremote.agent.protocol.bluetooth.mesh.utils.MeshParserUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final Logger
static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
addKeyIndexPadding
(Integer keyIndex) static String
bytesToHex
(byte[] bytes, boolean add0x) static String
bytesToHex
(byte[] bytes, int start, int length, boolean add0x) static int
bytesToInt
(@jakarta.validation.constraints.NotNull byte[] b) static int
calculateSeqZero
(byte[] sequenceNumber) static byte[]
concatenateSegmentedMessages
(Map<Integer, byte[]> segmentedMessages) static int
convert24BitsToInt
(@jakarta.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 String
formatTimeStamp
(long timestamp) Formats the timestampstatic String
formatUuid
(@NotNull String uuidHex) Formats a hex string without dashes to a uuid stringstatic int
getBitValue
(int value, int position) static int
getCompanyIdentifier
(int modelId) static byte[]
getDstAddress
(byte[] pdu) static NodeKey
getNodeKey
(@NotNull List<NodeKey> keys, int index) static int
getOpCode
(byte[] accessPayload, int opCodeCount) Returns the opcode within the access payloadstatic byte[]
getOpCode
(int opCode) Returns an array of opcodes.static int
getOpCodeLength
(int mostSignificantOpcodeByte) Returns the length of the opcode.static String
getRemainingTime
(int remainingTime) Returns the remaining time as a stringstatic int
getRemainingTime
(int resolution, int steps) Returns the remaining time in millisecondsstatic String
getRemainingTransitionTime
(int stepResolution, int numberOfSteps) Returns the remaining time as a stringstatic byte[]
getSequenceNumberBytes
(int sequenceNumber) static int
getSequenceNumberFromPDU
(byte[] pdu) static byte[]
getSrcAddress
(byte[] pdu) static UUID
Returns a type4 UUID from a uuid string without dashesstatic int
getValue
(byte[] bytes) static int
static byte[]
intToBytes
(int i) static boolean
isDefaultPublishTtl
(int publishTtl) Checks if the default publish ttl is used for publicationstatic boolean
isNodeKeyExists
(@NotNull List<NodeKey> keys, int index) static boolean
isUuidPattern
(@NotNull String uuidHex) static boolean
isValidDefaultTtl
(int ttl) Checks if the ttl value is within the allowed range.static boolean
isValidHeartbeatCountLog
(int countLog) Validates heart beat count log.static boolean
isValidHeartbeatPublicationTtl
(int ttl) Validates heart beat publication ttl.static boolean
isValidOpcode
(int opCode) Checks if the opcode is validstatic boolean
isValidParameters
(byte[] parameters) Checks if the parameters are within the valid rangestatic boolean
isValidSequenceNumber
(int sequenceNumber) static boolean
isValidTtl
(int ttl) Checks if the Publication ttl value is within the allowed range where the range is 0x00 - 0x7F.static boolean
isVendorModel
(int modelId) Returns if the model id is a vendor modelstatic byte
parseUpdateFlags
(int keyRefreshFlag, int ivUpdateFlag) static int
removeKeyIndexPadding
(byte[] keyIndex) static byte[]
toByteArray
(String hexString) static int
unsignedBytesToInt
(byte b0, byte b1) Convert signed bytes to a 16-bit unsigned int.static int
unsignedByteToInt
(byte b) Convert a signed byte to an unsigned int.static byte[]
uuidToBytes
(@NotNull UUID uuid) Returns UUID in bytesstatic String
Returns UUID as a hexstatic String
Returns UUID as a hexstatic boolean
validateIvIndexInput
(Integer ivIndex) Validates the IV Index inputstatic boolean
validateIvIndexInput
(String input) Validates the IV Index inputstatic boolean
validateKeyIndexInput
(String input) Validates the Key Index inputstatic boolean
validateKeyInput
(@NotNull String key) Validates the key inputstatic boolean
validateNetworkKeyInput
(@NotNull String networkKey) Validates the network key inputstatic boolean
validatePublishRetransmitIntervalSteps
(int intervalSteps) Checks if the publish retransmit interval steps is within the allowed rangestatic boolean
validateRetransmitCount
(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 @jakarta.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 @jakarta.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.
-