bacure.local-device

-next-instance

(-next-instance objects object-type)

add-listener!

(add-listener! local-device-id listener)

add-object!

(add-object! object-map)(add-object! device-id object-map)
Add the object map to the local device. Returns an object map.

clear!

(clear! local-device-id)
Destroy all traces of one local-device.

clear-all!

(clear-all!)
Destroy all traces of all local-devices.

default-configs

Some default configurations for device creation.

default-transport

(default-transport network)

disable-communications!

enable-communications!

get-configs

(get-configs local-device-id)
Return a map of the local-device configurations

get-local-device

(get-local-device device-id)
Return the local-device associated with the device-id. If device-id
is nil, simply return the first found.

get-local-device-id

(get-local-device-id device-object)
Given a local device object, return the device ID.

i-am-broadcast!

(i-am-broadcast!)(i-am-broadcast! local-device-id)
Send an 'I am' broadcast on the network.

initialize!

(initialize!)(initialize! local-device-id)
Initialize the local device. This will bind it to it's port (most
likely 47808), send a WhoIsRequest and load any programs available
for the local-device. The port will remain unavailable until the
device is terminated. Once terminated, you should discard the device
and create a new one if needed.

For more information on the local-device 'programs' operations, see
the bacure.local-save namespace.

Return true if initializing (binding to port) is successful.

list-local-devices

(list-local-devices)

load-local-device-backup!

(load-local-device-backup! local-device-id)(load-local-device-backup! local-device-id new-configs)
Load the local-device backup file and reset it with this new
configuration.

local-device-backup

(local-device-backup)(local-device-backup local-device-id)
Get the necessary information to create a local device backup.

local-device-object

(local-device-object device-id)
Return the local-device bacnet4j object associated with the
device-id. If device-id is nil, simply return the first found.

local-objects

(local-objects)(local-objects device-id)
Return a list of all the local objects.

local-test-devices!

(local-test-devices! qty port)
Generate multiple devices with a unique IP address.
(127.0.0.1, 127.0.0.2, etc.)

They don't bind to anylocal ("0.0.0.0") and thus won't
automatically receive broadcasts.

You probably want to register them as foreign devices or use
`remote-device/local-registered-test-devices!` instead.

maybe-register-as-foreign-device!

(maybe-register-as-foreign-device! local-device-id)
Try to register the device if the key ':foreign-device-target' is
present in the configuration 

new-local-device!

(new-local-device!)(new-local-device! configs-map)
Create a new device and return its ID. (A device is required to
communicate over the BACnet network.). Use the function 'initialize'
and 'terminate' to bind and unbind the device to the BACnet port. If
needed, the initial configurations are associated with the
keyword :init-configs inside the local-device map.'

See README for more information about how to specify configs-map.

object

(object object-identifier)(object device-id object-identifier)
Return a local object

register-as-foreign-device

(register-as-foreign-device target-ip-or-hostname target-port time-to-live)(register-as-foreign-device local-device-id target-ip-or-hostname target-port time-to-live)
Register the local device as a foreign device in a device located
on another network. Will block until the registration is completed
or the request times out.

The time-to-live is the time in minutes after which we should be
removed from the foreign device table (if we don't re-register).

Re-registration are handled automatically.

Throws a BACnet exception if timeout, a NAK is received, the device
is already registered or if the request couldn't be sent.

remove-all-objects!

(remove-all-objects!)(remove-all-objects! device-id)
Remove all the objects (except the local device itself).

remove-object!

(remove-object! object-identifier)(remove-object! device-id object-identifier)

reset-local-device!

(reset-local-device!)(reset-local-device! config-or-id)(reset-local-device! local-device-id new-config)
Terminate the local device and discard it. Replace it with a new
local device, and apply the same configurations as the previous one.
If a map with new configurations is provided, it will be merged with
the old config.

(reset-local-device {:device-id 1112})
---> reset the device and change the device id.

save-local-device-backup!

(save-local-device-backup!)
Save the device backup on a local file and return the config map.

terminate!

(terminate!)(terminate! local-device-id)
Terminate the local device, freeing any bound port in the process. Close its
serial connection if it exists afterwards. (If we don't terminate the device
first, and it's got an MS/TP node, it'll try to access a closed serial
connection in its MS/TP node thread and it'll throw angrily.)

terminate-all!

(terminate-all!)
Terminate all local devices.

unregister-as-foreign-device

(unregister-as-foreign-device)(unregister-as-foreign-device local-device-id)
Unregister as a foreign device. Should be done automatically when
terminating a local device.

update-configs!

(update-configs! local-device-id properties-smap)
Given a map of properties, will update the local-device. Return the
device configs. Please note that many properties CANNOT be changed
while the device is initialized (:object-identifier for example) and
will simply be discarded.

update-object!

(update-object! object-map)(update-object! device-id object-map)

with-temp-devices

macro

(with-temp-devices & body)
Execute body with a temporary set of local-devices. Useful for tests.
Warning: uses `with-redefs`, don't use concurrently (ex: pmap).