Author: JDM
Date: 2009-06-22 18:08:14 +0200 (Mon, 22 Jun 2009)
New Revision: 4854
Added:
software_suite_v3/smart-core/smart-api/cpp/
software_suite_v3/smart-core/smart-api/cpp/API/
software_suite_v3/smart-core/smart-api/cpp/API/TuxAPI.c
software_suite_v3/smart-core/smart-api/cpp/API/TuxAPI.h
software_suite_v3/smart-core/smart-api/cpp/Makefile
software_suite_v3/smart-core/smart-api/cpp/README.TXT
Log:
* First release for C++ API
Added: software_suite_v3/smart-core/smart-api/cpp/API/TuxAPI.c
===================================================================
--- software_suite_v3/smart-core/smart-api/cpp/API/TuxAPI.c
(rev 0)
+++ software_suite_v3/smart-core/smart-api/cpp/API/TuxAPI.c 2009-06-22
16:08:14 UTC (rev 4854)
@@ -0,0 +1,644 @@
+/*
+ * C++ TuxAPI
+ *
+ * An API written in C++ for the Tux Droid
+ *
+ * Joel Matteotti <joel.matteotti _AT_ free _DOT_ fr>
+ *
+ * Version 1.0.0
+ *
+ * =============== GPL HEADER =====================
+ * This file is part of C++ TuxAPI.
+ *
+ * C++ TuxAPI is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * C++ TuxAPI is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with "C++ TuxAPI". If not, see <http://www.gnu.org/licenses/>.
+ *
+ * ====================================================
+ *
+ * TODO Code:
+ *
+ * - Complete the status part
+ * - Allow the use of sound_flash
+ * - Modify the 3 values of the TuxAPI_LEDS_INTENSITY_LEVEL enumeration
+ * - Rename all constant of TuxAPI_STATUS_REQUESTED for more short name
+ *
+ * ====================================================
+ *
+ * More informations about the C++ API:
http://bbs.tuxisalive.com/viewtopic.php?pid=678
+ *
+ *
+*/
+
+#include <iostream>
+#include <string.h>
+#include <vector>
+#include "TuxAPI.h"
+
+using namespace std;
+
+string ReplaceAllG(string strSrc, string strSearch, string strReplace){
+ size_t start, end = 0, sizeSearch = strSearch.size();
+ while((start = strSrc.find(strSearch, end))!=string::npos){
+ end = start + sizeSearch;
+ strSrc.replace(start, sizeSearch, strReplace);
+ }
+ return strSrc;
+}
+
+TuxAPI::TuxAPI(void)
+{
+}
+
+//Interaction with the TuxHttp server
+string TuxAPI::doUrlAction(TuxAPI_LEVEL level, string url)
+{
+
+#ifdef WIN32
+ WSADATA WSAData;
+ WSAStartup(MAKEWORD(2,0), &WSAData);
+
+ SOCKET sock;
+ SOCKADDR_IN sin;
+#else
+ int sock;
+ struct sockaddr_in sin;
+#endif
+
+ char buffer[1024];
+
+ string srequete = "GET /";
+
+ switch(level)
+ {
+ case CLIENT_LEVEL_ANONYME: srequete += "-1";
+ break;
+ case CLIENT_LEVEL_FREE: srequete += "0";
+ break;
+ case CLIENT_LEVEL_RESTRICTED: srequete += "1";
+ break;
+ case CLIENT_LEVEL_ROOT: srequete += "2";
+ break;
+ }
+
+
+ srequete += url;
+ srequete += " HTTP/1.1\r\n";
+ srequete += "\r\n";
+
+ //cout << srequete << endl;
+
+ size_t requete_taille = srequete.size() + 1;
+
+ char crequete[requete_taille];
+ strncpy( crequete, srequete.c_str(), requete_taille );
+
+ int i = 0;
+ string source = "";
+
+ sock = socket(AF_INET, SOCK_STREAM, 0);
+
+ sin.sin_addr.s_addr = inet_addr("127.0.0.1");
+ sin.sin_port = 270;
+ sin.sin_family = AF_INET;
+ sin.sin_port = htons(270);
+
+#ifdef WIN32
+ connect(sock, (SOCKADDR *)&sin, sizeof(sin)); // on se connecte sur le
site web.
+#else
+ connect(sock, (struct sockaddr *)&sin, sizeof(sin));
+#endif
+
+ send(sock, crequete, strlen(crequete), 0); // on envoie la requ�te HTTP.
+
+ do
+ {
+ i = recv(sock, buffer, sizeof(buffer), 0); // le buffer r�cup�re les
donn�es re�ues.
+ source += buffer;
+ } while (i != 0);
+
+#ifdef WIN32
+ closesocket(sock); // on ferme le socket.
+ WSACleanup();
+#else
+ close(sock);
+#endif
+
+ return source;
+}
+
+//Allow tux do an action with his motors
+void TuxAPI::doMotorAction(TuxAPI_LEVEL level, TuxAPI_ACTION action)
+{
+ switch(action)
+ {
+ case FLIPPERS_UP: doUrlAction(level, "/flippers/up?");
+ break;
+ case FLIPPERS_DOWN: doUrlAction(level, "/flippers/down?");
+ break;
+ case MOUTH_OPEN: doUrlAction(level, "/mouth/open?");
+ break;
+ case MOUTH_CLOSE: doUrlAction(level, "/mouth/close?");
+ break;
+ case EYES_OPEN: doUrlAction(level, "/eyes/open?");
+ break;
+ case EYES_CLOSE: doUrlAction(level, "/eyes/close?");
+ break;
+ }
+}
+
+//Allow rotate Tux left/right
+void TuxAPI::DoRotorAction(TuxAPI_LEVEL level, TuxAPI_ACTION action, int
rotation)
+{
+ char cmd[4096];
+
+ switch(action)
+ {
+ case ROTATE_LEFT: strcpy(cmd, "/spinning/left_on?count=");
+ break;
+ case ROTATE_RIGHT: strcpy(cmd, "spinning/right_on?count=");
+ break;
+ }
+
+
+ char _rotation[50];
+ sprintf(_rotation, "%d", rotation);
+ strcat(cmd, _rotation);
+
+ doUrlAction(level, cmd);
+}
+
+void TuxAPI::DoLedsAction(TuxAPI_LEVEL level, TuxAPI_ACTION action,
TuxAPI_LEDS leds)
+{
+ char cmd[4096];
+ strcpy(cmd, "/leds/");
+
+ switch(action)
+ {
+ case LEDS_ON: strcat(cmd, "on?leds=");
+ break;
+ case LEDS_OFF: strcat(cmd, "off?leds=");
+ break;
+ }
+
+ switch(leds)
+ {
+ case LED_BOTH: strcat(cmd, "LED_BOTH");
+ break;
+ case LED_LEFT: strcat(cmd, "LED_LEFT");
+ break;
+ case LED_RIGHT: strcat(cmd, "LED_RIGHT");
+ break;
+ }
+
+ if(action == LEDS_ON)
+ strcat(cmd, "&intensity=10.0");
+
+ doUrlAction(level, cmd);
+}
+
+void TuxAPI::DoLedsAction(TuxAPI_LEVEL level, TuxAPI_ACTION action,
TuxAPI_LEDS leds, double intensity)
+{
+ char cmd[4096];
+ strcpy(cmd, "/leds/");
+
+ switch(action)
+ {
+ case LEDS_ON: strcat(cmd, "on?leds=");
+ break;
+ case LEDS_OFF: strcat(cmd, "off?leds=");
+ break;
+ }
+
+ switch(leds)
+ {
+ case LED_BOTH: strcat(cmd, "LED_BOTH");
+ break;
+ case LED_LEFT: strcat(cmd, "LED_LEFT");
+ break;
+ case LED_RIGHT: strcat(cmd, "LED_RIGHT");
+ break;
+ }
+
+
+ if(action == LEDS_ON)
+ {
+ strcat(cmd, "&intensity=");
+ char _intensity[50];
+ sprintf(_intensity,"%.2f",(intensity+0.1));
+ strcat(cmd, _intensity);
+ }
+
+ doUrlAction(level, cmd);
+}
+
+void TuxAPI::DoBlinkLedsAction(TuxAPI_LEVEL level, TuxAPI_LEDS leds, int count)
+{
+ char cmd[4096];
+ strcpy(cmd, "/leds/blink/count?count=");
+ strcat(cmd, (char *)count);
+ strcat(cmd, "&delay=0.1");
+
+ switch(leds)
+ {
+ case LED_BOTH: strcat(cmd, "LED_BOTH");
+ break;
+ case LED_LEFT: strcat(cmd, "LED_LEFT");
+ break;
+ case LED_RIGHT: strcat(cmd, "LED_RIGHT");
+ break;
+ }
+
+ doUrlAction(level,cmd);
+}
+
+void TuxAPI::DoBlinkLedsAction(TuxAPI_LEVEL level, TuxAPI_LEDS leds, int
count, double delay)
+{
+ char cmd[4096];
+ strcpy(cmd, "/leds/blink/count?count=");
+ strcat(cmd, (char *)count);
+ strcat(cmd, "&delay=");
+
+ char _delay[50];
+ sprintf(_delay, "%.2f",(delay+0.1));
+ strcat(cmd, _delay);
+
+ switch(leds)
+ {
+ case LED_BOTH: strcat(cmd, "LED_BOTH");
+ break;
+ case LED_LEFT: strcat(cmd, "LED_LEFT");
+ break;
+ case LED_RIGHT: strcat(cmd, "LED_RIGHT");
+ break;
+ }
+
+ doUrlAction(level,cmd);
+}
+
+
+void TuxAPI::DoSpeak(TuxAPI_LEVEL level, char *Text)
+{
+ char cmd[4096];
+ strcpy(cmd,"/tts/speak?text=");
+ strcat(cmd,Text);
+
+ string cmd_ = cmd;
+ cmd_ = ReplaceAllG(cmd_, " ", "%20");
+ strcpy(cmd, cmd_.c_str());
+
+
+ doUrlAction(level, cmd);
+}
+
+void TuxAPI::DoSpeak(TuxAPI_LEVEL level, TuxAPI_SPEAK_LOCUTOR locutor, char
*Text)
+{
+ char cmd[4096];
+ strcpy(cmd, "/tts/locutor?name=");
+
+ switch(locutor)
+ {
+ case Bruno: strcat(cmd, "Bruno");
+ break;
+ case Julie: strcat(cmd, "Julie");
+ break;
+ }
+
+ doUrlAction(level, cmd); //set the locutor
+
+ strcpy(cmd, "/tts/speak?text=");
+ strcat(cmd, Text);
+
+ string cmd_ = cmd;
+ cmd_ = ReplaceAllG(cmd_, " ", "%20");
+ strcpy(cmd, cmd_.c_str());
+
+
+ doUrlAction(level, cmd); //speak
+}
+
+void TuxAPI::DoSpeak(TuxAPI_LEVEL level, int pitch, char *Text)
+{
+ char cmd[4096];
+ strcpy(cmd, "/tts/pitch?value=");
+ char _pitch[256];
+ sprintf(_pitch, "%d", pitch);
+ strcat(cmd, _pitch);
+
+
+ doUrlAction(level, cmd); //set the pitch
+
+ strcpy(cmd, "/tts/speak?text=");
+ strcat(cmd, Text);
+
+ string cmd_ = cmd;
+ cmd_ = ReplaceAllG(cmd_, " ", "%20");
+ strcpy(cmd, cmd_.c_str());
+
+
+ doUrlAction(level, cmd); //speak
+}
+
+void TuxAPI::DoSpeak(TuxAPI_LEVEL level, TuxAPI_SPEAK_LOCUTOR locutor, int
pitch, char *Text)
+{
+ char cmd[4096];
+ strcpy(cmd, "/tts/locutor?name=");
+
+ switch(locutor)
+ {
+ case Bruno: strcat(cmd, "Bruno");
+ break;
+ case Julie: strcat(cmd, "Julie");
+ break;
+ }
+
+ doUrlAction(level, cmd); //set the locutor
+
+ strcpy(cmd, "/tts/pitch?value=");
+ char _pitch[256];
+ sprintf(_pitch, "%d", pitch);
+ strcat(cmd, _pitch);
+
+
+ doUrlAction(level, cmd); //set the pitch
+
+ strcpy(cmd, "/tts/speak?text=");
+ strcat(cmd, Text);
+
+ string cmd_ = cmd;
+ cmd_ = ReplaceAllG(cmd_, " ", "%20");
+ strcpy(cmd, cmd_.c_str());
+
+
+ doUrlAction(level, cmd); //speak
+}
+
+void TuxAPI::AttituneControl(TuxAPI_LEVEL level, TuxAPI_ACTION action, char
*attitune)
+{
+ char cmd[8128];
+ strcpy(cmd, "/attitune/");
+
+ switch(action)
+ {
+ case ATTITUNE_PLAY:
+ {
+ strcat(cmd, "load_and_play?path=");
+ strcat(cmd, attitune);
+ }
+ break;
+ case ATTITUNE_STOP: strcat(cmd, "stop?");
+ break;
+ }
+
+ doUrlAction(level,cmd);
+}
+
+void TuxAPI::WavControl(TuxAPI_LEVEL level, TuxAPI_ACTION action, char *sound)
+{
+ char cmd[8128];
+ strcpy(cmd, "/wav/");
+
+ switch(action)
+ {
+ case ATTITUNE_PLAY:
+ {
+ strcat(cmd, "play?path=");
+ strcat(cmd, sound);
+ }
+ break;
+ case ATTITUNE_STOP: strcat(cmd, "stop?");
+ break;
+ }
+
+ doUrlAction(level,cmd);
+}
+
+int Split(vector<string>& vecteur, string chaine, char separateur)
+{
+ vecteur.clear();
+
+ string::size_type stTemp = chaine.find(separateur);
+
+ while(stTemp != string::npos)
+ {
+ vecteur.push_back(chaine.substr(0, stTemp));
+ chaine = chaine.substr(stTemp + 1);
+ stTemp = chaine.find(separateur);
+ }
+
+ vecteur.push_back(chaine);
+
+ return vecteur.size();
+}
+
+string TuxAPI::getRawStatus(TuxAPI_LEVEL level, TuxAPI_STATUS_REQUESTED status)
+{
+ char cmd[4096];
+ strcpy(cmd, "/status/request_one?status_name=");
+
+ switch(status)
+ {
+ case flippers_motor_on: strcat(cmd, "flippers_motor_on");
+ break;
+ case flippers_position: strcat(cmd, "flippers_position");
+ break;
+
+
+ case eyes_motor_on: strcat(cmd, "eyes_motor_on");
+ break;
+ case eyes_position: strcat(cmd,"eyes_position");
+ break;
+ case eyes_remaining_movements: strcat(cmd, "eyes_remaining_movements");
+ break;
+
+ case mouth_motor_on: strcat(cmd, "mouth_motor_on");
+ break;
+ case mouth_position: strcat(cmd, "mouth_position");
+ break;
+ case mouth_remaining_movements: strcat(cmd,
"mouth_remaining_movements");
+ break;
+
+ case spin_left_motor_on: strcat(cmd, "spin_left_motor_on");
+ break;
+ case spin_right_motor_on: strcat(cmd, "spin_right_motor_on");
+ break;
+ case spinning_direction: strcat(cmd, "spinning_direction");
+ break;
+ case spinning_remaining_movements: strcat(cmd,
"spinning_remaining_movements");
+ break;
+
+ case right_led_state: strcat(cmd, "right_led_state");
+ break;
+ case left_led_state: strcat(cmd, "left_led_state");
+ break;
+
+
+ case light_level: strcat(cmd, "light_level");
+ break;
+ case battery_state: strcat(cmd, "battery_state");
+ break;
+ case battery_level: strcat(cmd, "battery_level");
+ break;
+ case charger_state: strcat(cmd, "charger_state");
+ break;
+
+ }
+
+ string data_raw = doUrlAction(level, cmd);
+
+ vector<string> VecStr;
+ int s = Split(VecStr, data_raw, '>');
+
+ string data = VecStr[10];
+ data = ReplaceAllG(data, "</value", "");
+
+
+ return data;
+}
+
+
+//=============== PUBLIC ===============
+
+void TuxAPI::Flippers_Up(void)
+{
+ doMotorAction(CLIENT_LEVEL_FREE, FLIPPERS_UP);
+}
+
+void TuxAPI::Flippers_Down(void)
+{
+ doMotorAction(CLIENT_LEVEL_FREE, FLIPPERS_DOWN);
+}
+
+void TuxAPI::Mouth_Open(void)
+{
+ doMotorAction(CLIENT_LEVEL_FREE, MOUTH_OPEN);
+}
+
+void TuxAPI::Mouth_Close(void)
+{
+ doMotorAction(CLIENT_LEVEL_FREE, MOUTH_CLOSE);
+}
+
+void TuxAPI::Eyes_Open(void)
+{
+ doMotorAction(CLIENT_LEVEL_FREE, EYES_OPEN);
+}
+
+void TuxAPI::Eyes_Close(void)
+{
+ doMotorAction(CLIENT_LEVEL_FREE, EYES_CLOSE);
+}
+
+void TuxAPI::Rotation_Left(int rotation)
+{
+ DoRotorAction(CLIENT_LEVEL_FREE, ROTATE_LEFT, rotation);
+}
+
+void TuxAPI::Rotation_Right(int rotation)
+{
+ DoRotorAction(CLIENT_LEVEL_FREE, ROTATE_RIGHT, rotation);
+}
+
+void TuxAPI::Leds_On(void)
+{
+ DoLedsAction(CLIENT_LEVEL_FREE, LEDS_ON, LED_BOTH);
+}
+
+void TuxAPI::Leds_On(TuxAPI_LEDS leds)
+{
+ DoLedsAction(CLIENT_LEVEL_FREE, LEDS_ON, leds);
+}
+
+void TuxAPI::Leds_On(double intensity)
+{
+ DoLedsAction(CLIENT_LEVEL_FREE, LEDS_ON, LED_BOTH, intensity);
+}
+
+void TuxAPI::Leds_On(TuxAPI_LEDS leds, double intensity)
+{
+ DoLedsAction(CLIENT_LEVEL_FREE, LEDS_ON, leds, intensity);
+}
+
+void TuxAPI::Leds_Off(void)
+{
+ DoLedsAction(CLIENT_LEVEL_FREE, LEDS_OFF, LED_BOTH);
+}
+
+void TuxAPI::Leds_Off(TuxAPI_LEDS leds)
+{
+ DoLedsAction(CLIENT_LEVEL_FREE, LEDS_OFF, leds);
+}
+
+void TuxAPI::Leds_Blink(void)
+{
+ DoBlinkLedsAction(CLIENT_LEVEL_FREE, LED_BOTH, 1);
+}
+
+void TuxAPI::Leds_Blink(TuxAPI_LEDS leds)
+{
+ DoBlinkLedsAction(CLIENT_LEVEL_FREE, leds, 1);
+}
+
+void TuxAPI::Leds_Blink(TuxAPI_LEDS leds, int count)
+{
+ DoBlinkLedsAction(CLIENT_LEVEL_FREE, leds, count);
+}
+
+void TuxAPI::Leds_Blink(TuxAPI_LEDS leds, int count, double delay)
+{
+ DoBlinkLedsAction(CLIENT_LEVEL_FREE, leds, count, delay);
+}
+
+void TuxAPI::Speak(char *Text)
+{
+ DoSpeak(CLIENT_LEVEL_FREE, Text);
+}
+
+void TuxAPI::Speak(TuxAPI_SPEAK_LOCUTOR locutor, char *Text)
+{
+ DoSpeak(CLIENT_LEVEL_FREE, locutor, Text);
+}
+
+void TuxAPI::Speak(int pitch, char *Text)
+{
+ DoSpeak(CLIENT_LEVEL_FREE, pitch, Text);
+}
+
+void TuxAPI::Speak(TuxAPI_SPEAK_LOCUTOR locutor, int pitch, char *Text)
+{
+ DoSpeak(CLIENT_LEVEL_FREE, locutor, pitch, Text);
+}
+
+void TuxAPI::PlayAttitune(char *attitune)
+{
+ AttituneControl(CLIENT_LEVEL_FREE, ATTITUNE_PLAY, attitune);
+}
+
+void TuxAPI::StopAttitune(void)
+{
+ AttituneControl(CLIENT_LEVEL_FREE, ATTITUNE_STOP, "");
+}
+
+void TuxAPI::PlayWav(char *sound)
+{
+ WavControl(CLIENT_LEVEL_FREE, WAV_PLAY, sound);
+}
+
+void TuxAPI::StopWav(void)
+{
+ WavControl(CLIENT_LEVEL_FREE, WAV_STOP, "");
+}
+
+string TuxAPI::getStatus(TuxAPI_STATUS_REQUESTED status)
+{
+ return getRawStatus(CLIENT_LEVEL_FREE, status);
+}
Added: software_suite_v3/smart-core/smart-api/cpp/API/TuxAPI.h
===================================================================
--- software_suite_v3/smart-core/smart-api/cpp/API/TuxAPI.h
(rev 0)
+++ software_suite_v3/smart-core/smart-api/cpp/API/TuxAPI.h 2009-06-22
16:08:14 UTC (rev 4854)
@@ -0,0 +1,251 @@
+/*
+ * C++ TuxAPI
+ *
+ * An API written in C++ for the Tux Droid
+ *
+ * Joel Matteotti <joel.matteotti _AT_ free _DOT_ fr>
+ *
+ * Version 1.0.0
+ *
+ * =============== GPL HEADER =====================
+ * This file is part of C++ TuxAPI.
+ *
+ * C++ TuxAPI is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * C++ TuxAPI is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with "C++ TuxAPI". If not, see <http://www.gnu.org/licenses/>.
+ *
+ * ====================================================
+ *
+*/
+
+
+#include <iostream>
+#include <string.h>
+
+#ifdef WIN32
+#include <winsock.h>
+#else
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#endif
+
+using namespace std;
+
+enum TuxAPI_LEVEL
+{
+ CLIENT_LEVEL_ANONYME = -1,
+ CLIENT_LEVEL_FREE = 0,
+ CLIENT_LEVEL_RESTRICTED = 1,
+ CLIENT_LEVEL_ROOT = 2,
+};
+
+/// <summary>
+/// All action can do Tux
+/// </summary>
+enum TuxAPI_ACTION
+{
+ FLIPPERS_UP = 1,
+ FLIPPERS_DOWN = 2,
+
+ MOUTH_OPEN = 3,
+ MOUTH_CLOSE = 4,
+
+ EYES_OPEN = 5,
+ EYES_CLOSE = 6,
+
+ LEDS_ON = 7,
+ LEDS_OFF = 8,
+
+ ROTATE_LEFT = 9,
+ ROTATE_RIGHT = 10,
+
+ ATTITUNE_PLAY = 11,
+ ATTITUNE_STOP = 12,
+
+ WAV_PLAY = 13,
+ WAV_STOP = 14,
+};
+
+/// <summary>
+/// The TTS voice (TODO: Add others voices)
+/// </summary>
+enum TuxAPI_SPEAK_LOCUTOR
+{
+ Bruno = 0,
+ Julie = 1,
+};
+
+/// <summary>
+/// //<<LED_BOTH|LED_RIGHT|LED_LEFT>>
+/// </summary>
+enum TuxAPI_LEDS
+{
+ LED_BOTH = 0,
+ LED_LEFT = 1,
+ LED_RIGHT = 2,
+};
+
+enum TuxAPI_STATUS_REQUESTED
+{
+ flippers_motor_on = 0,
+ flippers_position = 1,
+ flippers_remaining_movements = 2,
+
+ eyes_motor_on = 3,
+ eyes_position = 4,
+ eyes_remaining_movements = 5,
+
+ mouth_motor_on = 6,
+ mouth_position = 7,
+ mouth_remaining_movements = 8,
+
+ spin_left_motor_on = 9,
+ spin_right_motor_on = 10,
+ spinning_direction = 11,
+ spinning_remaining_movements = 12,
+
+ light_level = 13,
+ right_led_state = 14,
+ left_led_state = 15,
+
+ battery_level = 16,
+ battery_state = 17,
+ charger_state = 18,
+
+ //-----------
+
+ /* TODO: modify the number of any status
+ descriptor_complete = 4,
+ radio_state = 5,
+ dongle_plug = 6,
+
+
+ connection_quality = 15,
+
+ audio_flash_play = 16,
+ audio_general_play = 17,
+
+ flash_programming_current_track = 18,
+ flash_programming_last_track_size = 19,
+
+ tuxcore_symbolic_version = 20,
+ tuxaudio_symbolic_version = 21,
+ fuxusb_symbolic_version = 22,
+ fuxrf_symbolic_version = 23,
+ tuxrf_symbolic_version = 24,
+ driver_symbolic_version = 25,
+
+ sound_reflash_begin = 26,
+ sound_reflash_end = 27,
+ sound_reflash_current_trac = 28,
+
+
+ left_wing_button = 34,
+ sound_flash_count = 35,
+
+ osl_symbolic_version=38,
+ general_sound_state = 39,
+ wav_volume=40,
+ tts_volume=41,
+ tts_pitch=42,
+ tts_locutor=43,
+ wav_0_sound_state=44,
+ wav_0_pause_state=45,
+ wav_0_stop=46,
+ right_wing_button=47,
+ wav_1_sound_state=48,
+ wav_1_pause_state=49,
+ wav_1_stop=50,
+ wav_2_sound_state=51,
+ wav_2_pause_state=52,
+ wav_2_stop=53,
+ wav_3_sound_state=54,
+ wav_3_pause_state=55,
+ wav_3_stop=56,
+ tts_0_sound_state=57,
+ head_button=58,
+ tts_0_pause_state=59,
+ tts_0_stop=60,
+ tts_0_voice_loaded=61,
+ tts_0_speak_status=62,
+ tts_0_voice_list=63,
+ tts_wav_channel_start=64,
+ None=65,
+ remote_button=66,*/
+};
+
+class TuxAPI
+{
+private:
+ string doUrlAction(TuxAPI_LEVEL level, string url);
+ void doMotorAction(TuxAPI_LEVEL level, TuxAPI_ACTION action);
+ void DoRotorAction(TuxAPI_LEVEL level, TuxAPI_ACTION action, int rotation);
+
+ void DoLedsAction(TuxAPI_LEVEL level, TuxAPI_ACTION action, TuxAPI_LEDS
leds);
+ void DoLedsAction(TuxAPI_LEVEL level, TuxAPI_ACTION action, TuxAPI_LEDS
leds, double intensity);
+
+ void DoBlinkLedsAction(TuxAPI_LEVEL level, TuxAPI_LEDS leds, int count);
+ void DoBlinkLedsAction(TuxAPI_LEVEL level, TuxAPI_LEDS leds, int count,
double delay);
+
+ void DoSpeak(TuxAPI_LEVEL level, char *Text);
+ void DoSpeak(TuxAPI_LEVEL level, TuxAPI_SPEAK_LOCUTOR locutor, char *Text);
+ void DoSpeak(TuxAPI_LEVEL level, int pitch, char *Text);
+ void DoSpeak(TuxAPI_LEVEL level, TuxAPI_SPEAK_LOCUTOR locutor, int pitch,
char *Text);
+
+ void AttituneControl(TuxAPI_LEVEL level, TuxAPI_ACTION action, char
*attitune);
+
+ void WavControl(TuxAPI_LEVEL level, TuxAPI_ACTION action, char *sound);
+
+ string getRawStatus(TuxAPI_LEVEL level, TuxAPI_STATUS_REQUESTED status);
+
+public:
+ TuxAPI(void);
+ void Flippers_Up(void);
+ void Flippers_Down(void);
+ void Mouth_Open(void);
+ void Mouth_Close(void);
+ void Eyes_Open(void);
+ void Eyes_Close(void);
+ void Rotation_Left(int rotation);
+ void Rotation_Right(int rotation);
+ void Leds_On(void);
+ void Leds_On(TuxAPI_LEDS leds);
+ void Leds_On(double intensity);
+ void Leds_On(TuxAPI_LEDS leds, double intensity);
+ void Leds_Off(void);
+ void Leds_Off(TuxAPI_LEDS leds);
+
+ void Leds_Blink(void);
+ void Leds_Blink(TuxAPI_LEDS leds);
+ void Leds_Blink(TuxAPI_LEDS leds, int count);
+ void Leds_Blink(TuxAPI_LEDS leds, int count, double delay);
+
+ void Speak(char *Text);
+ void Speak(TuxAPI_SPEAK_LOCUTOR locutor, char *Text);
+ void Speak(int pitch, char *Text);
+ void Speak(TuxAPI_SPEAK_LOCUTOR locutor, int pitch, char *Text);
+
+ void PlayAttitune(char *attitune);
+ void StopAttitune(void);
+
+ void PlayWav(char *sound);
+ void StopWav(void);
+
+ string getStatus(TuxAPI_STATUS_REQUESTED status);
+
+
+
+
+
+
+};
Added: software_suite_v3/smart-core/smart-api/cpp/Makefile
===================================================================
--- software_suite_v3/smart-core/smart-api/cpp/Makefile
(rev 0)
+++ software_suite_v3/smart-core/smart-api/cpp/Makefile 2009-06-22 16:08:14 UTC
(rev 4854)
@@ -0,0 +1,12 @@
+
+all: main.o API/TuxAPI.o
+ g++ -o TuxAPIDemo API/TuxAPI.o main.o
+
+main.o: main.c
+ g++ -o main.o -c main.c -I./API/
+
+API/TuxAPI.o: API/TuxAPI.c
+ g++ -o API/TuxAPI.o -c API/TuxAPI.c -I./API/
+
+clean:
+ rm -f main.o API/TuxAPI.o
Added: software_suite_v3/smart-core/smart-api/cpp/README.TXT
===================================================================
--- software_suite_v3/smart-core/smart-api/cpp/README.TXT
(rev 0)
+++ software_suite_v3/smart-core/smart-api/cpp/README.TXT 2009-06-22
16:08:14 UTC (rev 4854)
@@ -0,0 +1,8 @@
+
+The C++ API for Tux Droid have been compiled AND tested on:
+
+- Windows XP SP3 (compiled with Dev-CPP)
+- Ubuntu 9.10 (compiled with G++)
+
+
+For more informations and for help on the API:
http://bbs.tuxisalive.com/viewtopic.php?pid=678
------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn