forked from enlightenment/enlightenment
bluez5 - if bz says it's busy when trying to power on, keep trying again
This commit is contained in:
parent
56e3d705ed
commit
2718516b42
|
@ -24,6 +24,7 @@ struct _Obj {
|
||||||
Eina_Bool ping_busy : 1;
|
Eina_Bool ping_busy : 1;
|
||||||
Eina_Bool ping_block : 1;
|
Eina_Bool ping_block : 1;
|
||||||
Ecore_Timer *ping_timer;
|
Ecore_Timer *ping_timer;
|
||||||
|
Ecore_Timer *power_retry_timer;
|
||||||
//// public data to read
|
//// public data to read
|
||||||
const char *path;
|
const char *path;
|
||||||
Obj_Type type;
|
Obj_Type type;
|
||||||
|
|
|
@ -412,10 +412,31 @@ bz_obj_find(const char *path)
|
||||||
return eina_hash_find(obj_table, path);
|
return eina_hash_find(obj_table, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static Eina_Bool
|
||||||
cb_power_on(void *data EINA_UNUSED, const Eldbus_Message *msg EINA_UNUSED, Eldbus_Pending *pending EINA_UNUSED)
|
_cb_power_again(void *data)
|
||||||
{
|
{
|
||||||
ERR_PRINT("Power On");
|
Obj *o = data;
|
||||||
|
|
||||||
|
o->power_retry_timer = NULL;
|
||||||
|
printf("Retry power on...");
|
||||||
|
bz_obj_power_on(o);
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cb_power_on(void *data, const Eldbus_Message *msg EINA_UNUSED, Eldbus_Pending *pending EINA_UNUSED)
|
||||||
|
{
|
||||||
|
Obj *o = data;
|
||||||
|
const char *name, *text;
|
||||||
|
|
||||||
|
if (eldbus_message_error_get(msg, &name, &text))
|
||||||
|
{
|
||||||
|
printf("Error: %s.\n %s:\n %s\n", "Power On", name, text);
|
||||||
|
if (!strcmp(name, "org.bluez.Error.Busy"))
|
||||||
|
{
|
||||||
|
o->power_retry_timer = ecore_timer_add(0.5, _cb_power_again, o);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -438,6 +459,11 @@ bz_obj_power_off(Obj *o)
|
||||||
{
|
{
|
||||||
Eina_Bool val = EINA_FALSE;
|
Eina_Bool val = EINA_FALSE;
|
||||||
if (!o->proxy) return;
|
if (!o->proxy) return;
|
||||||
|
if (o->power_retry_timer)
|
||||||
|
{
|
||||||
|
ecore_timer_del(o->power_retry_timer);
|
||||||
|
o->power_retry_timer = NULL;
|
||||||
|
}
|
||||||
eldbus_proxy_property_set
|
eldbus_proxy_property_set
|
||||||
(o->proxy, "Powered", "b", (void *)(uintptr_t)val, cb_power_off, o);
|
(o->proxy, "Powered", "b", (void *)(uintptr_t)val, cb_power_off, o);
|
||||||
}
|
}
|
||||||
|
@ -810,6 +836,11 @@ bz_obj_unref(Obj *o)
|
||||||
ecore_timer_del(o->ping_timer);
|
ecore_timer_del(o->ping_timer);
|
||||||
o->ping_timer = NULL;
|
o->ping_timer = NULL;
|
||||||
}
|
}
|
||||||
|
if (o->power_retry_timer)
|
||||||
|
{
|
||||||
|
ecore_timer_del(o->power_retry_timer);
|
||||||
|
o->power_retry_timer = NULL;
|
||||||
|
}
|
||||||
if (o->proxy)
|
if (o->proxy)
|
||||||
{
|
{
|
||||||
eldbus_proxy_unref(o->proxy);
|
eldbus_proxy_unref(o->proxy);
|
||||||
|
|
Loading…
Reference in New Issue