NAME
Tinkerforge::IPConnection - TCP/IP connection handling
CONSTANTS
- CALLBACK_ENUMERATE
-
This constant is used with the register_callback() subroutine to specify the CALLBACK_ENUMERATE callback.
- CALLBACK_CONNECTED
-
This constant is used with the register_callback() subroutine to specify the CALLBACK_CONNECTED callback.
- CALLBACK_DISCONNECTED
-
This constant is used with the register_callback() subroutine to specify the CALLBACK_DISCONNECTED callback.
- ENUMERATION_TYPE_AVAILABLE
-
Possible value for $enumeration_type parameter of CALLBACK_ENUMERATE callback.
- ENUMERATION_TYPE_CONNECTED
-
Possible value for $enumeration_type parameter of CALLBACK_ENUMERATE callback.
- ENUMERATION_TYPE_DISCONNECTED
-
Possible value for $enumeration_type parameter of CALLBACK_ENUMERATE callback.
- CONNECT_REASON_REQUEST
-
Possible value for $connect_reason parameter of CALLBACK_CONNECTED callback.
- CONNECT_REASON_AUTO_RECONNECT
-
Possible value for $connect_reason parameter of CALLBACK_CONNECTED callback.
- DISCONNECT_REASON_REQUEST
-
Possible value for $disconnect_reason parameter of CALLBACK_DISCONNECTED callback.
- DISCONNECT_REASON_ERROR
-
Possible value for $disconnect_reason parameter of CALLBACK_DISCONNECTED callback.
- DISCONNECT_REASON_SHUTDOWN
-
Possible value for $disconnect_reason parameter of CALLBACK_DISCONNECTED callback.
- CONNECTION_STATE_DISCONNECTED
-
Possible return value of the get_connection_state() subroutine.
- CONNECTION_STATE_CONNECTED
-
Possible return value of the get_connection_state() subroutine.
- CONNECTION_STATE_PENDING
-
Possible return value of the get_connection_state() subroutine.
FUNCTIONS
- new()
-
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.
- connect()
-
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.
- disconnect()
-
Disconnects the TCP/IP connection from the Brick Daemon or the WIFI/Ethernet Extension.
- authenticate()
-
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.
For more information about authentication see http://www.tinkerforge.com/en/doc/Tutorials/Tutorial_Authentication/Tutorial.html
- get_connection_state()
-
Can return the following states:
* IPConnection->CONNECTION_STATE_DISCONNECTED (0): No connection is established. * IPConnection->CONNECTION_STATE_CONNETED (1): A connection to the Brick Daemon or the WIFI/Ethernet Extension is established. * IPConnection->CONNECTION_STATE_PENDING (2): IP Connection is currently trying to connect.
- set_auto_reconnect()
-
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 connection is lost.
Default value is 1.
- get_auto_reconnect()
-
Returns 1 if auto-reconnect is enabled, 0 otherwise.
- set_timeout()
-
Sets the timeout in seconds for getters and for setters for which the response expected flag is activated.
Default timeout is 2.5.
- get_timeout()
-
Returns the timeout as set by set_timeout().
- enumerate()
-
Broadcasts an enumerate request. All devices will respond with an enumerate callback.
- register_callback()
-
Registers a callback with ID $id to the function named $callback.