From 07021baf7a9e81f75776c99d65b774204b11422e Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 2 Oct 2007 12:03:39 +0000 Subject: Implement support for SetMode("on") --- hcid/storage.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'hcid/storage.c') diff --git a/hcid/storage.c b/hcid/storage.c index 68f3470c..f2254cc3 100644 --- a/hcid/storage.c +++ b/hcid/storage.c @@ -94,6 +94,9 @@ int write_device_mode(bdaddr_t *bdaddr, const char *mode) create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + if (strcmp(mode, "off") != 0) + textfile_put(filename, "on", mode); + return textfile_put(filename, "mode", mode); } @@ -115,6 +118,24 @@ int read_device_mode(bdaddr_t *bdaddr, char *mode, int length) return 0; } +int read_on_mode(bdaddr_t *bdaddr, char *mode, int length) +{ + char filename[PATH_MAX + 1], *str; + + create_filename(filename, PATH_MAX, bdaddr, "config"); + + str = textfile_get(filename, "on"); + if (!str) + return -ENOENT; + + strncpy(mode, str, length); + mode[length - 1] = '\0'; + + free(str); + + return 0; +} + int write_local_name(bdaddr_t *bdaddr, char *name) { char filename[PATH_MAX + 1], str[249]; -- cgit