summaryrefslogtreecommitdiffstats
path: root/binding/radio-binding.c
diff options
context:
space:
mode:
authorEhsan Takalloo <ehsan.takalloo@gmail.com>2020-08-10 17:18:39 +0430
committerScott Murray <scott.murray@konsulko.com>2020-09-01 13:13:55 -0400
commit4cdb281367813ffc12face0bbcba300fe6e7e2d3 (patch)
treee69cfe4402212d1db80f963c54c7c7d86205e898 /binding/radio-binding.c
parent377a25d3f0831b5fd4a0ac01358ec86341d2531e (diff)
Add rds event
Update types in radio_impl_tef665x.c and radio_impl_tef665x.h Add rds verb to tef665x and send latest rds as response Implement rds parser based on rds standard structure and tef-665x user-manual for rds group types 0A, 0B, 1A, 2A, 2B and 4A Implement scan_start verb for tef-665x Implement scan_stop verb for tef-665x Implement get stereo_mode verb for tef-665x Fix an issue in tef665x_set_frequency_callback Update README.md file Signed-off-by: Ehsan Takalloo <ehsan.takalloo@gmail.com> Change-Id: Ife057e46c52fc420541dbad3b4f51c7d01707a3d
Diffstat (limited to 'binding/radio-binding.c')
-rw-r--r--binding/radio-binding.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/binding/radio-binding.c b/binding/radio-binding.c
index 6df4b6d..0ab5565 100644
--- a/binding/radio-binding.c
+++ b/binding/radio-binding.c
@@ -36,6 +36,7 @@ static radio_impl_ops_t *radio_impl_ops;
static afb_event_t freq_event;
static afb_event_t scan_event;
static afb_event_t status_event;
+static afb_event_t rds_event;
static bool playing;
@@ -64,6 +65,12 @@ static void scan_callback(uint32_t frequency, void *data)
afb_event_push(scan_event, json_object_get(jresp));
}
+static void rds_callback(void *rds_data)
+{
+ //rds_data is a json object
+ afb_event_push(rds_event, json_object_get(rds_data));
+}
+
/*
* Binding verb handlers
*/
@@ -464,7 +471,10 @@ static void subscribe(afb_req_t request)
afb_req_subscribe(request, scan_event);
} else if(!strcasecmp(value, "status")) {
afb_req_subscribe(request, status_event);
- } else {
+ } else if(!strcasecmp(value, "rds")) {
+ afb_req_subscribe(request, rds_event);
+ }
+ else {
afb_req_reply(request, NULL, "failed", "Invalid event");
return;
}
@@ -488,6 +498,10 @@ static void unsubscribe(afb_req_t request)
afb_req_unsubscribe(request, scan_event);
} else if(!strcasecmp(value, "status")) {
afb_req_unsubscribe(request, status_event);
+
+ } else if(!strcasecmp(value, "rds")) {
+ afb_req_unsubscribe(request, rds_event);
+
} else {
afb_req_reply(request, NULL, "failed", "Invalid event");
return;
@@ -572,6 +586,12 @@ static int init(afb_api_t api)
if(rc == 0) {
AFB_API_NOTICE(afbBindingV3root, "%s found\n", radio_impl_ops->name);
radio_impl_ops->set_frequency_callback(freq_callback, NULL);
+ if(radio_impl_ops->set_rds_callback)
+ {
+ radio_impl_ops->set_rds_callback(rds_callback);
+ }
+
+
} else {
return rc;
}
@@ -600,7 +620,7 @@ static int init(afb_api_t api)
freq_event = afb_daemon_make_event("frequency");
scan_event = afb_daemon_make_event("station_found");
status_event = afb_daemon_make_event("status");
-
+ rds_event = afb_daemon_make_event("rds");
return 0;
}