From 23e46d2de44a3d49063e852a38b020e7407a78bc Mon Sep 17 00:00:00 2001 From: Paul Nettle Date: Sun, 3 Sep 2017 08:15:12 -0500 Subject: The GGK server names are no longer in Globals.h but are now configured by ggkStart() allowing an application to change them based on configuration rather than compilation. Power-off-disconnect errors hacked out of existence. A few log lines that were set to trace converted to debug log levels to reduce logspam. --- src/Server.cpp | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) (limited to 'src/Server.cpp') diff --git a/src/Server.cpp b/src/Server.cpp index a369b32..87b3279 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -62,8 +62,6 @@ // used to generate both: (1) the D-Bus object hierarchy and (2) the BlueZ services that occupy that hierarchy. In addition, we'll // take that a step further by including the implementation right inside the description. Everything in one place. // -// Well, almost one place (hint: Take a quick look at Globals.h - that's where your server name is.) -// // >> // >>> MANAGING SERVER DATA // >> @@ -160,6 +158,8 @@ // https://www.freedesktop.org/software/gstreamer-sdk/data/docs/latest/glib/glib-GVariantType.html // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +#include + #include "Server.h" #include "ServerUtils.h" #include "Utils.h" @@ -171,6 +171,7 @@ #include "GattUuid.h" #include "GattCharacteristic.h" #include "GattDescriptor.h" +#include "Logger.h" namespace ggk { @@ -195,11 +196,45 @@ std::shared_ptr TheServer = nullptr; // Object implementation // --------------------------------------------------------------------------------------------------------------------------------- -// Create (and completely describe) a server +// Our constructor builds our entire server description +// +// serviceName: The name of our server (collectino of services) +// +// This is used to build the path for our Bluetooth services. It also provides the base for the D-Bus owned name (see +// getOwnedName.) +// +// This value will be stored as lower-case only. +// +// Retrieve this value using the `getName()` method. +// +// advertisingName: The name for this controller, as advertised over LE // -// For details, head up to the top of this file. -Server::Server(GGKServerDataGetter getter, GGKServerDataSetter setter) +// IMPORTANT: Setting the advertisingName will change the system-wide name of the device. If that's not what you want, set +// BOTH advertisingName and advertisingShortName to as empty string ("") to prevent setting the advertising +// name. +// +// Retrieve this value using the `getAdvertisingName()` method. +// +// advertisingShortName: The short name for this controller, as advertised over LE +// +// According to the spec, the short name is used in case the full name doesn't fit within Extended Inquiry Response (EIR) or +// Advertising Data (AD). +// +// IMPORTANT: Setting the advertisingName will change the system-wide name of the device. If that's not what you want, set +// BOTH advertisingName and advertisingShortName to as empty string ("") to prevent setting the advertising +// name. +// +// Retrieve this value using the `getAdvertisingShortName()` method. +// +Server::Server(const std::string &serviceName, const std::string &advertisingName, const std::string &advertisingShortName, + GGKServerDataGetter getter, GGKServerDataSetter setter) { + // Save our names + this->serviceName = serviceName; + std::transform(this->serviceName.begin(), this->serviceName.end(), this->serviceName.begin(), ::tolower); + this->advertisingName = advertisingName; + this->advertisingShortName = advertisingShortName; + // Register getter & setter for server data dataGetter = getter; dataSetter = setter; @@ -216,7 +251,7 @@ Server::Server(GGKServerDataGetter getter, GGKServerDataSetter setter) // // Create the root D-Bus object and push it into the list - objects.push_back(DBusObject(DBusObjectPath() + "com" + kServerName)); + objects.push_back(DBusObject(DBusObjectPath() + "com" + getServiceName())); // We're going to build off of this object, so we need to get a reference to the instance of the object as it resides in the // list (and not the object that would be added to the list.) -- cgit v1.2.3