Fix Bluetooth address truncation issues on Windows

On some Windows platforms when we convert a Bth address to a String
it is formatted as "(XX:XX:XX:XX:XX:XX)". Therefore we first try to
remove the round parentheses and finally we truncate the string
to 17 because there are 6 two-digit hex values and 5 colons.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Claudiu Olteanu 2015-09-19 19:14:51 +03:00 committed by Dirk Hohndel
parent 54f4ed70ce
commit 89540e0fb2
2 changed files with 5 additions and 4 deletions

View file

@ -609,14 +609,14 @@ void WinBluetoothDeviceDiscoveryAgent::run()
break;
}
// Save the name of the discovered device and truncate the address
QString deviceName = QString(pResults->lpszServiceInstanceName);
deviceAddress.truncate(addressSize / sizeof(wchar_t));
// Remove the round parentheses
deviceAddress.remove(')');
deviceAddress.remove('(');
// Save the name of the discovered device and truncate the address
QString deviceName = QString(pResults->lpszServiceInstanceName);
deviceAddress.truncate(BTH_ADDR_PRETTY_STRING_LEN);
// Create an object with information about the discovered device
QBluetoothDeviceInfo deviceInfo = QBluetoothDeviceInfo(QBluetoothAddress(deviceAddress), deviceName, 0);

View file

@ -15,6 +15,7 @@
#define SUCCESS 0
#define BTH_ADDR_STR_LEN 40
#define BTH_ADDR_PRETTY_STRING_LEN 17 // there are 6 two-digit hex values and 5 colons
#undef ERROR // this is already declared in our headers
#undef IGNORE // this is already declared in our headers