aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLi Xiaoming <lixm.fnst@cn.fujitsu.com>2019-11-29 09:47:14 +0100
committerLi Xiaoming <lixm.fnst@cn.fujitsu.com>2019-12-02 12:05:48 +0000
commit9b5ca97855494c9f9c4c80427400539d71c65759 (patch)
treeec536ad71ca36474128b732cdeb4086ecf708cb5
parent8239d20cc9ee88ca052060589ec8bf9e66cda6a3 (diff)
Migration to binding V3icefish_8.99.2icefish/8.99.28.99.2
Bug-AGL: SPEC-2745 Change-Id: I5ee9d3118a302f0edf5fe79a43590818d3d829c3 Signed-off-by: Li Xiaoming <lixm.fnst@cn.fujitsu.com>
-rw-r--r--binding/CMakeLists.txt2
-rw-r--r--binding/radio-binding.c112
-rw-r--r--binding/radio_impl_kingfisher.c16
-rw-r--r--binding/radio_impl_rtlsdr.c16
4 files changed, 73 insertions, 73 deletions
diff --git a/binding/CMakeLists.txt b/binding/CMakeLists.txt
index 97bc2a6..8f5b43a 100644
--- a/binding/CMakeLists.txt
+++ b/binding/CMakeLists.txt
@@ -21,7 +21,7 @@
# Add target to project dependency list
PROJECT_TARGET_ADD(radio-binding)
- add_definitions(-DAFB_BINDING_VERSION=2)
+ add_definitions(-DAFB_BINDING_VERSION=3)
# Define project Targets
set(radio_SOURCES
diff --git a/binding/radio-binding.c b/binding/radio-binding.c
index 847e822..1dae5da 100644
--- a/binding/radio-binding.c
+++ b/binding/radio-binding.c
@@ -33,9 +33,9 @@
static radio_impl_ops_t *radio_impl_ops;
-static struct afb_event freq_event;
-static struct afb_event scan_event;
-static struct afb_event status_event;
+static afb_event_t freq_event;
+static afb_event_t scan_event;
+static afb_event_t status_event;
static void freq_callback(uint32_t frequency, void *data)
{
@@ -62,10 +62,10 @@ static void scan_callback(uint32_t frequency, void *data)
/*
* @brief Get (and optionally set) frequency
*
- * @param struct afb_req : an afb request structure
+ * @param afb_req_t : an afb request structure
*
*/
-static void frequency(struct afb_req request)
+static void frequency(afb_req_t request)
{
json_object *ret_json;
const char *value = afb_req_value(request, "value");
@@ -77,28 +77,28 @@ static void frequency(struct afb_req request)
if(frequency && *p == '\0') {
radio_impl_ops->set_frequency(frequency);
} else {
- afb_req_fail(request, "failed", "Invalid scan direction");
+ afb_req_reply(request, NULL, "failed", "Invalid scan direction");
return;
}
}
ret_json = json_object_new_object();
frequency = radio_impl_ops->get_frequency();
json_object_object_add(ret_json, "frequency", json_object_new_int((int32_t) frequency));
- afb_req_success(request, ret_json, NULL);
+ afb_req_reply(request, ret_json, NULL, NULL);
}
/* @brief Get RDS information
*
-* @param struct afb_req : an afb request structure
+* @param afb_req_t : an afb request structure
*
*/
-static void rds(struct afb_req request)
+static void rds(afb_req_t request)
{
json_object *ret_json;
char * rds;
if (radio_impl_ops->get_rds_info == NULL) {
- afb_req_fail(request, "failed", "not supported");
+ afb_req_reply(request, NULL, "failed", "not supported");
return;
}
@@ -107,16 +107,16 @@ static void rds(struct afb_req request)
json_object_object_add(ret_json, "rds", json_object_new_string(rds?rds:""));
free(rds);
- afb_req_success(request, ret_json, NULL);
+ afb_req_reply(request, ret_json, NULL, NULL);
}
/*
* @brief Get (and optionally set) frequency band
*
- * @param struct afb_req : an afb request structure
+ * @param afb_req_t : an afb request structure
*
*/
-static void band(struct afb_req request)
+static void band(afb_req_t request)
{
json_object *ret_json;
const char *value = afb_req_value(request, "value");
@@ -148,7 +148,7 @@ static void band(struct afb_req request)
if(valid) {
radio_impl_ops->set_band(band);
} else {
- afb_req_fail(request, "failed", "Invalid band");
+ afb_req_reply(request, NULL, "failed", "Invalid band");
return;
}
}
@@ -156,16 +156,16 @@ static void band(struct afb_req request)
band = radio_impl_ops->get_band();
sprintf(band_name, "%s", band == BAND_AM ? "AM" : "FM");
json_object_object_add(ret_json, "band", json_object_new_string(band_name));
- afb_req_success(request, ret_json, NULL);
+ afb_req_reply(request, ret_json, NULL, NULL);
}
/*
* @brief Check if band is supported
*
- * @param struct afb_req : an afb request structure
+ * @param afb_req_t : an afb request structure
*
*/
-static void band_supported(struct afb_req request)
+static void band_supported(afb_req_t request)
{
json_object *ret_json;
const char *value = afb_req_value(request, "band");
@@ -195,23 +195,23 @@ static void band_supported(struct afb_req request)
}
}
if(!valid) {
- afb_req_fail(request, "failed", "Invalid band");
+ afb_req_reply(request, NULL, "failed", "Invalid band");
return;
}
ret_json = json_object_new_object();
json_object_object_add(ret_json,
"supported",
json_object_new_int(radio_impl_ops->band_supported(band)));
- afb_req_success(request, ret_json, NULL);
+ afb_req_reply(request, ret_json, NULL, NULL);
}
/*
* @brief Get frequency range for a band
*
- * @param struct afb_req : an afb request structure
+ * @param afb_req_t : an afb request structure
*
*/
-static void frequency_range(struct afb_req request)
+static void frequency_range(afb_req_t request)
{
json_object *ret_json;
const char *value = afb_req_value(request, "band");
@@ -243,7 +243,7 @@ static void frequency_range(struct afb_req request)
}
}
if(!valid) {
- afb_req_fail(request, "failed", "Invalid band");
+ afb_req_reply(request, NULL, "failed", "Invalid band");
return;
}
ret_json = json_object_new_object();
@@ -251,16 +251,16 @@ static void frequency_range(struct afb_req request)
max_frequency = radio_impl_ops->get_max_frequency(band);
json_object_object_add(ret_json, "min", json_object_new_int((int32_t) min_frequency));
json_object_object_add(ret_json, "max", json_object_new_int((int32_t) max_frequency));
- afb_req_success(request, ret_json, NULL);
+ afb_req_reply(request, ret_json, NULL, NULL);
}
/*
* @brief Get frequency step size (Hz) for a band
*
- * @param struct afb_req : an afb request structure
+ * @param afb_req_t : an afb request structure
*
*/
-static void frequency_step(struct afb_req request)
+static void frequency_step(afb_req_t request)
{
json_object *ret_json;
const char *value = afb_req_value(request, "band");
@@ -291,26 +291,26 @@ static void frequency_step(struct afb_req request)
}
}
if(!valid) {
- afb_req_fail(request, "failed", "Invalid band");
+ afb_req_reply(request, NULL, "failed", "Invalid band");
return;
}
ret_json = json_object_new_object();
step = radio_impl_ops->get_frequency_step(band);
json_object_object_add(ret_json, "step", json_object_new_int((int32_t) step));
- afb_req_success(request, ret_json, NULL);
+ afb_req_reply(request, ret_json, NULL, NULL);
}
/*
* @brief Start radio playback
*
- * @param struct afb_req : an afb request structure
+ * @param afb_req_t : an afb request structure
*
*/
-static void start(struct afb_req request)
+static void start(afb_req_t request)
{
radio_impl_ops->set_output(NULL);
radio_impl_ops->start();
- afb_req_success(request, NULL, NULL);
+ afb_req_reply(request, NULL, NULL, NULL);
json_object *jresp = json_object_new_object();
json_object *value = json_object_new_string("playing");
@@ -321,13 +321,13 @@ static void start(struct afb_req request)
/*
* @brief Stop radio playback
*
- * @param struct afb_req : an afb request structure
+ * @param afb_req_t : an afb request structure
*
*/
-static void stop(struct afb_req request)
+static void stop(afb_req_t request)
{
radio_impl_ops->stop();
- afb_req_success(request, NULL, NULL);
+ afb_req_reply(request, NULL, NULL, NULL);
json_object *jresp = json_object_new_object();
json_object *value = json_object_new_string("stopped");
@@ -338,10 +338,10 @@ static void stop(struct afb_req request)
/*
* @brief Scan for a station in the specified direction
*
- * @param struct afb_req : an afb request structure
+ * @param afb_req_t : an afb request structure
*
*/
-static void scan_start(struct afb_req request)
+static void scan_start(afb_req_t request)
{
const char *value = afb_req_value(request, "direction");
int valid = 0;
@@ -370,32 +370,32 @@ static void scan_start(struct afb_req request)
}
}
if(!valid) {
- afb_req_fail(request, "failed", "Invalid direction");
+ afb_req_reply(request, NULL, "failed", "Invalid direction");
return;
}
radio_impl_ops->scan_start(direction, scan_callback, NULL);
- afb_req_success(request, NULL, NULL);
+ afb_req_reply(request, NULL, NULL, NULL);
}
/*
* @brief Stop station scan
*
- * @param struct afb_req : an afb request structure
+ * @param afb_req_t : an afb request structure
*
*/
-static void scan_stop(struct afb_req request)
+static void scan_stop(afb_req_t request)
{
radio_impl_ops->scan_stop();
- afb_req_success(request, NULL, NULL);
+ afb_req_reply(request, NULL, NULL, NULL);
}
/*
* @brief Get (and optionally set) stereo mode
*
- * @param struct afb_req : an afb request structure
+ * @param afb_req_t : an afb request structure
*
*/
-static void stereo_mode(struct afb_req request)
+static void stereo_mode(afb_req_t request)
{
json_object *ret_json;
const char *value = afb_req_value(request, "value");
@@ -426,7 +426,7 @@ static void stereo_mode(struct afb_req request)
if(valid) {
radio_impl_ops->set_stereo_mode(mode);
} else {
- afb_req_fail(request, "failed", "Invalid mode");
+ afb_req_reply(request, NULL, "failed", "Invalid mode");
return;
}
}
@@ -434,16 +434,16 @@ static void stereo_mode(struct afb_req request)
mode = radio_impl_ops->get_stereo_mode();
json_object_object_add(ret_json, "mode", json_object_new_string(mode == MONO ? "mono" : "stereo"));
- afb_req_success(request, ret_json, NULL);
+ afb_req_reply(request, ret_json, NULL, NULL);
}
/*
* @brief Subscribe for an event
*
- * @param struct afb_req : an afb request structure
+ * @param afb_req_t : an afb request structure
*
*/
-static void subscribe(struct afb_req request)
+static void subscribe(afb_req_t request)
{
const char *value = afb_req_value(request, "value");
if(value) {
@@ -454,20 +454,20 @@ static void subscribe(struct afb_req request)
} else if(!strcasecmp(value, "status")) {
afb_req_subscribe(request, status_event);
} else {
- afb_req_fail(request, "failed", "Invalid event");
+ afb_req_reply(request, NULL, "failed", "Invalid event");
return;
}
}
- afb_req_success(request, NULL, NULL);
+ afb_req_reply(request, NULL, NULL, NULL);
}
/*
* @brief Unsubscribe for an event
*
- * @param struct afb_req : an afb request structure
+ * @param afb_req_t : an afb request structure
*
*/
-static void unsubscribe(struct afb_req request)
+static void unsubscribe(afb_req_t request)
{
const char *value = afb_req_value(request, "value");
if(value) {
@@ -478,14 +478,14 @@ static void unsubscribe(struct afb_req request)
} else if(!strcasecmp(value, "status")) {
afb_req_unsubscribe(request, status_event);
} else {
- afb_req_fail(request, "failed", "Invalid event");
+ afb_req_reply(request, NULL, "failed", "Invalid event");
return;
}
}
- afb_req_success(request, NULL, NULL);
+ afb_req_reply(request, NULL, NULL, NULL);
}
-static const struct afb_verb_v2 verbs[]= {
+static const afb_verb_t verbs[]= {
{ .verb = "frequency", .session = AFB_SESSION_NONE, .callback = frequency, .info = "Get/Set frequency" },
{ .verb = "band", .session = AFB_SESSION_NONE, .callback = band, .info = "Get/Set band" },
{ .verb = "rds", .session = AFB_SESSION_NONE, .callback = rds, .info = "Get RDS information" },
@@ -513,10 +513,10 @@ static int init()
rc = radio_impl_ops->init();
}
if (rc != 0) {
- AFB_ERROR("No radio device found, exiting");
+ AFB_API_ERROR(afbBindingV3root, "No radio device found, exiting");
}
if(rc == 0) {
- AFB_NOTICE("%s found\n", radio_impl_ops->name);
+ AFB_API_NOTICE(afbBindingV3root, "%s found\n", radio_impl_ops->name);
radio_impl_ops->set_frequency_callback(freq_callback, NULL);
} else {
return rc;
@@ -530,7 +530,7 @@ static int init()
return 0;
}
-const struct afb_binding_v2 afbBindingV2 = {
+const afb_binding_t afbBindingExport = {
.info = "radio service",
.api = "radio",
.verbs = verbs,
diff --git a/binding/radio_impl_kingfisher.c b/binding/radio_impl_kingfisher.c
index 24c547f..7732f51 100644
--- a/binding/radio_impl_kingfisher.c
+++ b/binding/radio_impl_kingfisher.c
@@ -130,7 +130,7 @@ static int kf_init(void)
"scan_valid_snr_threshold",
&error);
if(!error) {
- AFB_INFO("Scan valid SNR level set to %d", n);
+ AFB_API_INFO(afbBindingV3root, "Scan valid SNR level set to %d", n);
scan_valid_snr_threshold = n;
}
@@ -140,14 +140,14 @@ static int kf_init(void)
"scan_valid_rssi_threshold",
&error);
if(!error) {
- AFB_INFO("Scan valid SNR level set to %d", n);
+ AFB_API_INFO(afbBindingV3root, "Scan valid SNR level set to %d", n);
scan_valid_rssi_threshold = n;
}
g_key_file_free(conf_file);
}
- AFB_INFO("Using FM Bandplan: %s", known_fm_band_plans[bandplan].name);
+ AFB_API_INFO(afbBindingV3root, "Using FM Bandplan: %s", known_fm_band_plans[bandplan].name);
current_frequency = kf_get_min_frequency(BAND_FM);
snprintf(cmd,
sizeof(cmd),
@@ -159,7 +159,7 @@ static int kf_init(void)
current_frequency / 1000);
rc = system(cmd);
if(rc != 0) {
- AFB_ERROR("%s failed, rc = %d", SI_CTL, rc);
+ AFB_API_ERROR(afbBindingV3root, "%s failed, rc = %d", SI_CTL, rc);
return -1;
}
@@ -171,12 +171,12 @@ static int kf_init(void)
GST_PIPELINE_LEN,
"alsasrc device=hw:radio ! queue ! audioconvert ! audioresample ! pwaudiosink stream-properties=\"p,media.role=Multimedia\"");
if(rc >= GST_PIPELINE_LEN) {
- AFB_ERROR("pipeline string too long");
+ AFB_API_ERROR(afbBindingV3root, "pipeline string too long");
return -1;
}
pipeline = gst_parse_launch(gst_pipeline_str, NULL);
if(!pipeline) {
- AFB_ERROR("pipeline construction failed!");
+ AFB_API_ERROR(afbBindingV3root, "pipeline construction failed!");
return -1;
}
@@ -363,14 +363,14 @@ static void kf_scan_start(radio_scan_direction_t direction,
SI_CTL, direction == SCAN_FORWARD ? "up" : "down");
fp = popen(cmd, "r");
if(fp == NULL) {
- AFB_ERROR("Could not run: %s!", cmd);
+ AFB_API_ERROR(afbBindingV3root, "Could not run: %s!", cmd);
return;
}
// Look for "Frequency:" in output
while(fgets(line, SI_CTL_OUTPUT_MAXLEN, fp) != NULL) {
if(strncmp("Frequency:", line, 10) == 0) {
new_frequency = atoi(line + 10);
- //AFB_DEBUG("%s: got new_frequency = %d", __FUNCTION__, new_frequency);
+ //AFB_API_DEBUG(afbBindingV3root, "%s: got new_frequency = %d", __FUNCTION__, new_frequency);
break;
}
}
diff --git a/binding/radio_impl_rtlsdr.c b/binding/radio_impl_rtlsdr.c
index 044da0e..62ec623 100644
--- a/binding/radio_impl_rtlsdr.c
+++ b/binding/radio_impl_rtlsdr.c
@@ -178,7 +178,7 @@ static int rtlsdr_init(void)
if(!helper_path)
return -ENOMEM;
if(snprintf(helper_path, HELPER_MAX, "%s/bin/%s --detect", rootdir, HELPER_NAME) == HELPER_MAX) {
- AFB_ERROR("Could not create command for \"%s --detect\"", HELPER_NAME);
+ AFB_API_ERROR(afbBindingV3root, "Could not create command for \"%s --detect\"", HELPER_NAME);
return -EINVAL;
}
if(system(helper_path) != 0) {
@@ -316,7 +316,7 @@ static int rtlsdr_start_helper(void)
if(helper_output) {
// Indicate desired output to helper
- AFB_INFO("Setting RADIO_OUTPUT=%s", helper_output);
+ AFB_API_INFO(afbBindingV3root, "Setting RADIO_OUTPUT=%s", helper_output);
setenv("RADIO_OUTPUT", helper_output, 1);
}
@@ -325,15 +325,15 @@ static int rtlsdr_start_helper(void)
if(!helper_path)
return -ENOMEM;
if(snprintf(helper_path, PATH_MAX, "%s/bin/%s", rootdir, HELPER_NAME) == PATH_MAX) {
- AFB_ERROR("Could not create path to %s", HELPER_NAME);
+ AFB_API_ERROR(afbBindingV3root, "Could not create path to %s", HELPER_NAME);
return -EINVAL;
}
helper_pid = popen2(helper_path, &helper_out, &helper_in);
if(helper_pid < 0) {
- AFB_ERROR("Could not run %s!", HELPER_NAME);
+ AFB_API_ERROR(afbBindingV3root, "Could not run %s!", HELPER_NAME);
return -1;
}
- AFB_DEBUG("%s started", HELPER_NAME);
+ AFB_API_DEBUG(afbBindingV3root, "%s started", HELPER_NAME);
helper_started = true;
free(helper_path);
@@ -359,7 +359,7 @@ static void rtlsdr_start(void)
rc = write(helper_in, cmd, strlen(cmd));
pthread_mutex_unlock(&helper_mutex);
if (rc < 0) {
- AFB_ERROR("Failed to ask \"%s\" to start", HELPER_NAME);
+ AFB_API_ERROR(afbBindingV3root, "Failed to ask \"%s\" to start", HELPER_NAME);
return;
}
active = true;
@@ -381,7 +381,7 @@ static void rtlsdr_stop(void)
rc = write(helper_in, cmd, strlen(cmd));
pthread_mutex_unlock(&helper_mutex);
if (rc < 0) {
- AFB_ERROR("Failed to ask \"%s\" to stop", HELPER_NAME);
+ AFB_API_ERROR(afbBindingV3root, "Failed to ask \"%s\" to stop", HELPER_NAME);
return;
}
active = false;
@@ -454,7 +454,7 @@ static void rtlsdr_scan_stop(void)
rc = write(helper_in, cmd, strlen(cmd));
pthread_mutex_unlock(&helper_mutex);
if (rc < 0)
- AFB_ERROR("Failed to ask \"%s\" to stop scan", HELPER_NAME);
+ AFB_API_ERROR(afbBindingV3root, "Failed to ask \"%s\" to stop scan", HELPER_NAME);
}
static radio_stereo_mode_t rtlsdr_get_stereo_mode(void)