diff --git a/platform/corefoundation/btstack_run_loop_corefoundation.m b/platform/corefoundation/btstack_run_loop_corefoundation.m
index 0ead846a1..6c8b10821 100644
--- a/platform/corefoundation/btstack_run_loop_corefoundation.m
+++ b/platform/corefoundation/btstack_run_loop_corefoundation.m
@@ -75,11 +75,11 @@ static void socketDataCallback (
btstack_data_source_t * ds = (btstack_data_source_t *) info;
if ((callbackType == kCFSocketReadCallBack) && (ds->flags & DATA_SOURCE_CALLBACK_READ)){
- // printf("btstack_run_loop_corefoundation_ds %x - fd %u, CFSocket %x, CFRunLoopSource %x\n", (int) ds, ds->fd, (int) s, (int) ds->item.next);
+ // printf("btstack_run_loop_corefoundation_ds %x - fd %u, CFSocket %x, CFRunLoopSource %x\n", (int) ds, ds->source.fd, (int) s, (int) ds->item.next);
ds->process(ds, DATA_SOURCE_CALLBACK_READ);
}
if ((callbackType == kCFSocketWriteCallBack) && (ds->flags & DATA_SOURCE_CALLBACK_WRITE)){
- // printf("btstack_run_loop_corefoundation_ds %x - fd %u, CFSocket %x, CFRunLoopSource %x\n", (int) ds, ds->fd, (int) s, (int) ds->item.next);
+ // printf("btstack_run_loop_corefoundation_ds %x - fd %u, CFSocket %x, CFRunLoopSource %x\n", (int) ds, ds->source.fd, (int) s, (int) ds->item.next);
ds->process(ds, DATA_SOURCE_CALLBACK_WRITE);
}
}
@@ -115,7 +115,7 @@ static void btstack_run_loop_corefoundation_add_data_source(btstack_data_source_
uint16_t callback_types = btstack_run_loop_corefoundation_option_flags_for_callback_types(data_source->flags);
CFSocketRef socket = CFSocketCreateWithNative (
kCFAllocatorDefault,
- data_source->fd,
+ data_source->source.fd,
callback_types,
socketDataCallback,
&socketContext
@@ -139,7 +139,7 @@ static void btstack_run_loop_corefoundation_add_data_source(btstack_data_source_
// add to run loop
CFRunLoopAddSource( CFRunLoopGetCurrent(), socket_run_loop, kCFRunLoopCommonModes);
- // printf("btstack_run_loop_corefoundation_add_data_source %x - fd %u - CFSocket %x, CFRunLoopSource %x\n", (int) dataSource, dataSource->fd, (int) socket, (int) socket_run_loop);
+ // printf("btstack_run_loop_corefoundation_add_data_source %x - fd %u - CFSocket %x, CFRunLoopSource %x\n", (int) dataSource, dataSource->source.fd, (int) socket, (int) socket_run_loop);
}
@@ -157,7 +157,7 @@ static void btstack_run_loop_embedded_disable_data_source_callbacks(btstack_data
static int btstack_run_loop_corefoundation_remove_data_source(btstack_data_source_t *ds){
btstack_corefoundation_data_source_helper_t * references = (btstack_corefoundation_data_source_helper_t *) ds->item.next;
- // printf("btstack_run_loop_corefoundation_remove_data_source %x - fd %u, CFSocket %x, CFRunLoopSource %x\n", (int) dataSource, dataSource->fd, (int) dataSource->item.next, (int) dataSource->item.user_data);
+ // printf("btstack_run_loop_corefoundation_remove_data_source %x - fd %u, CFSocket %x, CFRunLoopSource %x\n", (int) dataSource, dataSource->source.fd, (int) dataSource->item.next, (int) dataSource->item.user_data);
CFRunLoopRemoveSource( CFRunLoopGetCurrent(), references->socket_run_loop, kCFRunLoopCommonModes);
CFRelease(references->socket_run_loop);
diff --git a/platform/daemon/binding/java/build.xml b/platform/daemon/binding/java/build.xml
index 1db5fae3a..cbdee87fd 100644
--- a/platform/daemon/binding/java/build.xml
+++ b/platform/daemon/binding/java/build.xml
@@ -22,7 +22,8 @@
-
+
@@ -42,6 +43,7 @@
+
@@ -50,4 +52,4 @@
-
\ No newline at end of file
+
diff --git a/platform/daemon/binding/java/src/com/bluekitchen/btstack/BTstackClient.java b/platform/daemon/binding/java/src/com/bluekitchen/btstack/BTstackClient.java
index e1ed13fec..bc501da78 100644
--- a/platform/daemon/binding/java/src/com/bluekitchen/btstack/BTstackClient.java
+++ b/platform/daemon/binding/java/src/com/bluekitchen/btstack/BTstackClient.java
@@ -155,4 +155,4 @@ public class BTstackClient {
// done
socketConnection = null;
}
-}
\ No newline at end of file
+}
diff --git a/platform/daemon/src/socket_connection.c b/platform/daemon/src/socket_connection.c
index 58e5255fd..e9149d1f0 100644
--- a/platform/daemon/src/socket_connection.c
+++ b/platform/daemon/src/socket_connection.c
@@ -515,8 +515,8 @@ void socket_connection_send_packet(connection_t *conn, uint16_t type, uint16_t c
little_endian_store_16(header, 0, type);
little_endian_store_16(header, 2, channel);
little_endian_store_16(header, 4, size);
- write(conn->ds.fd, header, 6);
- write(conn->ds.fd, packet, size);
+ write(conn->ds.source.fd, header, 6);
+ write(conn->ds.source.fd, packet, size);
}
/**
@@ -568,9 +568,9 @@ connection_t * socket_connection_open_tcp(const char *address, uint16_t port){
int socket_connection_close_tcp(connection_t * connection){
if (!connection) return -1;
#ifdef _WIN32
- shutdown(connection->ds.fd, SD_BOTH);
+ shutdown(connection->ds.source.fd, SD_BOTH);
#else
- shutdown(connection->ds.fd, SHUT_RDWR);
+ shutdown(connection->ds.source.fd, SHUT_RDWR);
#endif
socket_connection_free_connection(connection);
return 0;
@@ -605,9 +605,9 @@ connection_t * socket_connection_open_unix(void){
int socket_connection_close_unix(connection_t * connection){
if (!connection) return -1;
#ifdef _WIN32
- shutdown(connection->ds.fd, SD_BOTH);
+ shutdown(connection->ds.source.fd, SD_BOTH);
#else
- shutdown(connection->ds.fd, SHUT_RDWR);
+ shutdown(connection->ds.source.fd, SHUT_RDWR);
#endif
socket_connection_free_connection(connection);
return 0;
diff --git a/platform/posix/btstack_network_posix.c b/platform/posix/btstack_network_posix.c
index 085015869..948d6d155 100644
--- a/platform/posix/btstack_network_posix.c
+++ b/platform/posix/btstack_network_posix.c
@@ -120,7 +120,7 @@ static void process_tap_dev_data(btstack_data_source_t *ds, btstack_data_source_
UNUSED(callback_type);
ssize_t len;
- len = read(ds->fd, network_buffer, sizeof(network_buffer));
+ len = read(ds->source.fd, network_buffer, sizeof(network_buffer));
if (len <= 0){
fprintf(stderr, "TAP: Error while reading: %s\n", strerror(errno));
return;
diff --git a/platform/posix/btstack_run_loop_posix.c b/platform/posix/btstack_run_loop_posix.c
index fcd6d3723..56ac91ba4 100644
--- a/platform/posix/btstack_run_loop_posix.c
+++ b/platform/posix/btstack_run_loop_posix.c
@@ -72,7 +72,7 @@ static struct timeval init_tv;
*/
static void btstack_run_loop_posix_add_data_source(btstack_data_source_t *ds){
data_sources_modified = 1;
- // log_info("btstack_run_loop_posix_add_data_source %x with fd %u\n", (int) ds, ds->fd);
+ // log_info("btstack_run_loop_posix_add_data_source %x with fd %u\n", (int) ds, ds->source.fd);
btstack_linked_list_add(&data_sources, (btstack_linked_item_t *) ds);
}
@@ -164,20 +164,20 @@ static void btstack_run_loop_posix_execute(void) {
btstack_linked_list_iterator_init(&it, &data_sources);
while (btstack_linked_list_iterator_has_next(&it)){
btstack_data_source_t *ds = (btstack_data_source_t*) btstack_linked_list_iterator_next(&it);
- if (ds->fd < 0) continue;
+ if (ds->source.fd < 0) continue;
if (ds->flags & DATA_SOURCE_CALLBACK_READ){
- FD_SET(ds->fd, &descriptors_read);
- if (ds->fd > highest_fd) {
- highest_fd = ds->fd;
+ FD_SET(ds->source.fd, &descriptors_read);
+ if (ds->source.fd > highest_fd) {
+ highest_fd = ds->source.fd;
}
- log_debug("btstack_run_loop_execute adding fd %u for read", ds->fd);
+ log_debug("btstack_run_loop_execute adding fd %u for read", ds->source.fd);
}
if (ds->flags & DATA_SOURCE_CALLBACK_WRITE){
- FD_SET(ds->fd, &descriptors_write);
- if (ds->fd > highest_fd) {
- highest_fd = ds->fd;
+ FD_SET(ds->source.fd, &descriptors_write);
+ if (ds->source.fd > highest_fd) {
+ highest_fd = ds->source.fd;
}
- log_debug("btstack_run_loop_execute adding fd %u for write", ds->fd);
+ log_debug("btstack_run_loop_execute adding fd %u for write", ds->source.fd);
}
}
@@ -204,14 +204,14 @@ static void btstack_run_loop_posix_execute(void) {
btstack_linked_list_iterator_init(&it, &data_sources);
while (btstack_linked_list_iterator_has_next(&it) && !data_sources_modified){
btstack_data_source_t *ds = (btstack_data_source_t*) btstack_linked_list_iterator_next(&it);
- log_debug("btstack_run_loop_posix_execute: check ds %p with fd %u\n", ds, ds->fd);
- if (FD_ISSET(ds->fd, &descriptors_read)) {
- log_debug("btstack_run_loop_posix_execute: process read ds %p with fd %u\n", ds, ds->fd);
+ log_debug("btstack_run_loop_posix_execute: check ds %p with fd %u\n", ds, ds->source.fd);
+ if (FD_ISSET(ds->source.fd, &descriptors_read)) {
+ log_debug("btstack_run_loop_posix_execute: process read ds %p with fd %u\n", ds, ds->source.fd);
ds->process(ds, DATA_SOURCE_CALLBACK_READ);
}
if (data_sources_modified) break;
- if (FD_ISSET(ds->fd, &descriptors_write)) {
- log_debug("btstack_run_loop_posix_execute: process write ds %p with fd %u\n", ds, ds->fd);
+ if (FD_ISSET(ds->source.fd, &descriptors_write)) {
+ log_debug("btstack_run_loop_posix_execute: process write ds %p with fd %u\n", ds, ds->source.fd);
ds->process(ds, DATA_SOURCE_CALLBACK_WRITE);
}
}
diff --git a/platform/posix/btstack_stdin_posix.c b/platform/posix/btstack_stdin_posix.c
index 26d937f63..035dc325a 100644
--- a/platform/posix/btstack_stdin_posix.c
+++ b/platform/posix/btstack_stdin_posix.c
@@ -58,7 +58,7 @@ static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callbac
UNUSED(callback_type);
char data;
- read(stdin_source.fd, &data, 1);
+ read(stdin_source.source.fd, &data, 1);
if (stdin_handler){
(*stdin_handler)(data);
}
diff --git a/platform/posix/btstack_uart_block_posix.c b/platform/posix/btstack_uart_block_posix.c
index cf4626b5e..be619a4e8 100644
--- a/platform/posix/btstack_uart_block_posix.c
+++ b/platform/posix/btstack_uart_block_posix.c
@@ -89,7 +89,7 @@ static void btstack_uart_posix_process_write(btstack_data_source_t *ds) {
uint32_t start = btstack_run_loop_get_time_ms();
// write up to write_bytes_len to fd
- int bytes_written = (int) write(ds->fd, write_bytes_data, write_bytes_len);
+ int bytes_written = (int) write(ds->source.fd, write_bytes_data, write_bytes_len);
uint32_t end = btstack_run_loop_get_time_ms();
if (end - start > 10){
log_info("write took %u ms", end - start);
@@ -130,7 +130,7 @@ static void btstack_uart_posix_process_read(btstack_data_source_t *ds) {
uint32_t start = btstack_run_loop_get_time_ms();
// read up to bytes_to_read data in
- ssize_t bytes_read = read(ds->fd, read_bytes_data, read_bytes_len);
+ ssize_t bytes_read = read(ds->source.fd, read_bytes_data, read_bytes_len);
// log_info("btstack_uart_posix_process_read need %u bytes, got %d", read_bytes_len, (int) bytes_read);
uint32_t end = btstack_run_loop_get_time_ms();
if (end - start > 10){
@@ -157,7 +157,7 @@ static void btstack_uart_posix_process_read(btstack_data_source_t *ds) {
}
static void hci_uart_posix_process(btstack_data_source_t *ds, btstack_data_source_callback_type_t callback_type) {
- if (ds->fd < 0) return;
+ if (ds->source.fd < 0) return;
switch (callback_type){
case DATA_SOURCE_CALLBACK_READ:
btstack_uart_posix_process_read(ds);
@@ -172,7 +172,7 @@ static void hci_uart_posix_process(btstack_data_source_t *ds, btstack_data_sourc
static int btstack_uart_posix_set_baudrate(uint32_t baudrate){
- int fd = transport_data_source.fd;
+ int fd = transport_data_source.source.fd;
log_info("h4_set_baudrate %u", baudrate);
@@ -269,7 +269,7 @@ static void btstack_uart_posix_set_flowcontrol_option(struct termios * toptions,
}
static int btstack_uart_posix_set_parity(int parity){
- int fd = transport_data_source.fd;
+ int fd = transport_data_source.source.fd;
struct termios toptions;
if (tcgetattr(fd, &toptions) < 0) {
log_error("btstack_uart_posix_set_parity: Couldn't get term attributes");
@@ -285,7 +285,7 @@ static int btstack_uart_posix_set_parity(int parity){
static int btstack_uart_posix_set_flowcontrol(int flowcontrol){
- int fd = transport_data_source.fd;
+ int fd = transport_data_source.source.fd;
struct termios toptions;
if (tcgetattr(fd, &toptions) < 0) {
log_error("btstack_uart_posix_set_parity: Couldn't get term attributes");
@@ -343,7 +343,7 @@ static int btstack_uart_posix_open(void){
}
// store fd in data source
- transport_data_source.fd = fd;
+ transport_data_source.source.fd = fd;
// also set baudrate
if (btstack_uart_posix_set_baudrate(baudrate) < 0){
@@ -367,8 +367,8 @@ static int btstack_uart_posix_close_new(void){
btstack_run_loop_remove_data_source(&transport_data_source);
// then close device
- close(transport_data_source.fd);
- transport_data_source.fd = -1;
+ close(transport_data_source.source.fd);
+ transport_data_source.source.fd = -1;
return 0;
}
diff --git a/platform/windows/btstack_run_loop_windows.c b/platform/windows/btstack_run_loop_windows.c
index f9ef2c956..10a3f9164 100644
--- a/platform/windows/btstack_run_loop_windows.c
+++ b/platform/windows/btstack_run_loop_windows.c
@@ -159,10 +159,10 @@ static void btstack_run_loop_windows_execute(void) {
btstack_linked_list_iterator_init(&it, &data_sources);
while (btstack_linked_list_iterator_has_next(&it)){
btstack_data_source_t *ds = (btstack_data_source_t*) btstack_linked_list_iterator_next(&it);
- if (ds->handle == 0) continue;
+ if (ds->source.handle == 0) continue;
if (ds->flags & (DATA_SOURCE_CALLBACK_READ | DATA_SOURCE_CALLBACK_WRITE)){
- handles[num_handles++] = ds->handle;
- log_debug("btstack_run_loop_execute adding handle %p", ds->handle);
+ handles[num_handles++] = ds->source.handle;
+ log_debug("btstack_run_loop_execute adding handle %p", ds->source.handle);
}
}
@@ -194,13 +194,13 @@ static void btstack_run_loop_windows_execute(void) {
btstack_linked_list_iterator_init(&it, &data_sources);
while (btstack_linked_list_iterator_has_next(&it)){
btstack_data_source_t *ds = (btstack_data_source_t*) btstack_linked_list_iterator_next(&it);
- log_debug("btstack_run_loop_windows_execute: check ds %p with handle %p\n", ds, ds->handle);
- if (triggered_handle == ds->handle){
+ log_debug("btstack_run_loop_windows_execute: check ds %p with handle %p\n", ds, ds->source.handle);
+ if (triggered_handle == ds->source.handle){
if (ds->flags & DATA_SOURCE_CALLBACK_READ){
- log_debug("btstack_run_loop_windows_execute: process read ds %p with handle %p\n", ds, ds->handle);
+ log_debug("btstack_run_loop_windows_execute: process read ds %p with handle %p\n", ds, ds->source.handle);
ds->process(ds, DATA_SOURCE_CALLBACK_READ);
} else if (ds->flags & DATA_SOURCE_CALLBACK_WRITE){
- log_debug("btstack_run_loop_windows_execute: process write ds %p with handle %p\n", ds, ds->handle);
+ log_debug("btstack_run_loop_windows_execute: process write ds %p with handle %p\n", ds, ds->source.handle);
ds->process(ds, DATA_SOURCE_CALLBACK_WRITE);
}
break;
diff --git a/platform/windows/btstack_stdin_windows.c b/platform/windows/btstack_stdin_windows.c
index ed5fea16d..c8ea61e1f 100644
--- a/platform/windows/btstack_stdin_windows.c
+++ b/platform/windows/btstack_stdin_windows.c
@@ -66,7 +66,7 @@ static void (*stdin_handler)(char c);
static WINAPI DWORD stdin_reader_thread_process(void * p){
while (1){
key_read_buffer = getch();
- SignalObjectAndWait(stdin_source.handle, key_processed_handle, INFINITE, FALSE);
+ SignalObjectAndWait(stdin_source.source.handle, key_processed_handle, INFINITE, FALSE);
}
return 0;
}
@@ -96,7 +96,7 @@ void btstack_stdin_setup(void (*handler)(char c)){
// asynchronous io on stdin via OVERLAPPED seems to be problematic.
// Use separate thread and event objects instead
- stdin_source.handle = CreateEvent(NULL, FALSE, FALSE, NULL);
+ stdin_source.source.handle = CreateEvent(NULL, FALSE, FALSE, NULL);
key_processed_handle = CreateEvent(NULL, FALSE, FALSE, NULL);
// default attributes, default stack size, proc, args, start immediately, don't care for thread id
stdin_reader_thread_handle = CreateThread(NULL, 0, &stdin_reader_thread_process, NULL, 0, NULL);
@@ -121,7 +121,7 @@ void btstack_stdin_reset(void){
CloseHandle(stdin_reader_thread_handle);
// free events
- CloseHandle(stdin_source.handle);
+ CloseHandle(stdin_source.source.handle);
CloseHandle(key_processed_handle);
}
diff --git a/platform/windows/btstack_uart_block_windows.c b/platform/windows/btstack_uart_block_windows.c
index 2909dabad..787683c24 100644
--- a/platform/windows/btstack_uart_block_windows.c
+++ b/platform/windows/btstack_uart_block_windows.c
@@ -401,8 +401,8 @@ static int btstack_uart_windows_open(void){
overlapped_write.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
// setup read + write data sources
- transport_data_source_read.handle = overlapped_read.hEvent;
- transport_data_source_write.handle = overlapped_write.hEvent;
+ transport_data_source_read.source.handle = overlapped_read.hEvent;
+ transport_data_source_write.source.handle = overlapped_write.hEvent;
btstack_run_loop_set_data_source_handler(&transport_data_source_read, &btstack_uart_windows_process_read);
btstack_run_loop_set_data_source_handler(&transport_data_source_write, &btstack_uart_windows_process_write);
btstack_run_loop_add_data_source(&transport_data_source_read);
diff --git a/src/btstack_run_loop.c b/src/btstack_run_loop.c
index ffc41e8a8..65868f985 100644
--- a/src/btstack_run_loop.c
+++ b/src/btstack_run_loop.c
@@ -74,19 +74,19 @@ void btstack_run_loop_set_data_source_handler(btstack_data_source_t *ds, void (*
};
void btstack_run_loop_set_data_source_fd(btstack_data_source_t *ds, int fd){
- ds->fd = fd;
+ ds->source.fd = fd;
}
int btstack_run_loop_get_data_source_fd(btstack_data_source_t *ds){
- return ds->fd;
+ return ds->source.fd;
}
void btstack_run_loop_set_data_source_handle(btstack_data_source_t *ds, void * handle){
- ds->handle = handle;
+ ds->source.handle = handle;
}
void * btstack_run_loop_get_data_source_handle(btstack_data_source_t *ds){
- return ds->handle;
+ return ds->source.handle;
}
void btstack_run_loop_enable_data_source_callbacks(btstack_data_source_t *ds, uint16_t callbacks){
diff --git a/src/btstack_run_loop.h b/src/btstack_run_loop.h
index b92f711e5..f9477bf67 100644
--- a/src/btstack_run_loop.h
+++ b/src/btstack_run_loop.h
@@ -74,7 +74,7 @@ typedef struct btstack_data_source {
int fd;
// handle on windows
void * handle;
- };
+ } source;
// callback to call for enabled callback types
void (*process)(struct btstack_data_source *ds, btstack_data_source_callback_type_t callback_type);