ArDrone SDK 1.8 added
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / ARDroneLib / VP_SDK / Examples / linux / api_bluetoothClientTCP_raw_sdl.c
1 #include <stdlib.h>
2 #include <ctype.h>
3
4 #include <VP_Api/vp_api.h>
5 #include <VP_Api/vp_api_thread_helper.h>
6 #include <VP_Api/vp_api_error.h>
7 #include <VP_Stages/vp_stages_configs.h>
8 #include <VP_Stages/vp_stages_io_console.h>
9 #include <VP_Stages/vp_stages_o_sdl.h>
10 #include <VP_Stages/vp_stages_io_com.h>
11 #include <VP_Stages/vp_stages_io_file.h>
12 #include <VP_Os/vp_os_print.h>
13 #include <VP_Os/vp_os_malloc.h>
14
15
16 #define NB_STAGES 2
17
18
19 static PIPELINE_HANDLE pipeline_handle;
20
21
22 PROTO_THREAD_ROUTINE(escaper,nomParams);
23 PROTO_THREAD_ROUTINE(app,nomParams);
24
25
26 BEGIN_THREAD_TABLE
27   THREAD_TABLE_ENTRY(escaper,20)
28   THREAD_TABLE_ENTRY(app,20)
29 END_THREAD_TABLE
30
31
32 int
33 main(int argc, char **argv)
34 {
35   START_THREAD(escaper, NO_PARAM);
36   START_THREAD(app, argv);
37
38   JOIN_THREAD(escaper);
39   JOIN_THREAD(app);
40
41   return EXIT_SUCCESS;
42 }
43
44
45 PROTO_THREAD_ROUTINE(app,argv)
46 {
47   vp_api_io_pipeline_t    pipeline;
48   vp_api_io_data_t        out;
49   vp_api_io_stage_t       stages[NB_STAGES];
50
51   vp_stages_input_com_config_t      icc;
52   vp_stages_output_sdl_config_t     osc;
53
54   vp_com_t                        com;
55   vp_com_bluetooth_connection_t   connection;
56   vp_com_bluetooth_config_t       config;
57
58   vp_os_memset( &icc,         0, sizeof(vp_stages_input_com_config_t) );
59   vp_os_memset( &connection,  0, sizeof(vp_com_bluetooth_connection_t) );
60   vp_com_str_to_address("00:01:48:03:70:54",&connection.address);
61   vp_stages_fill_default_config(BLUETOOTH_COM_CONFIG, &config, sizeof(config));
62   vp_os_memset(&com, 0, sizeof(vp_com_t));
63   vp_stages_fill_default_config(SDL_DECODING_QCIF_CONFIG, &osc, sizeof(osc));
64
65   com.type                          = VP_COM_BLUETOOTH;
66   icc.com                           = &com;
67   icc.config                        = (vp_com_config_t*)&config;
68   icc.connection                    = (vp_com_connection_t*)&connection;
69   icc.socket.type                   = VP_COM_CLIENT;
70   icc.socket.protocol               = VP_COM_TCP;
71   icc.socket.port                   = 5555;
72   icc.buffer_size                   = 6400;
73
74   strcpy(icc.socket.serverHost,"192.168.2.23");
75
76   stages[0].type = VP_API_INPUT_SOCKET;
77   stages[0].cfg = (void *)&icc;
78   stages[0].funcs = vp_stages_input_com_funcs;
79
80   stages[1].type = VP_API_OUTPUT_SDL;
81   stages[1].cfg = (void *)&osc;
82   stages[1].funcs = vp_stages_output_sdl_funcs;
83
84   pipeline.nb_stages = NB_STAGES;
85   pipeline.stages = &stages[0];
86
87   vp_api_open(&pipeline, &pipeline_handle);
88   out.status = VP_API_STATUS_PROCESSING;
89   while(SUCCEED(vp_api_run(&pipeline, &out)) && (out.status == VP_API_STATUS_PROCESSING || out.status == VP_API_STATUS_STILL_RUNNING));
90   vp_api_close(&pipeline, &pipeline_handle);
91
92   return EXIT_SUCCESS;
93 }