Windows bluetooth I/O using virtual COM port.
More...
#include <stdlib.h>
#include <errno.h>
#include <windows.h>
#include "defs.h"
Go to the source code of this file.
|
void * | bt_open (const char *device, const char *unused) |
| opens COM Porte described by device. NULL leads to default action More...
|
|
int | bt_write (void *handle, const u8 *buf, size_t count) |
| writes buf[1] till buf[count - 2] to device More...
|
|
int | bt_read (void *handle, u8 *buf, size_t count, int milliseconds) |
| writes buf[1] till buf[count - 2] to device More...
|
|
void | bt_close (void *handle) |
| calls CloseHandle on argument More...
|
|
const wchar_t * | bt_error (void *fd_) |
| Returns an error string describing the last error occured. More...
|
|
Windows bluetooth I/O using virtual COM port.
- Author
- Ahmad Fatoum
- Copyright
- (c) 2015 Ahmad Fatoum. Code available under terms of the GNU General Public License 3.0
Definition in file bt-win.c.
void bt_close |
( |
void * |
handle | ) |
|
calls CloseHandle on argument
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 69 of file bt-win.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
Definition at line 79 of file bt-win.c.
void* bt_open |
( |
const char * |
device, |
|
|
const char * |
unused |
|
) |
| |
opens COM Porte described by device. NULL
leads to default action
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 21 of file bt-win.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 | is ignored |
- Returns
- status -1 on error. bytes read otherwise.
- Bug:
- milliseconds is ignored
Definition at line 56 of file bt-win.c.
int bt_write |
( |
void * |
handle, |
|
|
const u8 * |
buf, |
|
|
size_t |
count |
|
) |
| |
writes buf[1] till buf[count - 2] to device
- 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 36 of file bt-win.c.