summaryrefslogtreecommitdiffstats
path: root/plugins/radio
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-03-30 13:55:50 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2016-03-30 13:55:50 +0200
commitca208671cc79bbc05c574df788035878e5d39382 (patch)
treef5a61c22b3d650e20b21295706320602da1f3d19 /plugins/radio
parent8ca3d16606a99ef91d01a623dbe5ce1331688953 (diff)
refactoring
Change-Id: I8dd46cf7fa57962e20e02f0fe34b3ffaa4c94f08 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'plugins/radio')
-rw-r--r--plugins/radio/radio-api.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/plugins/radio/radio-api.c b/plugins/radio/radio-api.c
index ea17eb51..bdb1768f 100644
--- a/plugins/radio/radio-api.c
+++ b/plugins/radio/radio-api.c
@@ -26,6 +26,8 @@
/* ------ LOCAL HELPER FUNCTIONS --------- */
+static pluginHandleT *the_radio = NULL;
+
/* detect new radio devices */
STATIC void updateRadioDevList(pluginHandleT *handle) {
@@ -116,9 +118,9 @@ STATIC AFB_error releaseRadio (pluginHandleT *handle, radioCtxHandleT *ctx) {
}
/* called when client session dies [e.g. client quits for more than 15mns] */
-STATIC void freeRadio (void *context, void *handle) {
+STATIC void freeRadio (void *context) {
- releaseRadio (handle, context);
+ releaseRadio (the_radio, context);
free (context);
}
@@ -140,7 +142,7 @@ STATIC json_object* init (AFB_request *request) { /* AFB_SESSION_CHECK */
STATIC json_object* power (AFB_request *request) { /* AFB_SESSION_CHECK */
- pluginHandleT *handle = (pluginHandleT*)request->handle;
+ pluginHandleT *handle = the_radio;
radioCtxHandleT *ctx = (radioCtxHandleT*)request->context;
const char *value = getQueryValue (request, "value");
json_object *jresp;
@@ -325,8 +327,8 @@ PUBLIC AFB_plugin* pluginRegister () {
plugin->prefix = "radio";
plugin->apis = pluginApis;
- plugin->handle = initRadioPlugin();
plugin->freeCtxCB = (AFB_freeCtxCB)freeRadio;
- return (plugin);
+ radio = initRadioPlugin();
+ return plugin;
};