summaryrefslogtreecommitdiffstats
path: root/binding
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2017-08-17 20:22:37 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2017-08-17 20:32:30 -0700
commit29ffbaaf5c84f0c8fad0940939bd8a54d5879c56 (patch)
tree76dc55f7f4e672359ccf36049f2ecb84f1ec18d6 /binding
parentb14bd26a92259c86147465ced782830bb310aac9 (diff)
binding: radio: upgrade to v2 of binding framework
Update structures and function calls to afm binding framework version 2 specs Bug-AGL: SPEC-835 Change-Id: Ie9198c4fe035e2267a1098fac7995b60e65809ec Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding')
-rw-r--r--binding/radio-binding.c61
1 files changed, 26 insertions, 35 deletions
diff --git a/binding/radio-binding.c b/binding/radio-binding.c
index 12ed966..c82c435 100644
--- a/binding/radio-binding.c
+++ b/binding/radio-binding.c
@@ -16,6 +16,7 @@
#define _GNU_SOURCE
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
@@ -23,13 +24,12 @@
#include <sys/types.h>
#include <json-c/json.h>
+#define AFB_BINDING_VERSION 2
#include <afb/afb-binding.h>
#include <afb/afb-service-itf.h>
#include "radio_impl.h"
-static const struct afb_binding_interface *interface;
-
static struct afb_event freq_event;
static struct afb_event scan_event;
@@ -445,44 +445,28 @@ static void unsubscribe(struct afb_req request)
afb_req_success(request, NULL, NULL);
}
-static const struct afb_verb_desc_v1 verbs[]= {
- { "frequency", AFB_SESSION_CHECK, frequency, "Get/Set frequency" },
- { "band", AFB_SESSION_CHECK, band, "Get/Set band" },
- { "band_supported", AFB_SESSION_CHECK, band_supported, "Check band support" },
- { "frequency_range", AFB_SESSION_CHECK, frequency_range, "Get frequency range" },
- { "frequency_step", AFB_SESSION_CHECK, frequency_step, "Get frequency step" },
- { "start", AFB_SESSION_CHECK, start, "Start radio playback" },
- { "stop", AFB_SESSION_CHECK, stop, "Stop radio playback" },
- { "scan_start", AFB_SESSION_CHECK, scan_start, "Start station scan" },
- { "scan_stop", AFB_SESSION_CHECK, scan_stop, "Stop station scan" },
- { "stereo_mode", AFB_SESSION_CHECK, stereo_mode, "Get/Set stereo_mode" },
- { "subscribe", AFB_SESSION_CHECK, subscribe, "Subscribe for an event" },
- { "unsubscribe", AFB_SESSION_CHECK, unsubscribe, "Unsubscribe for an event" },
- { NULL }
+static const struct afb_verb_v2 verbs[]= {
+ { .verb = "frequency", .session = AFB_SESSION_CHECK, .callback = frequency, .info = "Get/Set frequency" },
+ { .verb = "band", .session = AFB_SESSION_CHECK, .callback = band, .info = "Get/Set band" },
+ { .verb = "band_supported", .session = AFB_SESSION_CHECK, .callback = band_supported, .info = "Check band support" },
+ { .verb = "frequency_range", .session = AFB_SESSION_CHECK, .callback = frequency_range, .info = "Get frequency range" },
+ { .verb = "frequency_step", .session = AFB_SESSION_CHECK, .callback = frequency_step, .info = "Get frequency step" },
+ { .verb = "start", .session = AFB_SESSION_CHECK, .callback = start, .info = "Start radio playback" },
+ { .verb = "stop", .session = AFB_SESSION_CHECK, .callback = stop, .info = "Stop radio playback" },
+ { .verb = "scan_start", .session = AFB_SESSION_CHECK, .callback = scan_start, .info = "Start station scan" },
+ { .verb = "scan_stop", .session = AFB_SESSION_CHECK, .callback = scan_stop, .info = "Stop station scan" },
+ { .verb = "stereo_mode", .session = AFB_SESSION_CHECK, .callback = stereo_mode, .info = "Get/Set stereo_mode" },
+ { .verb = "subscribe", .session = AFB_SESSION_CHECK, .callback = subscribe, .info = "Subscribe for an event" },
+ { .verb = "unsubscribe", .session = AFB_SESSION_CHECK, .callback = unsubscribe, .info = "Unsubscribe for an event" },
+ { }
};
-static const struct afb_binding binding_desc = {
- .type = AFB_BINDING_VERSION_1,
- .v1 = {
- .info = "radio service",
- .prefix = "radio",
- .verbs = verbs
- }
-};
-
-const struct afb_binding *afbBindingV1Register (const struct afb_binding_interface *itf)
-{
- interface = itf;
-
- return &binding_desc;
-}
-
-int afbBindingV1ServiceInit(struct afb_service service)
+static int init()
{
int rc;
- freq_event = afb_daemon_make_event(interface->daemon, "frequency");
- scan_event = afb_daemon_make_event(interface->daemon, "station_found");
+ freq_event = afb_daemon_make_event("frequency");
+ scan_event = afb_daemon_make_event("station_found");
rc = radio_impl_init();
if(rc == 0) {
@@ -491,3 +475,10 @@ int afbBindingV1ServiceInit(struct afb_service service)
return rc;
}
+
+const struct afb_binding_v2 afbBindingV2 = {
+ .info = "radio service",
+ .api = "radio",
+ .verbs = verbs,
+ .init = init,
+};