From 3b811552aa19f9f929565f8cec9bb3e233162362 Mon Sep 17 00:00:00 2001 From: Claudiu Olteanu Date: Tue, 18 Aug 2015 21:38:47 +0300 Subject: [PATCH] Add implementation for BTH custom serial write method used on Windows Implement the write method used for our custom serial implementation on Windows platforms. Signed-off-by: Claudiu Olteanu Signed-off-by: Dirk Hohndel --- qtserialbluetooth.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/qtserialbluetooth.cpp b/qtserialbluetooth.cpp index 9d1c14b74..45fc8d1ec 100644 --- a/qtserialbluetooth.cpp +++ b/qtserialbluetooth.cpp @@ -263,9 +263,20 @@ static int qt_serial_write(serial_t *device, const void* data, unsigned int size if (device == NULL) return DC_STATUS_INVALIDARGS; - // TODO write *size* bytes from data to the device + unsigned int nbytes = 0; + int rc; - return 0; + while (nbytes < size) { + rc = send(device->socket, (char *) data + nbytes, size - nbytes, 0); + + if (rc < 0) { + return -1; // Error during send call. + } + + nbytes += rc; + } + + return nbytes; #else if (device == NULL || device->socket == NULL) return DC_STATUS_INVALIDARGS;