diff options
Diffstat (limited to 'binding/telephony-binding.c')
-rw-r--r-- | binding/telephony-binding.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/binding/telephony-binding.c b/binding/telephony-binding.c index c84af2c..dce0ef9 100644 --- a/binding/telephony-binding.c +++ b/binding/telephony-binding.c @@ -106,6 +106,24 @@ static void answer(afb_req_t request) } } +static void get_battery_level(afb_req_t request) +{ + const gchar *device; + + device = ofono_manager_get_default_modem_path(); + if (!device) { + afb_req_fail(request, "failed", "No path find"); + return; + } + + json_object *result = ofono_get_property(device, OFONO_HANDSFREE_INTERFACE, "BatteryChargeLevel", NULL); + if (!result) + afb_req_fail(request, "failed", "Can not find Battery object"); + else + afb_req_success(request, result, "OK"); + return; +} + static void subscribe(afb_req_t request) { const char *value = afb_req_value(request, "value"); @@ -354,6 +372,10 @@ static const afb_verb_t verbs[]= { .callback = answer, }, { + .verb = "get_battery_level", + .callback = get_battery_level, + }, + { .verb = "subscribe", .callback = subscribe, }, |