ArDrone SDK 1.8 added
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / ARDroneLib / VP_SDK / Examples / linux / api_bluetoothClientTCP_console.c
1 #include <stdlib.h>
2 #include <ctype.h>
3
4 #include <VP_Api/vp_api.h>
5 #include <VP_Api/vp_api_error.h>
6 #include <VP_Stages/vp_stages_configs.h>
7 #include <VP_Stages/vp_stages_io_console.h>
8 #include <VP_Stages/vp_stages_io_com.h>
9 #include <VP_Os/vp_os_print.h>
10 #include <VP_Os/vp_os_malloc.h>
11
12
13 #define NB_STAGES 2
14
15
16 static PIPELINE_HANDLE pipeline_handle;
17
18
19 int
20 main(int argc, char **argv)
21 {
22   vp_api_io_pipeline_t    pipeline;
23   vp_api_io_data_t        out;
24   vp_api_io_stage_t       stages[NB_STAGES];
25
26   vp_stages_input_com_config_t     icc;
27
28   vp_com_t                      com;
29   vp_com_bluetooth_config_t     config;
30   vp_com_bluetooth_connection_t connection;
31
32   vp_os_memset( &icc,         0, sizeof(vp_stages_input_com_config_t) );
33   vp_os_memset( &connection,  0, sizeof(vp_com_bluetooth_connection_t) );
34   vp_com_str_to_address("00:01:48:03:70:54",&connection.address);
35   vp_stages_fill_default_config(BLUETOOTH_COM_CONFIG, &config, sizeof(config));
36   vp_os_memset(&com, 0, sizeof(vp_com_t));
37
38   com.type                          = VP_COM_BLUETOOTH;
39   icc.com                           = &com;
40   icc.config                        = (vp_com_config_t*)&config;
41   icc.connection                    = (vp_com_connection_t*)&connection;
42   icc.socket.type                   = VP_COM_CLIENT;
43   icc.socket.protocol               = VP_COM_TCP;
44   icc.socket.port                   = 5555;
45   icc.buffer_size                   = 64;
46
47   strcpy(icc.socket.serverHost,"192.168.2.23");
48
49   stages[0].type = VP_API_INPUT_SOCKET;
50   stages[0].cfg = (void *)&icc;
51   stages[0].funcs = vp_stages_input_com_funcs;
52
53   stages[1].type = VP_API_OUTPUT_CONSOLE;
54   stages[1].cfg = NULL;
55   stages[1].funcs = vp_stages_output_console_funcs;
56
57   pipeline.nb_stages = NB_STAGES;
58   pipeline.stages = &stages[0];
59
60   vp_api_open(&pipeline, &pipeline_handle);
61   out.status = VP_API_STATUS_PROCESSING;
62   while(SUCCEED(vp_api_run(&pipeline, &out)) && (out.status == VP_API_STATUS_PROCESSING || out.status == VP_API_STATUS_STILL_RUNNING));
63   vp_api_close(&pipeline, &pipeline_handle);
64
65   return EXIT_SUCCESS;
66 }