2 #include <VP_Os/vp_os_print.h>
3 #include <VP_Os/vp_os_delay.h>
4 #include <VP_Api/vp_api_error.h>
8 #include <sys/socket.h>
10 #include <sys/timeb.h>
12 #include <sys/types.h>
15 #define DRONE_HOST "192.168.1.2"
16 #define DRONE_PORT 5555
18 #define TIME_TO_SEND 1024*10
19 #define SIZE_TO_SEND 1024
21 static com_socket_t clt;
23 static Write my_write;
25 static int8_t buffer[SIZE_TO_SEND];
28 static uint32_t timeGetTime()
30 struct timeval tv; struct timezone tz;
32 gettimeofday(&tv,&tz);
34 return (uint32_t)( tv.tv_sec*1000 + tv.tv_usec/10000 );
40 vp_com_connection_t connection;
42 config.connection = VP_COM_WIFI;
43 config.localAdapterName = "rausb0";
45 connection.essid = "Drone";
46 connection.channel = 10;
48 if(FAILED(com_init(&config)))
49 PRINT("com_init failed\n");
51 if(FAILED(com_passKey("9F1C3EE11CBA230B27BF1C1B6F")))
52 PRINT("com_passKey failed\n");
54 if(FAILED(com_connect(&connection,1)))
55 PRINT("com_connect failed\n");
57 clt.socket = VP_COM_CLIENT;
58 clt.port = DRONE_PORT;
59 clt.serverHost = DRONE_HOST;
61 if(SUCCEED(com_open(&clt,&my_read,&my_write)))
64 float st = timeGetTime();
65 float et = timeGetTime();
69 for(i=0; i < TIME_TO_SEND;i++)
73 PRINT("\r reception n° %d... ",i);
78 while(received != SIZE_TO_SEND)
80 my_read(&clt,buffer,&size);
82 size = SIZE_TO_SEND - received;
85 PRINT("%d bytes ",received);
89 d = (et - st) / 1000.0f;
92 float tx = SIZE_TO_SEND * TIME_TO_SEND / 1024.0f;
95 PRINT("\n---------------\n");
96 PRINT("Start Time : %f\n",st);
97 PRINT("End Time : %f\n",et);
98 PRINT("%d Kbytes sent in %f time\n",SIZE_TO_SEND * TIME_TO_SEND / 1024,d);
99 PRINT("Debit: %f\n",db);
100 PRINT("\n---------------\n");
104 PRINT("snif... pas connecte a la socket\n");
107 PRINT("Waiting for disconnection\n");
111 PRINT("Disconnected\n");