Add the wireless service UUID to the SDP record
This allows more reliable client side filtering, however comes with the downside of leaving only 8 characters of space for the device name.pull/15/head
parent
cd5bd22b23
commit
650bf5f1e4
|
|
@ -1,3 +1,8 @@
|
|||
libnymea-networkmanager (0.5.0) UNRELEASED; urgency=medium
|
||||
|
||||
|
||||
-- Michael Zanetti <michael.zanetti@nymea.io> Sat, 27 Mar 2021 00:32:57 +0100
|
||||
|
||||
libnymea-networkmanager (0.4.2) xenial; urgency=medium
|
||||
|
||||
[ Michael Zanetti ]
|
||||
|
|
|
|||
|
|
@ -39,9 +39,11 @@
|
|||
#include "bluetoothserver.h"
|
||||
#include "../networkmanager.h"
|
||||
#include "../networkmanagerutils.h"
|
||||
#include "bluetoothuuids.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QSysInfo>
|
||||
#include <QBluetoothUuid>
|
||||
|
||||
BluetoothServer::BluetoothServer(NetworkManager *networkManager) :
|
||||
QObject(networkManager),
|
||||
|
|
@ -66,9 +68,10 @@ QString BluetoothServer::advertiseName() const
|
|||
return m_advertiseName;
|
||||
}
|
||||
|
||||
void BluetoothServer::setAdvertiseName(const QString &advertiseName)
|
||||
void BluetoothServer::setAdvertiseName(const QString &advertiseName, bool forceFullName)
|
||||
{
|
||||
m_advertiseName = advertiseName;
|
||||
m_forceFullName = forceFullName;
|
||||
}
|
||||
|
||||
QString BluetoothServer::modelName() const
|
||||
|
|
@ -461,9 +464,22 @@ void BluetoothServer::start()
|
|||
|
||||
QLowEnergyAdvertisingData advertisingData;
|
||||
advertisingData.setDiscoverability(QLowEnergyAdvertisingData::DiscoverabilityGeneral);
|
||||
advertisingData.setIncludePowerLevel(true);
|
||||
advertisingData.setLocalName(m_advertiseName);
|
||||
// FIXME: set manufacturer SIG data once available
|
||||
// Setting the wireless service UUID to the advertise data.
|
||||
// Given that nymea-networkmanager doesn't have a registered service UUID (yet), we need
|
||||
// to write the full UUID which takes up most of the advertise data space. Because of
|
||||
// this, we can only fit 8 character device name and nothing else.
|
||||
// Registering a service UUID with the BT SIG would allow to use shortened uuids and leave
|
||||
// more space for device name, multiple uuids, or other info (in that case we'd likely also have manufacturer
|
||||
// data to add here).
|
||||
// Anyhow, for now, 8 characters device name it is with the single wireless service UUID.
|
||||
advertisingData.setServices({wirelessServiceUuid});
|
||||
|
||||
if (m_forceFullName || m_advertiseName.length() <= 8) {
|
||||
advertisingData.setLocalName(m_advertiseName);
|
||||
} else {
|
||||
qCWarning(dcNetworkManagerBluetoothServer()) << "Truncating local host name to" << m_advertiseName.left(8) << "(maximum length of 8 characters exceeded)";
|
||||
advertisingData.setLocalName(m_advertiseName.left(8));
|
||||
}
|
||||
|
||||
// Note: start advertising in 100 ms interval, this makes the device better discoverable on certain phones
|
||||
QLowEnergyAdvertisingParameters advertisingParameters;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public:
|
|||
~BluetoothServer();
|
||||
|
||||
QString advertiseName() const;
|
||||
void setAdvertiseName(const QString &advertiseName);
|
||||
void setAdvertiseName(const QString &advertiseName, bool forceFullName = false);
|
||||
|
||||
// Information for the device info service
|
||||
QString modelName() const;
|
||||
|
|
@ -80,6 +80,7 @@ public:
|
|||
|
||||
private:
|
||||
QString m_advertiseName;
|
||||
bool m_forceFullName = false;
|
||||
|
||||
QString m_modelName;
|
||||
QString m_softwareVersion;
|
||||
|
|
|
|||
Loading…
Reference in New Issue