return dbus_message_new_method_return(msg);
}
-static void set_le_static_address(struct btd_adapter *adapter)
+static void init_le_static_address(struct btd_adapter *adapter)
{
int fd;
int ret;
char address[18];
char dirname[PATH_MAX];
+ int i;
+ bdaddr_t le_static_addr;
+
+ le_static_addr.b[5] = adapter->bdaddr.b[5] | 0xc0;
+ for (i = 0; i < 5; i++) {
+ le_static_addr.b[i] =
+ (adapter->bdaddr.b[i] & 0x7f) << 1 |
+ (adapter->bdaddr.b[i] & 0x80) >> 7;
+ }
+
+ /*
+ * < How to get Public address from above static address >
+ *
+ * for (i = 0; i < 5; i++) {
+ * bredr_addr.b[i] =
+ * (adapter->le_static_addr.b[i] & 0xfe) >> 1 |
+ * (adapter->le_static_addr.b[i] & 0x01) << 7;
+ * }
+ * bredr_addr.b[5] = {the value from advertising data}
+ */
snprintf(dirname, PATH_MAX, STORAGEDIR "/%s", "le_static_addr");
- if (access(dirname, F_OK) < 0) {
- int i;
- bdaddr_t le_static_addr;
-
- le_static_addr.b[5] = adapter->bdaddr.b[5] | 0xc0;
- for (i = 0; i < 5; i++) {
- le_static_addr.b[i] =
- (adapter->bdaddr.b[i] & 0x7f) << 1 |
- (adapter->bdaddr.b[i] & 0x80) >> 7;
+ fd = open(dirname, O_WRONLY | O_CREAT, 0644);
+
+ if (fd >= 0) {
+ ba2str(&le_static_addr, address);
+ DBG("LE static random : %s", address);
+ ret = write(fd, address, strlen(address));
+ if (ret < 0) {
+ error("Cannot save LE address : %s",
+ strerror(errno));
}
- /*
- * < How to get Public address from above static address >
- *
- * for (i = 0; i < 5; i++) {
- * bredr_addr.b[i] =
- * (adapter->le_static_addr.b[i] & 0xfe) >> 1 |
- * (adapter->le_static_addr.b[i] & 0x01) << 7;
- * }
- * bredr_addr.b[5] = {the value from advertising data}
- */
+ ret = fdatasync(fd);
+ if (ret < 0)
+ error("sync failed : %s", strerror(errno));
- fd = open(dirname, O_WRONLY | O_CREAT, 0644);
- if (fd >= 0) {
- ba2str(&le_static_addr, address);
- DBG("LE static random : %s", address);
- ret = write(fd, address, strlen(address));
- if (ret < 0) {
- error("Cannot save LE address : %s",
- strerror(errno));
- }
+ close(fd);
+ } else {
+ error("Cannot save LE address");
+ }
+ bacpy(&adapter->le_static_addr, &le_static_addr);
+}
- ret = fdatasync(fd);
- if (ret < 0)
- error("sync failed : %s", strerror(errno));
+static void set_le_static_address(struct btd_adapter *adapter)
+{
+ int fd;
+ int ret;
+ char address[18];
+ char dirname[PATH_MAX];
- close(fd);
- } else {
- error("Cannot save LE address");
- }
- bacpy(&adapter->le_static_addr, &le_static_addr);
+ snprintf(dirname, PATH_MAX, STORAGEDIR "/%s", "le_static_addr");
+ if (access(dirname, F_OK) < 0) {
+ init_le_static_address(adapter);
} else {
fd = open(dirname, O_RDONLY);
if (fd >= 0) {
set_mode(adapter, MGMT_OP_SET_POWERED, 0x01);
#endif
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+ init_le_static_address(adapter);
+#endif
+
return;
failed: