Class BaseMeshNetwork
- Direct Known Subclasses:
MeshNetwork
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Comparator<ApplicationKey>
protected final Comparator<Group>
protected final Comparator<AllocatedGroupRange>
static final int
static final Logger
protected MeshNetworkCallbacks
protected final Comparator<NetworkKey>
protected final Comparator<ProvisionedMeshNode>
static final int
protected final Comparator<AllocatedSceneRange>
protected final Comparator<AllocatedUnicastRange>
-
Method Summary
Modifier and TypeMethodDescriptionboolean
addAppKey
(ApplicationKey newAppKey) Adds an app key to the list of keys with the given key index.boolean
addNetKey
(NetworkKey newNetKey) Adds a Net key to the list of net keys with the given key indexboolean
addProvisioner
(Provisioner provisioner) Adds a provisioner to the networkCreates an application keyCreates an Network keycreateProvisioner
(String name, AllocatedUnicastRange unicastRange, AllocatedGroupRange groupRange, AllocatedSceneRange sceneRange) Creates a provisionerboolean
deleteNode
(ProvisionedMeshNode meshNode) Deletes a mesh node from the list of provisioned nodesdistributeAppKey
(ApplicationKey applicationKey, byte[] newAppKey) Distributes/updates the provisioner node's the application key and returns the updated Application Key.distributeNetKey
(NetworkKey networkKey, byte[] newNetKey) Distribute Net Key will start the key refresh procedure and return the newly updated key.getAppKey
(int keyIndex) Returns an application key with a given key indexprotected List<ApplicationKey>
getAppKeys
(int boundNetKeyIndex) Returns a list of application keys bound to a Network keygetNetKey
(int keyIndex) Returns an application key with a given key indexReturns the map of network exclusionsgetNode
(int unicastAddress) Returns the mesh node with the corresponding unicast addressReturns the mesh node with the corresponding unicast addressgetNodes()
Returns the list ofProvisionedMeshNode
Returns the list ofProvisioner
Returns theProxyFilter
set on the proxyReturns the selected provisioner in the networkboolean
isKeyInUse
(org.openremote.agent.protocol.bluetooth.mesh.MeshKey meshKey) Checks if the app key is in use.protected boolean
isProvisionerUuidInUse
(String uuid) protected void
Loads the sequence numbers known to the networkboolean
removeAppKey
(ApplicationKey appKey) Removes an app key from the app key listboolean
removeNetKey
(NetworkKey networkKey) Removes a network key from the network key listboolean
revokeOldKey
(NetworkKey networkKey) Revokes the old key.final void
selectProvisioner
(Provisioner provisioner) Selects a provisioner if there are multiple provisioners.void
setProxyFilter
(ProxyFilter proxyFilter) Sets theProxyFilter
settings on the proxyboolean
switchToNewKey
(NetworkKey networkKey) Switches the new key, this will initiate the provisioner node transmitting messages using the new keys but will support receiving messages using both old and the new key.boolean
updateAppKey
(ApplicationKey applicationKey) Updates an app key in the mesh network.boolean
updateAppKey
(ApplicationKey applicationKey, String newAppKey) Updates an app key with a given key in the mesh network.boolean
updateNetKey
(NetworkKey networkKey) Update a network key in the mesh network.boolean
updateNetKey
(NetworkKey networkKey, String newNetKey) Update a network key with the given 16-byte hexadecimal string in the mesh network.
-
Field Details
-
LOG
-
NORMAL_OPERATION
public static final int NORMAL_OPERATION- See Also:
-
IV_UPDATE_ACTIVE
public static final int IV_UPDATE_ACTIVE- See Also:
-
appKeyComparator
-
netKeyComparator
-
mCallbacks
-
networkExclusions
-
sequenceNumbers
-
nodeComparator
-
groupComparator
-
unicastRangeComparator
-
groupRangeComparator
-
sceneRangeComparator
-
-
Method Details
-
createNetworkKey
Creates an Network key- Returns:
NetworkKey
- Throws:
IllegalArgumentException
- in case the generated application key already exists
-
addNetKey
Adds a Net key to the list of net keys with the given key index- Parameters:
newNetKey
- Network key- Throws:
IllegalArgumentException
- if the key already exists.
-
updateNetKey
public boolean updateNetKey(NetworkKey networkKey, String newNetKey) throws IllegalArgumentException Update a network key with the given 16-byte hexadecimal string in the mesh network.Updating a NetworkKey's key value requires initiating a Key Refresh Procedure. A NetworkKey that's in use would require a Key Refresh Procedure to update it's key contents. However a NetworkKey that's not in could be updated without this procedure. If the key is in use, call
distributeNetKey(NetworkKey, byte[])
to initiate the Key Refresh Procedure.- Parameters:
networkKey
- Network keynewNetKey
- 16-byte hexadecimal string- Throws:
IllegalArgumentException
- if the key is already in use
-
updateNetKey
Update a network key in the mesh network.Updating a NetworkKey's key value requires initiating a Key Refresh Procedure. A NetworkKey that's in use would require a Key Refresh Procedure to update it's key contents. However a NetworkKey that's not in could be updated without this procedure. If the key is in use, call
distributeNetKey(NetworkKey, byte[])
to initiate the Key Refresh Procedure.- Parameters:
networkKey
- Network key- Throws:
IllegalArgumentException
- if the key is already in use
-
distributeNetKey
public NetworkKey distributeNetKey(NetworkKey networkKey, byte[] newNetKey) throws IllegalArgumentException Distribute Net Key will start the key refresh procedure and return the newly updated key.This process contains three phases.
NetworkKey.KEY_DISTRIBUTION
- Distribution of the new KeysdistributeNetKey(NetworkKey, byte[])
.NetworkKey.USING_NEW_KEYS
- Switching to the new keysswitchToNewKey(NetworkKey)
.NetworkKey.REVOKE_OLD_KEYS
- Revoking old keysrevokeOldKey(NetworkKey)
. The new key is distributed to the provisioner node by setting the currently used key as the old key and setting the currently used key to the new key value. This will change the phase of the network key toNetworkKey.KEY_DISTRIBUTION
. During this phase a node will transmit using the old key but may receive using both old and the new key. After a successful distribution to the provisioner, the user may start sendingConfigNetKeyUpdate
messages to the respective nodes in the network that requires updating. In addition if the user wishes to update the AppKey calldistributeAppKey(ApplicationKey, byte[])
to update the Application Key on the provisioner and then distribute it to other nodes by sendingConfigAppKeyUpdate
to update an AppKey. However it shall be only successfully processed if the NetworkKey bound to the Application Key is inNetworkKey.KEY_DISTRIBUTION
and the received app key value is different or when the received AppKey value is the same as previously received value. Also note that sending a ConfigNetKeyUpdate duringNetworkKey.NORMAL_OPERATION
will switch the phase toNetworkKey.KEY_DISTRIBUTION
. Once distribution is completed, callswitchToNewKey(NetworkKey)
and sendConfigKeyRefreshPhaseSet
to other nodes.- Parameters:
networkKey
- Network keynewNetKey
- 16-byte key- Throws:
IllegalArgumentException
- the key value is already in use.
-
switchToNewKey
Switches the new key, this will initiate the provisioner node transmitting messages using the new keys but will support receiving messages using both old and the new key.This must be called after
distributeNetKey(NetworkKey, byte[])
- Parameters:
networkKey
- Network key to switch too- Returns:
- true if success or false otherwise
- Throws:
IllegalArgumentException
- if the provided key is not the same as the distributed key.
-
revokeOldKey
Revokes the old key.This initiates
NetworkKey.REVOKE_OLD_KEYS
of the Key Refresh Procedure in which user must sendConfigKeyRefreshPhaseSet
message with transition set toNetworkKey.REVOKE_OLD_KEYS
to the other nodes going through the Key Refresh Procedure. The library at this point will set the given Network Key's Phase toNetworkKey.NORMAL_OPERATION
.- Parameters:
networkKey
- Network key that was distributed- Returns:
- true if success or false otherwise
-
removeNetKey
Removes a network key from the network key list- Parameters:
networkKey
- key to be removed- Throws:
IllegalArgumentException
- if the key is in use or if it does not exist in the list of keys
-
getNetKey
Returns an application key with a given key index- Parameters:
keyIndex
- index
-
createAppKey
Creates an application key- Returns:
ApplicationKey
- Throws:
IllegalArgumentException
- in case the generated application key already exists
-
addAppKey
Adds an app key to the list of keys with the given key index. If there is an existing key with the same index, an illegal argument exception is thrown.- Parameters:
newAppKey
- application key- Throws:
IllegalArgumentException
- if app key already exists
-
getAppKey
Returns an application key with a given key index- Parameters:
keyIndex
- index
-
getAppKeys
Returns a list of application keys bound to a Network key- Parameters:
boundNetKeyIndex
- Network Key index
-
updateAppKey
public boolean updateAppKey(ApplicationKey applicationKey, String newAppKey) throws IllegalArgumentException Updates an app key with a given key in the mesh network.Updates the Key if it is not use, if not Updating a Key's key value requires initiating a Key Refresh Procedure. This requires the bound NetworkKey of the AppKey to be updated. A NetworkKey that's in use would require a Key Refresh Procedure to update it's key contents. However a NetworkKey that's not in could be updated without this procedure. If the key is in use, call
distributeNetKey(NetworkKey, byte[])
to initiate the Key Refresh Procedure.- Parameters:
applicationKey
-ApplicationKey
newAppKey
- Application key- Throws:
IllegalArgumentException
- if the key is in use.
-
updateAppKey
Updates an app key in the mesh network.Updates the Key if it is not use, if not Updating a Key's key value requires initiating a Key Refresh Procedure. This requires the bound NetworkKey of the AppKey to be updated. A NetworkKey that's in use would require aKey Refresh Procedure to update it's key contents. However a NetworkKey that's not in could be updated without this procedure. If the key is in use, call
distributeNetKey(NetworkKey, byte[])
to initiate the Key Refresh Procedure. After distributing the NetworkKey bound to the Application Key, user may calldistributeAppKey(ApplicationKey, byte[])
to update the corresponding ApplicationKey.- Parameters:
applicationKey
-ApplicationKey
- Throws:
IllegalArgumentException
- if the key is already in use
-
distributeAppKey
public ApplicationKey distributeAppKey(ApplicationKey applicationKey, byte[] newAppKey) throws IllegalArgumentException Distributes/updates the provisioner node's the application key and returns the updated Application Key.This will only work if the NetworkKey bound to this ApplicationKey is in Phase 1 of the Key Refresh Procedure. Therefore the NetworkKey must be updated first before updating it's bound application key. Call
distributeNetKey(NetworkKey, byte[])
to initiate the Key Refresh Procedure to update a Network Key that's in use by the provisioner or the nodes, if it has not been started already. To update a key that's not in use callupdateAppKey(ApplicationKey, String)
Once the provisioner nodes' AppKey is updated user must distribute the updated AppKey to the nodes. This can be done by sending
ConfigAppKeyUpdate
message with the new key.- Parameters:
applicationKey
- Network keynewAppKey
- 16-byte key- Throws:
IllegalArgumentException
- the key value is already in use.
-
removeAppKey
Removes an app key from the app key list- Parameters:
appKey
- app key to be removed- Throws:
IllegalArgumentException
- if the key is in use or if it does not exist in the list of keys
-
isKeyInUse
public boolean isKeyInUse(org.openremote.agent.protocol.bluetooth.mesh.MeshKey meshKey) Checks if the app key is in use.This will check if the specified app key is added to a node other than the selected provisioner node
- Parameters:
meshKey
-MeshKey
-
createProvisioner
public Provisioner createProvisioner(String name, AllocatedUnicastRange unicastRange, AllocatedGroupRange groupRange, AllocatedSceneRange sceneRange) throws IllegalArgumentException Creates a provisioner- Parameters:
name
- Provisioner nameunicastRange
-AllocatedUnicastRange
for the provisionergroupRange
-AllocatedGroupRange
for the provisionersceneRange
-AllocatedSceneRange
for the provisioner- Returns:
Provisioner
- Throws:
IllegalArgumentException
- if the name is empty
-
selectProvisioner
Selects a provisioner if there are multiple provisioners.- Parameters:
provisioner
-Provisioner
-
addProvisioner
Adds a provisioner to the network- Parameters:
provisioner
-Provisioner
- Throws:
IllegalArgumentException
- if unicast address is invalid, in use by a node
-
getNode
Returns the mesh node with the corresponding unicast address- Parameters:
unicastAddress
- unicast address of the node
-
getNode
Returns the mesh node with the corresponding unicast address- Parameters:
uuid
- unicast address of the node
-
loadSequenceNumbers
protected void loadSequenceNumbers()Loads the sequence numbers known to the network -
isProvisionerUuidInUse
-
getProvisioners
Returns the list ofProvisioner
-
getSelectedProvisioner
Returns the selected provisioner in the network -
getNodes
Returns the list ofProvisionedMeshNode
-
getNetworkExclusions
Returns the map of network exclusions -
getProxyFilter
Returns theProxyFilter
set on the proxy -
setProxyFilter
Sets theProxyFilter
settings on the proxyPlease note that this is not persisted within the node since the filter is reinitialized to a whitelist filter upon connecting to a proxy node. Therefore after setting a proxy filter and disconnecting users will have to manually
-
deleteNode
Deletes a mesh node from the list of provisioned nodesNote that deleting a node manually will not reset the node, but only be deleted from the stored list of provisioned nodes. However you may still be able to connect to the same node, if it was not reset since the network may still exist. This would be useful to in case if a node was physically reset and needs to be removed from the mesh network/db
- Parameters:
meshNode
- node to be deleted- Returns:
- true if deleted and false otherwise
-