diff --git a/src/device.c b/src/device.c
index 2d3ac71..24ef3d7 100644
--- a/src/device.c
+++ b/src/device.c
device->wake_support = wake_support;
- /* If wake configuration has not been made yet, set the initial
- * configuration.
+ if (device->wake_support)
+ device->supported_flags |= DEVICE_FLAG_REMOTE_WAKEUP;
+ else
+ device->supported_flags &= ~DEVICE_FLAG_REMOTE_WAKEUP;
+
+ /* If there is not override set, set the default the same as
+ * support value.
*/
- if (device->wake_override == WAKE_FLAG_DEFAULT) {
+ if (device->wake_override == WAKE_FLAG_DEFAULT)
device_set_wake_override(device, wake_support);
- device_set_wake_allowed(device, wake_support, -1U);
- }
+
+ /* Set wake_allowed according to the override value. */
+ device_set_wake_allowed(device,
+ device->wake_override == WAKE_FLAG_ENABLED,
+ -1U);
}
static bool device_get_wake_allowed(struct btd_device *device)
void device_set_wake_override(struct btd_device *device, bool wake_override)
{
- if (wake_override) {
+ if (wake_override)
device->wake_override = WAKE_FLAG_ENABLED;
- device->current_flags |= DEVICE_FLAG_REMOTE_WAKEUP;
- } else {
+ else
device->wake_override = WAKE_FLAG_DISABLED;
- device->current_flags &= ~DEVICE_FLAG_REMOTE_WAKEUP;
- }
}
static void device_set_wake_allowed_complete(struct btd_device *device)
if (status != MGMT_STATUS_SUCCESS) {
error("Set device flags return status: %s",
mgmt_errstr(status));
+ if (dev->wake_id != -1U) {
+ g_dbus_pending_property_error(dev->wake_id,
+ ERROR_INTERFACE ".Failed",
+ mgmt_errstr(status));
+ dev->wake_id = -1U;
+ }
return;
}
* progress. Only update wake allowed if pending value doesn't match the
* new value.
*/
- if (wake_allowed == device->pending_wake_allowed)
+ if (device->wake_id != -1U && id != -1U) {
+ g_dbus_pending_property_error(id, ERROR_INTERFACE ".Busy",
+ "Property change in progress");
return;
+ }
device->wake_id = id;
device->pending_wake_allowed = wake_allowed;
device->tx_power = 127;
device->volume = -1;
+ device->wake_id = -1U;
device->db = gatt_db_new();
if (!device->db) {