From 067ffa5ef915499fed17a2ed67ad2fe689fdea81 Mon Sep 17 00:00:00 2001 From: saman Date: Mon, 30 Nov 2020 09:11:27 +0330 Subject: Getting network registration of connected phone device. Is used ofono service and NetworkRegistration interface. Add NeworkRegistration interface to provide access to the connected phone's network registration properties (registration mode, status, technology, strength) Bug-AGL: SPEC-3721 Signed-off-by: saman Change-Id: I9c4be0366f97b39056af3b5bc9e861097a48ed44 --- README.md | 1 + binding/gdbus/ofono_manager.h | 1 + binding/telephony-binding.c | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/README.md b/README.md index 34ca312..d6cee02 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Telephony service allows respective clients access to the Handsfree Profile via | hangup | hangup an active call or reject incoming call | | | answer | answer incoming call | | | get_battery_level | getting battery level of connected phone device | | +| get_network_registration | getting network registration of connected phone device | *Response:* {"Status": "registered","Mode": "auto-only","Name": "Irancell","Strength": 20} | ## Events diff --git a/binding/gdbus/ofono_manager.h b/binding/gdbus/ofono_manager.h index c7333d0..cd62736 100644 --- a/binding/gdbus/ofono_manager.h +++ b/binding/gdbus/ofono_manager.h @@ -23,6 +23,7 @@ #define OFONO_SERVICE "org.ofono" #define OFONO_HANDSFREE_INTERFACE OFONO_SERVICE ".Handsfree" +#define OFONO_NetworkRegistration_INTERFACE OFONO_SERVICE ".NetworkRegistration" int ofono_manager_init(void); void ofono_manager_invalidate_default_modem(void); diff --git a/binding/telephony-binding.c b/binding/telephony-binding.c index 2f96338..b2dc073 100644 --- a/binding/telephony-binding.c +++ b/binding/telephony-binding.c @@ -141,6 +141,24 @@ static void get_battery_level(afb_req_t request) return; } +static void get_network_registration(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_NetworkRegistration_INTERFACE, NULL, NULL); + if (!result) + afb_req_fail(request, "failed", "Can not find Network Registration object"); + else + afb_req_success(request, result, "OK"); + return; +} + static void subscribe(afb_req_t request) { const char *value = afb_req_value(request, "value"); @@ -396,6 +414,10 @@ static const afb_verb_t verbs[]= { .verb = "get_battery_level", .callback = get_battery_level, }, + { + .verb = "get_network_registration", + .callback = get_network_registration, + }, { .verb = "subscribe", .callback = subscribe, -- cgit 1.2.3-korg