Fix Device Name Characteristic

"Name" key value defined in the main.conf file can not be used without
substitution(hostname and adapter id). This patch adds Device Name
Characteristic with length 0 and updates the value when the adapter is
initialized.

Multiple adapters with different settings is not supported at the moment
by the attribute server. GAP characteristics values will be overwritten
if the host has multiple adapters.
diff --git a/src/adapter.c b/src/adapter.c
index 2a19ace..dbae219 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2658,6 +2658,10 @@
 		expand_name(adapter->dev.name, MAX_NAME_LENGTH, main_opts.name,
 							adapter->dev_id);
 
+	if (main_opts.attrib_server)
+		attrib_gap_set(GATT_CHARAC_DEVICE_NAME,
+			(const uint8_t *) dev->name, strlen(dev->name));
+
 	sdp_init_services_list(&adapter->bdaddr);
 	load_drivers(adapter);
 	clear_blocked(adapter);
diff --git a/src/attrib-server.c b/src/attrib-server.c
index c1ca5ba..5e00601 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -802,7 +802,6 @@
 {
 	uint8_t atval[256];
 	uuid_t uuid;
-	int len;
 	uint16_t appearance = 0x0000;
 
 	/* GAP service: primary service definition */
@@ -820,9 +819,8 @@
 
 	/* GAP service: device name attribute */
 	sdp_uuid16_create(&uuid, GATT_CHARAC_DEVICE_NAME);
-	len = strlen(main_opts.name);
 	attrib_db_add(name_handle, &uuid, ATT_NONE, ATT_NOT_PERMITTED,
-					(uint8_t *) main_opts.name, len);
+								NULL, 0);
 
 	/* GAP service: device appearance characteristic */
 	appearance_handle = 0x0008;