aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/radio/radio-api.c
diff options
context:
space:
mode:
authorManuel Bachmann <manuel.bachmann@iot.bzh>2015-12-20 23:00:56 +0100
committerManuel Bachmann <manuel.bachmann@iot.bzh>2015-12-20 23:00:56 +0100
commit0d170147150b90678225b55548215d09d8273e6d (patch)
tree8f29a1fd6cdc1e594b88398af4f0c70f9a3a9010 /plugins/radio/radio-api.c
parent61354a55ac2abd9e83e1f869cdb735654d6eb74a (diff)
Fix frequency setting bug in Radio API
Passing floats between functions seems to cause problems... not sure why ; anyway, fix this by using a double variable. Signed-off-by: Manuel Bachmann <manuel.bachmann@iot.bzh>
Diffstat (limited to 'plugins/radio/radio-api.c')
-rw-r--r--plugins/radio/radio-api.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/plugins/radio/radio-api.c b/plugins/radio/radio-api.c
index 3048f7b3..3de8e044 100644
--- a/plugins/radio/radio-api.c
+++ b/plugins/radio/radio-api.c
@@ -219,6 +219,7 @@ STATIC json_object* freq (AFB_request *request) { /* AFB_SESSION_CHECK */
radioCtxHandleT *ctx = (radioCtxHandleT*)request->client->ctx;
const char *value = getQueryValue (request, "value");
json_object *jresp = json_object_new_object();
+ double freq;
char freq_str[256];
/* no "?value=" parameter : return current state */
@@ -229,8 +230,9 @@ STATIC json_object* freq (AFB_request *request) { /* AFB_SESSION_CHECK */
/* "?value=" parameter, set frequency */
else {
- ctx->freq = strtof (value, NULL);
- _radio_set_freq (ctx->idx, ctx->freq);
+ freq = strtod (value, NULL);
+ _radio_set_freq (ctx->idx, freq);
+ ctx->freq = (float)freq;
snprintf (freq_str, sizeof(freq_str), "%f", ctx->freq);
json_object_object_add (jresp, "freq", json_object_new_string (freq_str));