1c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/*
2c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Copyright (C) 2012 The Android Open Source Project
3c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
4c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Licensed under the Apache License, Version 2.0 (the "License");
5c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * you may not use this file except in compliance with the License.
6c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * You may obtain a copy of the License at
7c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
8c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      http://www.apache.org/licenses/LICENSE-2.0
9c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
10c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Unless required by applicable law or agreed to in writing, software
11c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * distributed under the License is distributed on an "AS IS" BASIS,
12c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * See the License for the specific language governing permissions and
14c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * limitations under the License.
15c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine */
16c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
17c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine#ifndef ANDROID_SDKCONTROL_SOCKET_H_
18c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine#define ANDROID_SDKCONTROL_SOCKET_H_
19c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
20c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine#include "android/async-socket.h"
217136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine#include "android/async-utils.h"
22c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
23c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/*
24c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Contains declaration of an API that encapsulates communication protocol with
25c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * SdkController running on an Android device.
26c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
27c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * SdkController is used to provide:
28c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
29c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * - Realistic sensor emulation.
30c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * - Multi-touch emulation.
31c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * - Open for other types of emulation.
32c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
33c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * The idea behind this type of emulation is such that there is an actual
34c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Android device that is connected via USB to the host running the emulator.
35c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * On the device there is an SdkController service running that enables
36c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * communication between an Android application that gathers information required
37c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * by the emulator, and transmits that info to the emulator.
38c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
39c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * SdkController service on the device, and SDKCtlSocket API implemented here
40c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * implement the exchange protocol between an Android application, and emulation
41c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * engine running inside the emulator.
42c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
43c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * In turn, the exchange protocol is implemented on top of asynchronous socket
44c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * communication (abstracted in AsyncSocket protocol implemented in
45c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * android/async-socket.*). It means that connection, and all data transfer
46c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * (both, in, and out) are completely asynchronous, and results of each operation
47c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * are reported through callbacks.
48c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
49c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Essentially, this entire API implements two types of protocols:
50c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
51c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * - Connection protocol.
52c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * - Data exchange protocol.
53c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
54c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * 1. Connection protocol.
55c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
56c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Connecting to SdkController service on the attached device can be broken down
57c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * into two phases:
58c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * - Connecting to a TCP socket.
59c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * - Sending a "handshake" query to the SdkController.
60c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
61c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * 1.1. Connecting to the socket.
62c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
63c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * TCP socket connection with SdkController is enabled by using adb port
64c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * forwarding. SdkController is always listening to a local abstract socket named
65c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * 'android.sdk.controller', so to enable connecting to it from the host, run
66c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
67c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *   adb forward tcp:<port> localabstract: android.sdk.controller
68c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
69c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * After that TCP socket for the requested port can be used to connect to
70c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * SdkController, and connecting to it is no different than connecting to any
71c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * socket server. Except for one thing: adb port forwarding is implemented in
72c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * such a way, that socket_connect will always succeed, even if there is no
73c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * server listening to that port on the other side of connection. Moreover,
74c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * even socked_send will succeed in this case, so the only way to ensure that
75c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * SdkController in deed is listening is to exchange a handshake with it:
76c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Fortunatelly, an attempt to read from forwarded TCP port on condition that
77c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * there is no listener on the oher side will fail.
78c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
79c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * 1.2. Handshake query.
80c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
81c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Handshake query is a special type of query that SDKCtlSocket sends to the
82c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * SdkController upon successful socket connection. This query served two
83c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * purposes:
84c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * - Informs the SdkController about host endianness. This information is
85c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *   important, because SdkController needs it in order to format its messages
86c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *   with proper endianness.
87c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * - Ensures that SdkController is in deed listening on the other side of the
88c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *   connected socket.
89c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
90c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Connection with SdkController is considered to be successfuly established when
91c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * SdkController responds to the handshake query, thus, completing the connection.
92c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
93c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * 2. Data exchange protocol.
94c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
95c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * As it was mentioned above, all data transfer in this API is completely
96c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * asynchronous, and result of each data transfer is reported via callbacks.
97c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * This also complicates destruction of data involved in exchange, since in an
98c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * asynchronous environment it's hard to control the lifespan of an object, its
99c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * owner, and who and when is responsible to free resources allocated for the
100c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * transfer. To address this issue, all the descriptors that this API operates
101c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * with are referenced on use / released after use, and get freed when reference
102c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * counter for them drops to zero, indicating that there is no component that is
103c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * interested in that particular descriptor.
104c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
105c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * There are three types of data in the exchange protocol:
1067136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * - A message - the simplest type of data that doesn't require any replies.
107c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * - A query - A message that require a reply, and
108c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * - A query reply - A message that delivers query reply.
109c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine */
110c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
1117136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine/* Default TCP port to use for connection with SDK controller. */
1127136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine#define SDKCTL_DEFAULT_TCP_PORT     1970
1137136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine
114c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/* Declares SDK controller socket descriptor. */
115c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkinetypedef struct SDKCtlSocket SDKCtlSocket;
116c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
1177136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine/* Declares SDK controller message descriptor. */
1187136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkinetypedef struct SDKCtlMessage SDKCtlMessage;
119c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
120c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/* Declares SDK controller query descriptor. */
121c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkinetypedef struct SDKCtlQuery SDKCtlQuery;
122c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
1237136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine/* Declares SDK controller direct packet descriptor.
1247136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Direct packet (unlike message, or query packets) doesn't contain data buffer,
1257136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * but rather references message, or query data allocated by the client.
1267136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine */
1277136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkinetypedef struct SDKCtlDirectPacket SDKCtlDirectPacket;
1287136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine
129c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/* Defines client's callback set to monitor SDK controller socket connection.
130c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
131c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * SDKCtlSocket will invoke this callback when connection to TCP port is
132c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * established, but before handshake query is processed. The client should use
133c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * on_sdkctl_handshake_cb to receive notification about an operational connection
134c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * with SdkController.
135c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
136c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * The main purpose of this callback for the client is to monitor connection
137c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * state: in addition to TCP port connection, this callback will be invoked when
138c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * connection with the port is lost.
139c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
140c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Param:
141c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  client_opaque - An opaque pointer associated with the client.
142c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  sdkctl - Initialized SDKCtlSocket instance.
143c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  status - Socket connection status.  Can be one of these:
144c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *    - ASIO_STATE_SUCCEEDED : Socket is connected to the port.
145c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *    - ASIO_STATE_FAILED    : Connection attempt has failed, or connection with
146c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *                             the port is lost.
147c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Return:
148c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  One of the AsyncIOAction values.
149c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine */
1507136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkinetypedef AsyncIOAction (*on_sdkctl_socket_connection_cb)(void* client_opaque,
1517136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine                                                        SDKCtlSocket* sdkctl,
1527136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine                                                        AsyncIOState status);
1537136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine
1547136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine/* Enumerates port connection statuses passed to port connection callback.
1557136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine */
1567136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkinetypedef enum SdkCtlPortStatus {
1577136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine    /* Service-side port has connected to the socket. */
1587136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine    SDKCTL_PORT_DISCONNECTED,
1597136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine    /* Service-side port has disconnected from the socket. */
1607136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine    SDKCTL_PORT_CONNECTED,
1617136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine    /* Service-side port has enabled emulation */
1627136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine    SDKCTL_PORT_ENABLED,
1637136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine    /* Service-side port has disabled emulation */
1647136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine    SDKCTL_PORT_DISABLED,
1657136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine    /* Handshake request has succeeded, and service-side port is connected. */
1667136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine    SDKCTL_HANDSHAKE_CONNECTED,
1677136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine    /* Handshake request has succeeded, but service-side port is not connected. */
1687136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine    SDKCTL_HANDSHAKE_NO_PORT,
1697136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine    /* Handshake request has failed due to port duplication. */
1707136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine    SDKCTL_HANDSHAKE_DUP,
1717136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine    /* Handshake request has failed on an unknown query. */
1727136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine    SDKCTL_HANDSHAKE_UNKNOWN_QUERY,
1737136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine    /* Handshake request has failed on an unknown response. */
1747136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine    SDKCTL_HANDSHAKE_UNKNOWN_RESPONSE,
1757136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine} SdkCtlPortStatus;
176c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
1777136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine/* Defines client's callback set to receive port connection status.
178c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
1797136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Port connection is different than socket connection, and indicates whether
1807136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * or not a service-side port that provides requested emulation functionality is
1817136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * hooked up with the connected socket. For instance, multi-touch port may be
1827136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * inactive at the time when socket is connected. So, there is a successful
1837136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * socket connection, but there is no service at the device end that provides
1847136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * multi-touch functionality. So, for multi-touch example, this callback will be
1857136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * invoked when multi-touch port at the device end becomes active, and hooks up
1867136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * with the socket that was connected before.
187c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
188c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Param:
189c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  client_opaque - An opaque pointer associated with the client.
190c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  sdkctl - Initialized SDKCtlSocket instance.
1917136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  status - Port connection status.
1927136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine */
1937136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkinetypedef void (*on_sdkctl_port_connection_cb)(void* client_opaque,
1947136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine                                             SDKCtlSocket* sdkctl,
1957136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine                                             SdkCtlPortStatus status);
196c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
197c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/* Defines a message notification callback.
198c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Param:
199c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  client_opaque - An opaque pointer associated with the client.
200c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  sdkctl - Initialized SDKCtlSocket instance.
201c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  message - Descriptor for received message. Note that message descriptor will
202c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      be released upon exit from this callback (thus, could be freed along
203c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      with message data). If the client is interested in working with that
204c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      message after the callback returns, it should reference the message
205c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      descriptor in this callback.
206c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  msg_type - Message type.
207c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  msg_data, msg_size - Message data.
208c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine */
209c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkinetypedef void (*on_sdkctl_message_cb)(void* client_opaque,
210c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                     SDKCtlSocket* sdkctl,
2117136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine                                     SDKCtlMessage* message,
212c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                     int msg_type,
213c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                     void* msg_data,
214c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                     int msg_size);
215c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
216c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/* Defines query completion callback.
217c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Param:
218c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  query_opaque - An opaque pointer associated with the query by the client.
219c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  query - Query descriptor.  Note that query descriptor will be released upon
220c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      exit from this callback (thus, could be freed along with query data). If
221c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      the client is interested in working with that query after the callback
222c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      returns, it should reference the query descriptor in this callback.
223c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  status - Query status. Can be one of these:
224c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *    - ASIO_STATE_CONTINUES : Query data has been transmitted to the service,
225c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *                             and query is now waiting for response.
226c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *    - ASIO_STATE_SUCCEEDED : Query has been successfully completed.
227c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *    - ASIO_STATE_FAILED    : Query has failed on an I/O.
228c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *    - ASIO_STATE_TIMED_OUT : Deadline set for the query has expired.
229c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *    - ASIO_STATE_CANCELLED : Query has been cancelled due to socket
230c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *                             disconnection.
231c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Return:
232c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  One of the AsyncIOAction values.
233c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine */
234c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkinetypedef AsyncIOAction (*on_sdkctl_query_cb)(void* query_opaque,
235c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                            SDKCtlQuery* query,
236c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                            AsyncIOState status);
237c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
2387136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine/* Defines direct packet completion callback.
2397136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Param:
2407136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  opaque - An opaque pointer associated with the direct packet by the client.
2417136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  packet - Packet descriptor.  Note that packet descriptor will be released
2427136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *      upon exit from this callback (thus, could be freed). If the client is
2437136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *      interested in working with that packet after the callback returns, it
2447136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *      should reference the packet descriptor in this callback.
2457136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  status - Packet status. Can be one of these:
2467136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *    - ASIO_STATE_SUCCEEDED : Packet has been successfully sent.
2477136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *    - ASIO_STATE_FAILED    : Packet has failed on an I/O.
2487136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *    - ASIO_STATE_CANCELLED : Packet has been cancelled due to socket
2497136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *                             disconnection.
2507136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Return:
2517136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  One of the AsyncIOAction values.
2527136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine */
2537136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkinetypedef AsyncIOAction (*on_sdkctl_direct_cb)(void* opaque,
2547136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine                                             SDKCtlDirectPacket* packet,
2557136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine                                             AsyncIOState status);
2567136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine
257c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/********************************************************************************
2587136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *                        SDKCtlDirectPacket API
259c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine ********************************************************************************/
260c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
2617136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine/* Creates new SDKCtlDirectPacket descriptor.
262c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Param:
2637136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  sdkctl - Initialized SDKCtlSocket instance to create a direct packet for.
2647136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Return:
2657136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  Referenced SDKCtlDirectPacket instance.
2667136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine */
2677136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkineextern SDKCtlDirectPacket* sdkctl_direct_packet_new(SDKCtlSocket* sdkctl);
2687136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine
2697136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine/* References SDKCtlDirectPacket object.
2707136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Param:
2717136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  packet - Initialized SDKCtlDirectPacket instance.
272c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Return:
273c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  Number of outstanding references to the object.
274c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine */
2757136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkineextern int sdkctl_direct_packet_reference(SDKCtlDirectPacket* packet);
276c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
2777136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine/* Releases SDKCtlDirectPacket object.
278c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Note that upon exiting from this routine the object might be destroyed, even
279c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * if this routine returns value other than zero.
280c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Param:
2817136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  packet - Initialized SDKCtlDirectPacket instance.
282c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Return:
283c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  Number of outstanding references to the object.
284c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine */
2857136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkineextern int sdkctl_direct_packet_release(SDKCtlDirectPacket* packet);
2867136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine
2877136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine/* Sends direct packet.
2887136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Param:
2897136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  packet - Packet descriptor for the direct packet to send.
2907136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  data - Data to send with the packet. Must be fully initialized message, or
2917136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *      query header.
2927136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  cb, cb_opaque - Callback to invoke on packet transmission events.
2937136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine */
2947136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkineextern void sdkctl_direct_packet_send(SDKCtlDirectPacket* packet,
2957136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine                                      void* data,
2967136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine                                      on_sdkctl_direct_cb cb,
2977136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine                                      void* cb_opaque);
2987136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine
2997136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine/********************************************************************************
3007136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *                         SDKCtlMessage API
3017136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine ********************************************************************************/
3027136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine
3037136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine/* References SDKCtlMessage object.
3047136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Param:
3057136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  msg - Initialized SDKCtlMessage instance.
3067136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Return:
3077136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  Number of outstanding references to the object.
3087136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine */
3097136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkineextern int sdkctl_message_reference(SDKCtlMessage* msg);
3107136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine
3117136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine/* Releases SDKCtlMessage object.
3127136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Note that upon exiting from this routine the object might be destroyed, even
3137136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * if this routine returns value other than zero.
3147136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Param:
3157136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  msg - Initialized SDKCtlMessage instance.
3167136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Return:
3177136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  Number of outstanding references to the object.
3187136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine */
3197136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkineextern int sdkctl_message_release(SDKCtlMessage* msg);
3207136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine
3217136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine/* Builds and sends a message to the device.
3227136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Param:
3237136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  sdkctl - SDKCtlSocket instance for the message.
3247136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  msg_type - Defines message type.
3257136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  data - Message data. Can be NULL if there is no data associated with the
3267136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *      message.
3277136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  size - Byte size of the data buffer.
3287136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Return:
3297136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  Referenced SDKCtlQuery descriptor.
3307136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine */
3317136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkineextern SDKCtlMessage* sdkctl_message_send(SDKCtlSocket* sdkctl,
3327136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine                                          int msg_type,
3337136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine                                          const void* data,
3347136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine                                          uint32_t size);
3357136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine
3367136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine/* Gets message header size */
3377136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkineextern int sdkctl_message_get_header_size(void);
3387136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine
3397136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine/* Initializes message header.
3407136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Param:
3417136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  msg - Beginning of the message packet.
3427136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  msg_type - Message type.
3437136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  msg_size - Message data size.
3447136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine */
3457136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkineextern void sdkctl_init_message_header(void* msg, int msg_type, int msg_size);
346c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
347c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/********************************************************************************
348c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *                          SDKCtlQuery API
349c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine ********************************************************************************/
350c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
351c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/* Creates, and partially initializes query descriptor.
352c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Note that returned descriptor is referenced, and it must be eventually
353c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * released with a call to sdkctl_query_release.
354c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Param:
355c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  sdkctl - SDKCtlSocket instance for the query.
356c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  query_type - Defines query type.
357c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  in_data_size Size of the query's input buffer (data to be sent with this
358c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      query). Note that buffer for query data will be allocated along with the
359c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      query descriptor. Use sdkctl_query_get_buffer_in to get address of data
360c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      buffer for this query.
361c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Return:
362c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  Referenced SDKCtlQuery descriptor.
363c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine */
364c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkineextern SDKCtlQuery* sdkctl_query_new(SDKCtlSocket* sdkctl,
365c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                     int query_type,
366c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                     uint32_t in_data_size);
367c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
368c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/* Creates, and fully initializes query descriptor.
369c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Note that returned descriptor is referenced, and it must be eventually
370c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * released with a call to sdkctl_query_release.
371c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Param:
372c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  sdkctl - SDKCtlSocket instance for the query.
373c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  query_type - Defines query type.
374c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  in_data_size Size of the query's input buffer (data to be sent with this
375c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      query). Note that buffer for query data will be allocated along with the
376c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      query descriptor. Use sdkctl_query_get_buffer_in to get address of data
377c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      buffer for this query.
378c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  in_data - Data to initialize query's input buffer with.
379c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  response_buffer - Contains address of the buffer addressing preallocated
380c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      response buffer on the way in, and address of the buffer containing query
381c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      response on query completion. If this parameter is NULL, the API will
382c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      allocate its own query response buffer, which is going to be freed after
383c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      query completion.
384c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  response_size - Contains size of preallocated response buffer on the way in,
385c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      and size of the received response on query completion. Can be NULL.
386c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  query_cb - A callback to monitor query state.
387c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  query_opaque - An opaque pointer associated with the query.
388c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Return:
389c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  Referenced SDKCtlQuery descriptor.
390c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine */
391c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkineextern SDKCtlQuery* sdkctl_query_new_ex(SDKCtlSocket* sdkctl,
392c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                        int query_type,
393c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                        uint32_t in_data_size,
394c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                        const void* in_data,
395c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                        void** response_buffer,
396c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                        uint32_t* response_size,
397c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                        on_sdkctl_query_cb query_cb,
398c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                        void* query_opaque);
399c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
400c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/* Sends query to SDK controller.
401c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Param:
402c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  query - Query to send. Note that this must be a fully initialized query
403c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      descriptor.
404c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  to - Milliseconds to allow for the query to complete. Negative value means
405c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  "forever".
406c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine */
407c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkineextern void sdkctl_query_send(SDKCtlQuery* query, int to);
408c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
409c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/* Creates, fully initializes query descriptor, and sends the query to SDK
410c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * controller.
411c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Note that returned descriptor is referenced, and it must be eventually
412c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * released with a call to sdkctl_query_release.
413c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Param:
414c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  sdkctl - SDKCtlSocket instance for the query.
415c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  query_type - Defines query type.
416c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  in_data_size Size of the query's input buffer (data to be sent with this
417c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      query). Note that buffer for query data will be allocated along with the
418c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      query descriptor. Use sdkctl_query_get_buffer_in to get address of data
419c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      buffer for this query.
420c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  in_data - Data to initialize query's input buffer with.
421c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  response_buffer - Contains address of the buffer addressing preallocated
422c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      response buffer on the way in, and address of the buffer containing query
423c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      response on query completion. If this parameter is NULL, the API will
424c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      allocate its own query response buffer, which is going to be freed after
425c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      query completion.
426c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  response_size - Contains size of preallocated response buffer on the way in,
427c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      and size of the received response on query completion. Can be NULL.
428c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  query_cb - A callback to monitor query state.
429c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  query_opaque - An opaque pointer associated with the query.
430c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  to - Milliseconds to allow for the query to complete. Negative value means
431c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  "forever".
432c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Return:
433c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  Referenced SDKCtlQuery descriptor for the query that has been sent.
434c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine */
435c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkineextern SDKCtlQuery* sdkctl_query_build_and_send(SDKCtlSocket* sdkctl,
436c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                                int query_type,
437c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                                uint32_t in_data_size,
438c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                                const void* in_data,
439c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                                void** response_buffer,
440c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                                uint32_t* response_size,
441c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                                on_sdkctl_query_cb query_cb,
442c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                                void* query_opaque,
443c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                                int to);
444c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
445c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/* References SDKCtlQuery object.
446c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Param:
447c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  query - Initialized SDKCtlQuery instance.
448c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Return:
449c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  Number of outstanding references to the object.
450c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine */
451c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkineextern int sdkctl_query_reference(SDKCtlQuery* query);
452c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
453c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/* Releases SDKCtlQuery object.
454c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Note that upon exit from this routine the object might be destroyed, even if
455c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * this routine returns value other than zero.
456c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Param:
457c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  query - Initialized SDKCtlQuery instance.
458c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Return:
459c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  Number of outstanding references to the object.
460c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine */
461c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkineextern int sdkctl_query_release(SDKCtlQuery* query);
462c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
463c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/* Gets address of query's input data buffer (data to be send).
464c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Param:
465c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  query - Query to get data buffer for.
466c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Return:
467c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  Address of query's input data buffer.
468c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine */
469c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkineextern void* sdkctl_query_get_buffer_in(SDKCtlQuery* query);
470c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
4717136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine/* Gets address of query's output data buffer (response data).
4727136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Param:
4737136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  query - Query to get data buffer for.
4747136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Return:
4757136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  Address of query's output data buffer.
4767136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine */
4777136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkineextern void* sdkctl_query_get_buffer_out(SDKCtlQuery* query);
4787136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine
479c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/********************************************************************************
480c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *                          SDKCtlSocket API
481c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine ********************************************************************************/
482c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
483c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/* Creates an SDK controller socket descriptor.
484c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Param:
485c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  reconnect_to - Timeout before trying to reconnect, or retry connection
486c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      attempts after disconnection, or on connection failures.
487c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  service_name - Name of the SdkController service for this socket (such as
488c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      'sensors', 'milti-touch', etc.)
4897136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  on_socket_connection - A callback to invoke on socket connection events.
4907136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  on_port_connection - A callback to invoke on port connection events.
491c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  on_message - A callback to invoke when a message is received from the SDK
492c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      controller.
493c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  opaque - An opaque pointer to associate with the socket.
494c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Return:
495c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  Initialized SDKCtlSocket instance on success, or NULL on failure.
496c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine */
497c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkineextern SDKCtlSocket* sdkctl_socket_new(int reconnect_to,
498c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                       const char* service_name,
4997136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine                                       on_sdkctl_socket_connection_cb on_socket_connection,
5007136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine                                       on_sdkctl_port_connection_cb on_port_connection,
501c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                       on_sdkctl_message_cb on_message,
502c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                       void* opaque);
503c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
504c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/* Improves throughput by recycling memory allocated for buffers transferred via
505c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * this API.
506c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *
507c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * In many cases data exchanged between SDK controller sides are small, and,
508c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * although may come quite often, are coming in a sequential manner. For instance,
509c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * sensor service on the device may send us sensor updates every 20ms, one after
510c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * another. For such data traffic it makes perfect sense to recycle memory
511c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * allocated for the previous sensor update, rather than to free it just to
512c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * reallocate same buffer in 20ms. This routine sets properties of the recycler
513c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * for the given SDK controller connection. Recycling includes memory allocated
514c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * for all types of data transferred in this API: packets, and queries.
515c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Param:
516c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  sdkctl - Initialized SDKCtlSocket instance.
517c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  data_size - Size of buffer to allocate for each data block.
518c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  max_recycled_num - Maximum number of allocated buffers to keep in the
519c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      recycler.
520c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine */
521c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkineextern void sdkctl_init_recycler(SDKCtlSocket* sdkctl,
522c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                 uint32_t data_size,
523c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine                                 int max_recycled_num);
524c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
525c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/* References SDKCtlSocket object.
526c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Param:
527c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  sdkctl - Initialized SDKCtlSocket instance.
528c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Return:
529c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  Number of outstanding references to the object.
530c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine */
531c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkineextern int sdkctl_socket_reference(SDKCtlSocket* sdkctl);
532c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
533c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/* Releases SDKCtlSocket object.
534c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Note that upon exit from this routine the object might be destroyed, even if
535c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * this routine returns value other than zero.
536c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Param:
537c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  sdkctl - Initialized SDKCtlSocket instance.
538c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Return:
539c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  Number of outstanding references to the object.
540c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine */
541c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkineextern int sdkctl_socket_release(SDKCtlSocket* sdkctl);
542c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
543c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/* Asynchronously connects to SDK controller.
544c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Param:
545c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  sdkctl - Initialized SDKCtlSocket instance.
546c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  port - TCP port to connect the socket to.
547c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  retry_to - Number of milliseconds to wait before retrying a failed
548c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      connection attempt.
549c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine */
550c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkineextern void sdkctl_socket_connect(SDKCtlSocket* sdkctl, int port, int retry_to);
551c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
552c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/* Asynchronously reconnects to SDK controller.
553c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Param:
554c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  sdkctl - Initialized SDKCtlSocket instance.
555c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  port - TCP port to reconnect the socket to.
556c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  retry_to - Number of milliseconds to wait before reconnecting. Same timeout
557c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *      will be used for retrying a failed connection attempt.
558c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine */
559c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkineextern void sdkctl_socket_reconnect(SDKCtlSocket* sdkctl, int port, int retry_to);
560c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
561c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine/* Disconnects from SDK controller.
562c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine * Param:
563c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine *  sdkctl - Initialized SDKCtlSocket instance.
564c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine */
565c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkineextern void sdkctl_socket_disconnect(SDKCtlSocket* sdkctl);
566c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine
5677136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine/* Checks if SDK controller socket is connected.
5687136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Param:
5697136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  sdkctl - Initialized SDKCtlSocket instance.
5707136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Return:
5717136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  Boolean: 1 if socket is connected, 0 if socket is not connected.
5727136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine */
5737136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkineextern int sdkctl_socket_is_connected(SDKCtlSocket* sdkctl);
5747136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine
5757136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine/* Checks if SDK controller port is ready for emulation.
5767136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Param:
5777136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  sdkctl - Initialized SDKCtlSocket instance.
5787136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Return:
5797136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  Boolean: 1 if port is ready, 0 if port is not ready.
5807136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine */
5817136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkineextern int sdkctl_socket_is_port_ready(SDKCtlSocket* sdkctl);
5827136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine
5837136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine/* Gets status of the SDK controller port for this socket.
5847136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Param:
5857136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  sdkctl - Initialized SDKCtlSocket instance.
5867136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Return:
5877136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  Status of the SDK controller port for this socket.
5887136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine */
5897136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkineextern SdkCtlPortStatus sdkctl_socket_get_port_status(SDKCtlSocket* sdkctl);
5907136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine
5917136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine/* Checks if handshake was successful.
5927136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Param:
5937136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  sdkctl - Initialized SDKCtlSocket instance.
5947136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine * Return:
5957136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine *  Boolean: 1 if handshake was successful, 0 if handshake was not successful.
5967136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine */
5977136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkineextern int sdkctl_socket_is_handshake_ok(SDKCtlSocket* sdkctl);
5987136b053b7fc7840ec64e01d1d19ab822e1f949aVladimir Chtchetkine
599c8aa2c570d30098da59f1967d5158024ed28570dVladimir Chtchetkine#endif  /* ANDROID_SDKCONTROL_SOCKET_H_ */
600