diff options
| author | ElectricBlue <ElectricBlue@i10y.com> | 2016-01-30 23:56:40 +0300 |
|---|---|---|
| committer | ElectricBlue <ElectricBlue@i10y.com> | 2016-01-30 23:56:40 +0300 |
| commit | 315b1d08d278517bf90a65a2bb340fe7f8eeb747 (patch) | |
| tree | ab0950db75130042f42ae1b93bdb479a774bc70d | |
| parent | 292c9e6e6e0351bfdb05f1fa74c163dd530ad27e (diff) | |
| download | NimBluez-315b1d08d278517bf90a65a2bb340fe7f8eeb747.tar.gz NimBluez-315b1d08d278517bf90a65a2bb340fe7f8eeb747.zip | |
Trailing zeroes removed from device names.
| -rw-r--r-- | nimbluez/bluetoothbluez.nim | 3 |
1 files changed, 3 insertions, 0 deletions
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()) |
