mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-25 05:04:18 +08:00
Add a way to store the remote device type
Because we need to know the device type (LE, Basic Rate or Dual Mode) to be able to fully restore the device from storage, we have to store and load this information to permanent storage. Note: due to "device_type_t" usage in storage.h, some header includes needed to be reordered in files which include storage.h.
This commit is contained in:
parent
5f44369b91
commit
50fb53c4a7
@ -46,11 +46,11 @@
|
||||
#include "textfile.h"
|
||||
#include "uinput.h"
|
||||
|
||||
#include "../src/storage.h"
|
||||
#include "../src/adapter.h"
|
||||
#include "../src/device.h"
|
||||
#include "../src/storage.h"
|
||||
#include "../src/manager.h"
|
||||
#include "../src/dbus-common.h"
|
||||
#include "../src/device.h"
|
||||
|
||||
#include "device.h"
|
||||
#include "error.h"
|
||||
|
@ -41,11 +41,11 @@
|
||||
#include "hcid.h"
|
||||
#include "sdpd.h"
|
||||
#include "adapter.h"
|
||||
#include "device.h"
|
||||
#include "plugin.h"
|
||||
#include "log.h"
|
||||
#include "storage.h"
|
||||
#include "event.h"
|
||||
#include "device.h"
|
||||
#include "manager.h"
|
||||
|
||||
static int child_pipe[2] = { -1, -1 };
|
||||
|
@ -53,6 +53,8 @@
|
||||
|
||||
#include "error.h"
|
||||
#include "manager.h"
|
||||
#include "adapter.h"
|
||||
#include "device.h"
|
||||
#include "storage.h"
|
||||
#include "port.h"
|
||||
|
||||
|
@ -45,6 +45,8 @@
|
||||
#include <bluetooth/sdp_lib.h>
|
||||
|
||||
#include "textfile.h"
|
||||
#include "adapter.h"
|
||||
#include "device.h"
|
||||
#include "glib-helper.h"
|
||||
#include "storage.h"
|
||||
|
||||
@ -1391,3 +1393,41 @@ int read_device_attributes(const bdaddr_t *sba, textfile_cb func, void *data)
|
||||
|
||||
return textfile_foreach(filename, func, data);
|
||||
}
|
||||
|
||||
int write_device_type(const bdaddr_t *sba, const bdaddr_t *dba,
|
||||
device_type_t type)
|
||||
{
|
||||
char filename[PATH_MAX + 1], addr[18], chars[3];
|
||||
|
||||
create_filename(filename, PATH_MAX, sba, "types");
|
||||
|
||||
create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
|
||||
ba2str(dba, addr);
|
||||
|
||||
snprintf(chars, sizeof(chars), "%2.2X", type);
|
||||
|
||||
return textfile_put(filename, addr, chars);
|
||||
}
|
||||
|
||||
device_type_t read_device_type(const bdaddr_t *sba, const bdaddr_t *dba)
|
||||
{
|
||||
char filename[PATH_MAX + 1], addr[18], *chars;
|
||||
device_type_t type;
|
||||
|
||||
create_filename(filename, PATH_MAX, sba, "types");
|
||||
|
||||
create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
|
||||
ba2str(dba, addr);
|
||||
|
||||
chars = textfile_caseget(filename, addr);
|
||||
if (chars == NULL)
|
||||
return DEVICE_TYPE_UNKNOWN;
|
||||
|
||||
type = strtol(chars, NULL, 16);
|
||||
|
||||
free(chars);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
@ -91,6 +91,9 @@ char *read_device_characteristics(const bdaddr_t *sba, const bdaddr_t *dba,
|
||||
int write_device_attribute(const bdaddr_t *sba, const bdaddr_t *dba,
|
||||
uint16_t handle, const char *chars);
|
||||
int read_device_attributes(const bdaddr_t *sba, textfile_cb func, void *data);
|
||||
int write_device_type(const bdaddr_t *sba, const bdaddr_t *dba,
|
||||
device_type_t type);
|
||||
device_type_t read_device_type(const bdaddr_t *sba, const bdaddr_t *dba);
|
||||
|
||||
#define PNP_UUID "00001200-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user