error = port:connect(connectionCallback[, object])
Sends an asynchronous request for connection to the port. When the request is processed, the result is reported to the specified callback.
Parameter |
Type |
Description |
---|---|---|
port |
in port object |
The port to connect to. |
connectionCallback |
in function |
Callback to receive connection events. |
object |
in any (optional) |
If an object is provided, it will be passed as the first parameter to the specified callback function. The object can be of any type except nil. |
error |
out string (optional) |
If successful nil is returned, an error message otherwise. |
Introduced in platform.apiLevel = '2.7'.
connectionCallback ([object,] port, event[, error])
The callback function provided in connect will be called when the state of the connection to the port changes.
Parameter |
Type |
Description |
---|---|---|
object |
in any (optional) |
If an object was provided as a parameter to the function connect, it will be passed as the first parameter to this callback function. |
port |
in port object |
The port requesting to connect or disconnect. |
event |
in asi table constant |
The connection event (please see table below). |
error |
in string (optional) |
If successfully connected or disconnected the parameter will be nil, an error message otherwise. |
Connection event |
Description |
---|---|
asi.CONNECTED |
The connection was successful and the port is ready for input/output operations. |
asi.CONNECTING_FAILED |
The connection failed. |
asi.DISCONNECTED |
The port has been disconnected. |
Introduced in platform.apiLevel = '2.7'.