ArDrone SDK 1.8 added
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / ARDroneLib / VP_SDK / Examples / elinux / api_bluetoothClientTCP_ofile.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_Stages/vp_stages_io_file.h>
10 #include <VP_Os/vp_os_print.h>
11 #include <VP_Os/vp_os_malloc.h>
12
13
14 #define NB_STAGES 2
15
16
17 static PIPELINE_HANDLE pipeline_handle;
18
19
20 int
21 main(int argc, char **argv)
22 {
23   vp_api_io_pipeline_t    pipeline;
24   vp_api_io_data_t        out;
25   vp_api_io_stage_t       stages[NB_STAGES];
26
27   vp_stages_input_com_config_t       icc;
28   vp_stages_output_file_config_t     ofc;
29
30   vp_com_t                        com;
31   vp_com_bluetooth_connection_t   connection;
32   vp_com_bluetooth_config_t       config;
33
34   vp_os_memset( &icc,         0, sizeof(vp_stages_input_com_config_t) );
35   vp_os_memset( &ofc,         0, sizeof(vp_stages_output_file_config_t) );
36   vp_os_memset( &connection,  0, sizeof(vp_com_bluetooth_connection_t) );
37   vp_com_str_to_address("00:01:48:03:70:54",&connection.address);
38   vp_stages_fill_default_config(BLUETOOTH_COM_CONFIG, &config, sizeof(config));
39   vp_os_memset(&com, 0, sizeof(vp_com_t));
40
41   com.type                          = VP_COM_BLUETOOTH;
42   icc.com                           = &com;
43   icc.config                        = (vp_com_config_t*)&config;
44   icc.connection                    = (vp_com_connection_t*)&connection;
45   icc.socket.type                   = VP_COM_CLIENT;
46   icc.socket.protocol               = VP_COM_TCP;
47   icc.socket.port                   = 5555;
48   icc.buffer_size                   = 6400;
49
50   strcpy(icc.socket.serverHost,"192.168.2.23");
51
52   ofc.name = "out.mpg";
53
54   stages[0].type = VP_API_INPUT_SOCKET;
55   stages[0].cfg = (void *)&icc;
56   stages[0].funcs = vp_stages_input_com_funcs;
57
58   stages[1].type = VP_API_OUTPUT_FILE;
59   stages[1].cfg = (void *)&ofc;
60   stages[1].funcs = vp_stages_output_file_funcs;
61
62   pipeline.nb_stages = NB_STAGES;
63   pipeline.stages = &stages[0];
64
65   vp_api_open(&pipeline, &pipeline_handle);
66   out.status = VP_API_STATUS_PROCESSING;
67   while(SUCCEED(vp_api_run(&pipeline, &out)) && (out.status == VP_API_STATUS_PROCESSING || out.status == VP_API_STATUS_STILL_RUNNING));
68   vp_api_close(&pipeline, &pipeline_handle);
69
70   return EXIT_SUCCESS;
71 }