From 315b1d08d278517bf90a65a2bb340fe7f8eeb747 Mon Sep 17 00:00:00 2001 From: ElectricBlue Date: Sat, 30 Jan 2016 23:56:40 +0300 Subject: Trailing zeroes removed from device names. --- nimbluez/bluetoothbluez.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nimbluez/bluetoothbluez.nim b/nimbluez/bluetoothbluez.nim index 59dbb08..c11107d 100644 --- a/nimbluez/bluetoothbluez.nim +++ b/nimbluez/bluetoothbluez.nim @@ -7,6 +7,7 @@ ## Linux. import os +from strutils import strip import bluez/bz_bluetooth, bluez/bz_hci, bluez/bz_hci_lib export bdaddr_t, inquiry_info @@ -133,6 +134,7 @@ proc name*(device: BluetoothDeviceLocal): string = result.setLen(BLUETOOTH_MAX_NAME_SIZE) if hci_read_local_name(socket, cint(len(result)), result, 0) < 0: raiseOSError(osLastError()) + result = result.strip(false, true, {'\0'}) finally: if hci_close_dev(socket) < 0: raiseOSError(osLastError()) @@ -155,6 +157,7 @@ proc name*(device: BluetoothDeviceRemote, if hci_read_remote_name(socket, addr(device.fInquiryInfo.bdaddr), cint(len(result)), result, 0) < 0: raiseOSError(osLastError()) + result = result.strip(false, true, {'\0'}) finally: if hci_close_dev(socket) < 0: raiseOSError(osLastError()) -- cgit v1.2.3