diff --git a/README.md b/README.md index c92335f..6b8da20 100644 --- a/README.md +++ b/README.md @@ -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 The name of the bluetooth server. Default "BT - WLAN setup". + -a, --advertise-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 The name of the platform this daemon is running. - Default "nymea-box". + Default "nymea". -g, --gpio The GPIO sysfs number for the button GPIO. This parameter is only needed for the "button" mode. -t, --timeout 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 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 diff --git a/debian/control b/debian/control index 2c04f0f..b9a6146 100644 --- a/debian/control +++ b/debian/control @@ -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 diff --git a/nymea-networkmanager/core.cpp b/nymea-networkmanager/core.cpp index d4b5d5d..7469557 100644 --- a/nymea-networkmanager/core.cpp +++ b/nymea-networkmanager/core.cpp @@ -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(); diff --git a/nymea-networkmanager/core.h b/nymea-networkmanager/core.h index 274a9c4..13a6929 100644 --- a/nymea-networkmanager/core.h +++ b/nymea-networkmanager/core.h @@ -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; diff --git a/nymea-networkmanager/main.cpp b/nymea-networkmanager/main.cpp index 9e68aaa..56babf8 100644 --- a/nymea-networkmanager/main.cpp +++ b/nymea-networkmanager/main.cpp @@ -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") {