[tuxdroid-svn] r375 - daemon/trunk/libs
Status: Beta
Brought to you by:
ks156
From: jaguarondi <c2m...@c2...> - 2007-06-14 20:58:35
|
Author: jaguarondi Date: 2007-06-14 22:58:04 +0200 (Thu, 14 Jun 2007) New Revision: 375 Modified: daemon/trunk/libs/USBDaemon_command_tux.c Log: * Made all connection functions static. * Need to disconnect prior to connect or wakeup in case those commands are issued when the dongle is already handling an RF connection. Modified: daemon/trunk/libs/USBDaemon_command_tux.c =================================================================== --- daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-14 13:16:01 UTC (rev 374) +++ daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-14 20:58:04 UTC (rev 375) @@ -43,15 +43,15 @@ /*_____________________ F U N C T I O N S __________________________________*/ -void tux_connection(unsigned char const data[], unsigned char result[]); -int disconnect_from_tux(void); -int connect_to_tux(uint16_t id); -int id_request(uint16_t *id); -int id_lookup(uint16_t *id); -int change_id(uint16_t id); -int wakeup_tux(const uint16_t id); -int avoid_wifi_channel(unsigned char wifi_channel); -int random_tux_connection(void); +static void tux_connection(unsigned char const data[], unsigned char result[]); +static int disconnect_from_tux(void); +static int connect_to_tux(uint16_t id); +static int id_request(uint16_t *id); +static int id_lookup(uint16_t *id); +static int change_id(uint16_t id); +static int wakeup_tux(const uint16_t id); +static int avoid_wifi_channel(unsigned char wifi_channel); +static int random_tux_connection(void); static void sub_daemon_cmd_struct(unsigned char const data[], unsigned char result[], @@ -806,7 +806,7 @@ /** * tux connection commands */ -void tux_connection(unsigned char const data[], unsigned char result[]) +static void tux_connection(unsigned char const data[], unsigned char result[]) { result[0] = data[0]; switch (data[0]) @@ -970,7 +970,7 @@ * * \return 0 if successful, -1 otherwise */ -int disconnect_from_tux(void) +static int disconnect_from_tux(void) { if (send_usb_dongle_cmd(USB_TUX_CONNECTION_CMD, USB_TUX_CONNECTION_DISCONNECT, 0, 0) == USB_FRAME_SIZE) @@ -988,8 +988,12 @@ * * \return 0 if successful, -1 otherwise */ -int connect_to_tux(const uint16_t id) +static int connect_to_tux(const uint16_t id) { + /* Disconnecting first is necessary in case tux is connected */ + if (disconnect_from_tux() < 0) + return -1; + if (send_usb_dongle_cmd(USB_TUX_CONNECTION_CMD, USB_TUX_CONNECTION_CONNECT, (uint8_t)(id>>8), (uint8_t)id) == USB_FRAME_SIZE) return 0; @@ -1004,7 +1008,7 @@ * * \return 0 if successful, -1 otherwise */ -int random_tux_connection(void) +static int random_tux_connection(void) { uint16_t id; if (id_lookup((uint16_t *)&id) < 0) @@ -1023,7 +1027,7 @@ * \return 0 if successful, -1 otherwise */ #define ID_REQUEST_TIMEOUT 5 /* 100ms time unit */ -int id_request(uint16_t *id) +static int id_request(uint16_t *id) { int timeout_cnt = 0; @@ -1063,7 +1067,7 @@ * \return 0 if successful, -1 otherwise */ #define ID_LOOKUP_TIMEOUT 50 /* 100ms time unit */ -int id_lookup(uint16_t *id) +static int id_lookup(uint16_t *id) { int timeout_cnt = 0; @@ -1107,7 +1111,7 @@ * \return 0 if successful, -1 otherwise */ #define CHANGE_ID_TIMEOUT 70 -int change_id(const uint16_t id) +static int change_id(const uint16_t id) { int timeout_cnt = 0; @@ -1153,8 +1157,12 @@ * * \return 0 if successful, -1 otherwise */ -int wakeup_tux(const uint16_t id) +static int wakeup_tux(const uint16_t id) { + /* Disconnecting first is necessary in case tux is connected */ + if (disconnect_from_tux() < 0) + return -1; + /* Send the wakeup command then a connection with the given id */ if (send_usb_dongle_cmd(USB_TUX_CONNECTION_CMD, USB_TUX_CONNECTION_WAKEUP, 0, 0) != USB_FRAME_SIZE) @@ -1179,7 +1187,7 @@ * * \return 0 if successful, -1 otherwise */ -int avoid_wifi_channel(unsigned char wifi_channel) +static int avoid_wifi_channel(unsigned char wifi_channel) { /* * Conversion of the lower and higher frequencies of a wifi channel into |