This is the description of the LabVIEW API bindings for the IP Connection. The IP Connection manages the communication between the API bindings and the Brick Daemon or a WIFI/Ethernet Extension. Before Bricks and Bricklets can be controlled using their API an IP Connection has to be created and its TCP/IP connection has to be established.
An installation guide for the LabVIEW API bindings is part of their general description.
The example code below is Public Domain (CC0 1.0).
The namespace for the IPConnection is Tinkerforge.*
.
IPConnection
() → ipcon¶Output: |
|
---|
Creates an IP Connection object that can be used to enumerate the available devices. It is also required for the constructor of Bricks and Bricklets.
IPConnection.
Connect
(host, port)¶Input: |
|
---|
Creates a TCP/IP connection to the given host
and port
. The host and port
can refer to a Brick Daemon or to a WIFI/Ethernet Extension.
Devices can only be controlled when the connection was established successfully.
Blocks until the connection is established and throws an exception if there is no Brick Daemon or WIFI/Ethernet Extension listening at the given host and port.
IPConnection.
Disconnect
()¶Disconnects the TCP/IP connection from the Brick Daemon or the WIFI/Ethernet Extension.
IPConnection.
Authenticate
(secret)¶Input: |
|
---|
Performs an authentication handshake with the connected Brick Daemon or WIFI/Ethernet Extension. If the handshake succeeds the connection switches from non-authenticated to authenticated state and communication can continue as normal. If the handshake fails then the connection gets closed. Authentication can fail if the wrong secret was used or if authentication is not enabled at all on the Brick Daemon or the WIFI/Ethernet Extension.
See the authentication tutorial for more information.
New in version 2.1.0.
IPConnection.
GetConnectionState
() → connectionState¶Output: |
|
---|
Can return the following states:
IPConnection.
SetAutoReconnect
(autoReconnect)¶Input: |
|
---|
Enables or disables auto-reconnect. If auto-reconnect is enabled,
the IP Connection will try to reconnect to the previously given
host and port, if the currently existing connection is lost.
Therefore, auto-reconnect only does something after a successful
Connect()
call.
Default value is true.
IPConnection.
GetAutoReconnect
() → autoReconnect¶Output: |
|
---|
Returns true if auto-reconnect is enabled, false otherwise.
IPConnection.
SetTimeout
(timeout)¶Input: |
|
---|
Sets the timeout in milliseconds for getters and for setters for which the response expected flag is activated.
Default timeout is 2500.
IPConnection.
GetTimeout
() → timeout¶Output: |
|
---|
Returns the timeout as set by SetTimeout()
.
IPConnection.
Enumerate
()¶Broadcasts an enumerate request. All devices will respond with an enumerate callback.
Callbacks can be registered to be notified about events. The registration is done by appending your callback handler to the corresponding event. The available events are described below.
IPConnection.
EnumerateCallback
(sender, uid, connectedUid, position, hardwareVersion, firmwareVersion, deviceIdentifier, enumerationType)¶Input: |
|
---|
The event receives seven parameters:
uid
: The UID of the device.connectedUid
: UID where the device is connected to. For a Bricklet this
is the UID of the Brick or Bricklet it is connected to. For a Brick it is
the UID of the bottommost Brick in the stack. For the bottommost Brick
in a stack it is "0". With this information it is possible to
reconstruct the complete network topology.position
: For Bricks: '0' - '8' (position in stack). For Bricklets:
'a' - 'h' (position on Brick) or 'i' (position of the Raspberry Pi (Zero) HAT)
or 'z' (Bricklet on Isolator Bricklet).hardwareVersion
: Major, minor and release number for hardware version.firmwareVersion
: Major, minor and release number for firmware version.deviceIdentifier
: A number that represents the device.enumerationType
: Type of enumeration.Possible enumeration types are:
Enumerate()
). This enumeration type can occur multiple times
for the same device.uid
and
enumerationType
are valid.It should be possible to implement plug-and-play functionality with this (as is done in Brick Viewer).
The device identifier numbers can be found here. There are also constants for these numbers named following this pattern:
<device-class>.DEVICE_IDENTIFIER
For example: BrickMaster.DEVICE_IDENTIFIER
or BrickletAmbientLight.DEVICE_IDENTIFIER
.
IPConnection.
ConnectedCallback
(sender, connectReason)¶Input: |
|
---|
This event is triggered whenever the IP Connection got connected to a Brick Daemon or to a WIFI/Ethernet Extension, possible reasons are:
IPConnection.
DisconnectedCallback
(sender, disconnectReason)¶Input: |
|
---|
This event is triggered whenever the IP Connection got disconnected from a Brick Daemon or to a WIFI/Ethernet Extension, possible reasons are: