diff options
author | Vladimir Chtchetkine <vchtchetkine@google.com> | 2012-04-05 16:22:55 -0700 |
---|---|---|
committer | Vladimir Chtchetkine <vchtchetkine@google.com> | 2012-04-06 14:33:17 -0700 |
commit | c8aa2c570d30098da59f1967d5158024ed28570d (patch) | |
tree | 894bf051d609573a856e9ec27c50b5b2247e94da /android/sensors-port.c | |
parent | 0f719d093468913f6af7455a7d2d5d7f04edd961 (diff) | |
download | external_qemu-c8aa2c570d30098da59f1967d5158024ed28570d.zip external_qemu-c8aa2c570d30098da59f1967d5158024ed28570d.tar.gz external_qemu-c8aa2c570d30098da59f1967d5158024ed28570d.tar.bz2 |
Implements SDKCtlSocket that implements communication protocol wih SdkController
In addition, this CL contains some minor tweaks to async-socket, and
async-socket-connector that improve tracebility.
Change-Id: Ib1309b19dcd02e96379155fea7015019d93160e7
Diffstat (limited to 'android/sensors-port.c')
-rw-r--r-- | android/sensors-port.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/android/sensors-port.c b/android/sensors-port.c index 9e9351d..8620783 100644 --- a/android/sensors-port.c +++ b/android/sensors-port.c @@ -173,6 +173,42 @@ _on_io_failure(void* opaque, AndroidDevice* ad, int failure) * Sensors port API *******************************************************************************/ +#include "android/sdk-controller-socket.h" + +static AsyncIOAction +_on_sdkctl_connection(void* client_opaque, SDKCtlSocket* sdkctl, AsyncIOState status) +{ + if (status == ASIO_STATE_FAILED) { + sdkctl_socket_reconnect(sdkctl, 1970, 20); + } + return ASIO_ACTION_DONE; +} + +void on_sdkctl_handshake(void* client_opaque, + SDKCtlSocket* sdkctl, + void* handshake, + uint32_t handshake_size, + AsyncIOState status) +{ + if (status == ASIO_STATE_SUCCEEDED) { + printf("---------- Handshake %d bytes received.\n", handshake_size); + } else { + printf("!!!!!!!!!! Handshake failed with status %d: %d -> %s\n", + status, errno, strerror(errno)); + sdkctl_socket_reconnect(sdkctl, 1970, 20); + } +} + +void on_sdkctl_message(void* client_opaque, + SDKCtlSocket* sdkctl, + SDKCtlPacket* message, + int msg_type, + void* msg_data, + int msg_size) +{ + printf("########################################################\n"); +} + AndroidSensorsPort* sensors_port_create(void* opaque) { @@ -180,6 +216,12 @@ sensors_port_create(void* opaque) char* wrk; int res; + SDKCtlSocket* sdkctl = sdkctl_socket_new(20, "test", _on_sdkctl_connection, + on_sdkctl_handshake, on_sdkctl_message, + NULL); +// sdkctl_init_recycler(sdkctl, 64, 8); + sdkctl_socket_connect(sdkctl, 1970, 20); + ANEW0(asp); asp->opaque = opaque; asp->is_connected = 0; |