Input/Output wrappers for Bluetooth.
More...
Go to the source code of this file.
|
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...
|
|
Input/Output wrappers for Bluetooth.
- Author
- Ahmad Fatoum
- Copyright
- (c) 2015 Ahmad Fatoum. Code available under terms of the GNU General Public License 3.0
Definition in file btserial.h.
void bt_close |
( |
void * |
handle | ) |
|
Closes the resource opened by bt_open
.
- Parameters
-
[in] | device | handle returned by bt_open |
- See also
- implementation at bt-win.c and bt-unix.c
Closes the resource opened by bt_open
.
- Parameters
-
Closes the resource opened by bt_open
.
- Parameters
-
[in] | handle | handle 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] | device | handle 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
-
- Returns
- message An error string
- Parameters
-
[in] | device | handle 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_in | string describing the bluetooth device |
[in] | only | for *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] | virtual | COM 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] | device | handle returned by bt_open |
[in] | buf | buffer to write to |
[in] | count | number of characters to be read |
[in] | milliseconds | number 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] | device | handle returned by bt_open() |
[in] | buf | buffer to write to |
[in] | count | number of characters to be read |
[in] | milliseconds | number 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] | device | handle returned by bt_open |
[in] | buf | buffer to write to |
[in] | count | number of characters to be read |
[in] | milliseconds | is 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] | device | handle returned by bt_open |
[in] | buf | byte string to write, the first byte is omitted |
[in] | count | number 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] | handle | handle returned by bt_open() |
[in] | buf | byte string to write, the first byte is omitted |
[in] | count | number 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] | handle | handle returned by bt_open |
[in] | buf | byte string to write, the first byte is omitted |
[in] | count | number 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.