Merge PR #48: Add option to enfoce the full name instead of adding the Service UUID

This commit is contained in:
Jenkins nymea 2021-04-16 23:38:02 +02:00
commit c4e1e36e48
5 changed files with 31 additions and 13 deletions

View File

@ -92,10 +92,17 @@ this repository and it will be installed to /etc/nymea-networkmanager.conf with
-h, --help Displays this help.
-v, --version Displays version information.
-d, --debug Enable more debug output.
-a, --advertise-name <NAME> The name of the bluetooth server. Default "BT
WLAN setup".
-a, --advertise-name <NAME> The name of the bluetooth server. Default
"BT-WiFi". NOTE: The length is limited to 8
characters.
-f, --force-name Enforce the full name to be used even if it is
longer than 8 characters. IMPORTANT: This will
displace the Service UUID in the discovery data
which implies that client applications cannot
discover the wifi setup service on this device
any more.
-p, --platform-name <NAME> The name of the platform this daemon is running.
Default "nymea-box".
Default "nymea".
-g, --gpio <GPIO> The GPIO sysfs number for the button GPIO. This
parameter is only needed for the "button" mode.
-t, --timeout <SECONDS> The timeout of the bluetooth server. Minimum
@ -104,8 +111,7 @@ this repository and it will be installed to /etc/nymea-networkmanager.conf with
once, always, button, start). Default is
"offline".
-b, --dbus-type <DBUSTYPE> If given, a DBus interface will be exposed on
the chosen DBus bus type (session, system)
the chosen DBus bus type (session, system)
# Bluetooth GATT profile

2
debian/control vendored
View File

@ -10,7 +10,7 @@ Build-Depends: debhelper (>= 9.0.0),
qtbase5-dev-tools,
libqt5bluetooth5,
qtconnectivity5-dev,
libnymea-networkmanager-dev (>= 0.4.0),
libnymea-networkmanager-dev (>= 0.5.0),
libnymea-gpio-dev
Standards-Version: 3.9.7

View File

@ -65,9 +65,10 @@ QString Core::advertiseName() const
return m_advertiseName;
}
void Core::setAdvertiseName(const QString &name)
void Core::setAdvertiseName(const QString &name, bool forceFullName)
{
m_advertiseName = name;
m_forceFullName = forceFullName;
}
QString Core::platformName() const
@ -207,7 +208,7 @@ void Core::startService()
m_nymeaService->enableBluetooth(false);
// Start the bluetooth server for this wireless device
m_bluetoothServer->setAdvertiseName(m_advertiseName);
m_bluetoothServer->setAdvertiseName(m_advertiseName, m_forceFullName);
m_bluetoothServer->setModelName(m_platformName);
m_bluetoothServer->setSoftwareVersion(VERSION_STRING);
m_bluetoothServer->start();

View File

@ -65,7 +65,7 @@ public:
void setMode(Mode mode);
QString advertiseName() const;
void setAdvertiseName(const QString &name);
void setAdvertiseName(const QString &name, bool forceFullName = false);
QString platformName() const;
void setPlatformName(const QString &name);
@ -89,6 +89,7 @@ private:
Mode m_mode = ModeOffline;
QString m_advertiseName;
bool m_forceFullName = false;
QString m_platformName;
int m_advertisingTimeout = 60;

View File

@ -93,8 +93,9 @@ int main(int argc, char *argv[])
Core::Mode mode = Core::ModeOffline;
int timeout = 60;
int buttonGpio = -1;
QString advertiseName = "BT WLAN setup";
QString platformName = "nymea-box";
QString advertiseName = "BT-WiFi";
bool forceFullName = false;
QString platformName = "nymea";
QString dbusBusType;
Application application(argc, argv);
@ -121,10 +122,13 @@ int main(int argc, char *argv[])
QCommandLineOption debugOption(QStringList() << "d" << "debug", "Enable more debug output.");
parser.addOption(debugOption);
QCommandLineOption advertiseNameOption(QStringList() << "a" << "advertise-name", QString("The name of the bluetooth server. Default \"%1\".").arg(advertiseName), "NAME");
QCommandLineOption advertiseNameOption(QStringList() << "a" << "advertise-name", QString("The name of the bluetooth server. Default \"%1\". NOTE: The length is limited to 8 characters.").arg(advertiseName), "NAME");
advertiseNameOption.setDefaultValue(advertiseName);
parser.addOption(advertiseNameOption);
QCommandLineOption forceFullNameOption(QStringList() << "f" << "force-name", QString("Enforce the full name to be used even if it is longer than 8 characters. IMPORTANT: This will displace the Service UUID in the discovery data which implies that client applications cannot discover the wifi setup service on this device any more."));
parser.addOption(forceFullNameOption);
QCommandLineOption platformNameOption(QStringList() << "p" << "platform-name", QString("The name of the platform this daemon is running. Default \"%1\".").arg(platformName), "NAME");
platformNameOption.setDefaultValue(platformName);
parser.addOption(platformNameOption);
@ -191,6 +195,9 @@ int main(int argc, char *argv[])
if (settings.contains("AdvertiseName")) {
advertiseName = settings.value("AdvertiseName").toString();
}
if (settings.contains("ForceFullName")) {
forceFullName = settings.value("ForceFullName").toBool();
}
if (settings.contains("PlatformName")) {
platformName = settings.value("PlatformName").toString();
}
@ -222,6 +229,9 @@ int main(int argc, char *argv[])
if (parser.isSet(advertiseNameOption)) {
advertiseName = parser.value(advertiseNameOption);
}
if (parser.isSet(forceFullNameOption)) {
forceFullName = true;
}
if (parser.isSet(platformNameOption)) {
platformName = parser.value(platformNameOption);
}
@ -274,7 +284,7 @@ int main(int argc, char *argv[])
Core core(&application);
core.setMode(mode);
core.setAdvertisingTimeout(timeout);
core.setAdvertiseName(advertiseName);
core.setAdvertiseName(advertiseName, forceFullName);
core.setPlatformName(platformName);
core.addGPioButton(buttonGpio);
if (dbusBusType == "system") {