ev3duder  0.3.0
EV3 Downloader/Uploader
tcp.h
Go to the documentation of this file.
1 
8 #include "defs.h"
9 
10 //FIXME: encapsulate
11 struct tcp_handle {
12 #ifdef _WIN32
13  void* sock; // HANDLE/SOCKET
14 #else
15  int fd[2];
16 #endif
17  char serial[15];
18  char ip[48]; // enough for ipv6
19  unsigned tcp_port;
20  char name[96];
21  char protocol[8];
22 };
23 //FIXME: copy more stuff here
31 void *tcp_open(const char *serial, unsigned timeout);
32 
42 #ifdef _WIN32
43 int tcp_write(void* device, const u8* buf, size_t count);
44 #else
45 extern int (*tcp_write)(void* device, const u8* buf, size_t count);
46 #endif
47 
57 #ifdef _WIN32
58 extern int tcp_read(void* device, u8* buf, size_t count, int milliseconds);
59 #else
60 extern int (*tcp_read)(void* device, u8* buf, size_t count, int milliseconds);
61 #endif
62 
68 void tcp_close(void*);
76 const wchar_t *tcp_error(void* device);
77 
85 const wchar_t *tcp_info(void* device);
86 
unsigned tcp_port
Definition: tcp.h:19
unsigned serial
Definition: main.c:118
const wchar_t * tcp_info(void *device)
Returns an error string describing the last error occured.
char name[96]
Definition: tcp.h:20
void tcp_close(void *)
Closes the resource opened by bt_open.
Definition: tcp.c:241
int fd[2]
Definition: tcp.h:15
char ip[48]
Definition: tcp.h:18
unsigned timeout
Definition: main.c:126
const wchar_t * tcp_error(void *device)
Returns an error string describing the last error occured.
Definition: tcp.c:256
int(* tcp_write)(void *device, const u8 *buf, size_t count)
writes buf[1] till buf[count - 2] to device
Definition: tcp.c:271
uint8_t u8
Definition: defs.h:9
void * tcp_open(const char *serial, unsigned timeout)
open a bluetooth device described by device. NULL leads to default action
Definition: tcp.c:84
char protocol[8]
Definition: tcp.h:21
int(* tcp_read)(void *device, u8 *buf, size_t count, int milliseconds)
writes buf[1] till buf[count - 2] to device
Definition: tcp.c:272
char serial[15]
Definition: tcp.h:17
Definition: tcp.h:11