Merge PR #15: Add the wireless service UUID to the SDP record

pull/16/head
Jenkins nymea 2021-04-16 23:37:54 +02:00
commit 8c43caf025
3 changed files with 27 additions and 5 deletions

5
debian/changelog vendored
View File

@ -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 libnymea-networkmanager (0.4.2) xenial; urgency=medium
[ Michael Zanetti ] [ Michael Zanetti ]

View File

@ -39,9 +39,11 @@
#include "bluetoothserver.h" #include "bluetoothserver.h"
#include "../networkmanager.h" #include "../networkmanager.h"
#include "../networkmanagerutils.h" #include "../networkmanagerutils.h"
#include "bluetoothuuids.h"
#include <QFile> #include <QFile>
#include <QSysInfo> #include <QSysInfo>
#include <QBluetoothUuid>
BluetoothServer::BluetoothServer(NetworkManager *networkManager) : BluetoothServer::BluetoothServer(NetworkManager *networkManager) :
QObject(networkManager), QObject(networkManager),
@ -66,9 +68,10 @@ QString BluetoothServer::advertiseName() const
return m_advertiseName; return m_advertiseName;
} }
void BluetoothServer::setAdvertiseName(const QString &advertiseName) void BluetoothServer::setAdvertiseName(const QString &advertiseName, bool forceFullName)
{ {
m_advertiseName = advertiseName; m_advertiseName = advertiseName;
m_forceFullName = forceFullName;
} }
QString BluetoothServer::modelName() const QString BluetoothServer::modelName() const
@ -461,9 +464,22 @@ void BluetoothServer::start()
QLowEnergyAdvertisingData advertisingData; QLowEnergyAdvertisingData advertisingData;
advertisingData.setDiscoverability(QLowEnergyAdvertisingData::DiscoverabilityGeneral); advertisingData.setDiscoverability(QLowEnergyAdvertisingData::DiscoverabilityGeneral);
advertisingData.setIncludePowerLevel(true); // 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); advertisingData.setLocalName(m_advertiseName);
// FIXME: set manufacturer SIG data once available } 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 // Note: start advertising in 100 ms interval, this makes the device better discoverable on certain phones
QLowEnergyAdvertisingParameters advertisingParameters; QLowEnergyAdvertisingParameters advertisingParameters;

View File

@ -60,7 +60,7 @@ public:
~BluetoothServer(); ~BluetoothServer();
QString advertiseName() const; QString advertiseName() const;
void setAdvertiseName(const QString &advertiseName); void setAdvertiseName(const QString &advertiseName, bool forceFullName = false);
// Information for the device info service // Information for the device info service
QString modelName() const; QString modelName() const;
@ -80,6 +80,7 @@ public:
private: private:
QString m_advertiseName; QString m_advertiseName;
bool m_forceFullName = false;
QString m_modelName; QString m_modelName;
QString m_softwareVersion; QString m_softwareVersion;