ev3duder  0.3.0
EV3 Downloader/Uploader
btserial.h File Reference

Input/Output wrappers for Bluetooth. More...

#include "defs.h"

Go to the source code of this file.

Functions

void * bt_open (const char *file_in, const char *file_out)
 open a bluetooth device described by device. NULL leads to default action More...
 
int bt_write (void *device, const u8 *buf, size_t count)
 writes buf[1] till buf[count - 2] to device More...
 
int bt_read (void *device, u8 *buf, size_t count, int milliseconds)
 writes buf[1] till buf[count - 2] to device More...
 
void bt_close (void *)
 Closes the resource opened by bt_open. More...
 
const wchar_t * bt_error (void *device)
 Returns an error string describing the last error occured. More...
 

Detailed Description

Input/Output wrappers for Bluetooth.

Author
Ahmad Fatoum

Definition in file btserial.h.

Function Documentation

void bt_close ( void *  handle)

Closes the resource opened by bt_open.

Parameters
[in]devicehandle returned by bt_open
See also
implementation at bt-win.c and bt-unix.c

Closes the resource opened by bt_open.

Parameters
[in]devicehandle returned by bt_open()

Closes the resource opened by bt_open.

Parameters
[in]handlehandle returned by bt_open
Bug:
It takes whopping 3 seconds for the COM port to be reclaimable. If opened before that, the device is unusable for a minute.

Definition at line 116 of file bt-unix.c.

const wchar_t* bt_error ( void *  fd_)

Returns an error string describing the last error occured.

Parameters
[in]devicehandle returned by bt_open
Returns
message An error string
See also
implementation at bt-win.c and bt-unix.c
Bug:
it's useless
Parameters
[in]devicehandle returned by bt_open()
Returns
message An error string
Parameters
[in]devicehandle returned by bt_open
Returns
message An error string

Definition at line 127 of file bt-unix.c.

void* bt_open ( const char *  device,
const char *  unused 
)

open a bluetooth device described by device. NULL leads to default action

Parameters
[in]file_instring describing the bluetooth device
[in]onlyfor *nix: non-NULL for cases where read/write files differ
Returns
handle a opaque handle for use with bt_{read,write,close,error}
See also
implementation at bt-win.c and bt-unix.c

open a bluetooth device described by device. NULL leads to default action

Parameters
[in]virtualCOM port or NULL
Returns
HANDLE Windows HANDLE to virtual COM port for use with bt_{read,write,close,error}

Definition at line 29 of file bt-unix.c.

int bt_read ( void *  handle,
u8 buf,
size_t  count,
int  milliseconds 
)

writes buf[1] till buf[count - 2] to device

Parameters
[in]devicehandle returned by bt_open
[in]bufbuffer to write to
[in]countnumber of characters to be read
[in]millisecondsnumber of milliseconds to wait at maximum. -1 is indefinitely
Returns
status -1 on error. bytes read otherwise.
Bug:
the milliseconds part needs to be tested more throughly
See also
implementation at bt-win.c and bt-unix.c
Parameters
[in]devicehandle returned by bt_open()
[in]bufbuffer to write to
[in]countnumber of characters to be read
[in]millisecondsnumber of milliseconds to wait at maximum. -1 is indefinitely
Returns
status -1 on error. bytes read otherwise.
Bug:
the milliseconds part needs to be tested more throughly
Parameters
[in]devicehandle returned by bt_open
[in]bufbuffer to write to
[in]countnumber of characters to be read
[in]millisecondsis ignored
Returns
status -1 on error. bytes read otherwise.
Bug:
milliseconds is ignored

Definition at line 77 of file bt-unix.c.

int bt_write ( void *  handle,
const u8 buf,
size_t  count 
)

writes buf[1] till buf[count - 2] to device

Parameters
[in]devicehandle returned by bt_open
[in]bufbyte string to write, the first byte is omitted
[in]countnumber of characters to be written (including leading ignored byte)
Returns
status -1 on error. bytes read otherwise.
Bug:
the first byte is omitted for compatiblity with the leading report byte demanded by hid_write. Wrapping HIDAPI could fix this.
See also
implementation at bt-win.c and bt-unix.c
Parameters
[in]handlehandle returned by bt_open()
[in]bufbyte string to write, the first byte is omitted
[in]countnumber of characters to be written (including leading ignored byte)
Returns
status -1 on error. bytes read otherwise.
Bug:
the first byte is omitted for compatiblity with the leading report byte demanded by hid_write. Wrapping HIDAPI could fix this.
Parameters
[in]handlehandle returned by bt_open
[in]bufbyte string to write, the first byte is omitted
[in]countnumber of characters to be written (including leading ignored byte)
Returns
status -1 on error. bytes read otherwise.
Bug:
the first byte is omitted for compatiblity with the leading report byte demanded by hid_write. Wrapping HIDAPI could fix this.

Definition at line 51 of file bt-unix.c.