diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2019-01-04 14:24:11 +0100 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2019-01-04 14:37:24 +0100 |
commit | aba89b590ef0d1743dd0aa82a8b8ed1bf8809909 (patch) | |
tree | c29aa2571f0d315ccf14616828ac2fb39275f6ae | |
parent | a1976ff1b2bccc8689182505828f7e3814d0d21b (diff) |
Little code cleaning.
Rename apiHandle to api.
Add a missing parameter to QAfbWebsocketClient::call function
comment.
Change-Id: I6fb1acd7357fbea3132cd429e9477a1a0b8a4f43
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r-- | afb-timer.c | 21 | ||||
-rw-r--r-- | afb-timer.h | 6 | ||||
-rw-r--r-- | curl-wrap.h | 3 | ||||
-rw-r--r-- | filescan-utils.h | 6 | ||||
-rw-r--r-- | qafbwebsocketclient.cpp | 1 |
5 files changed, 12 insertions, 25 deletions
diff --git a/afb-timer.c b/afb-timer.c index 30ab80d..b302278 100644 --- a/afb-timer.c +++ b/afb-timer.c @@ -66,32 +66,23 @@ void TimerEvtStop(TimerHandleT *timerHandle) { free (timerHandle); } - -void TimerEvtStart(afb_api_t apiHandle, TimerHandleT *timerHandle, timerCallbackT callback, void *context) { +void TimerEvtStart(afb_api_t api, TimerHandleT *timerHandle, timerCallbackT callback, void *context) { uint64_t usec; // populate CB handle timerHandle->callback=callback; timerHandle->context=context; - timerHandle->api=apiHandle; + timerHandle->api=api; // set a timer with ~250us accuracy - sd_event_now(afb_api_get_event_loop(apiHandle), CLOCK_MONOTONIC, &usec); - sd_event_add_time(afb_api_get_event_loop(apiHandle), &timerHandle->evtSource, CLOCK_MONOTONIC, usec+timerHandle->delay*1000, 250, TimerNext, timerHandle); -} - - -// Create Binding Event at Init -int TimerEvtInit (afb_api_t apiHandle) { - - AFB_API_DEBUG (apiHandle, "Timer-Init Done"); - return 0; + sd_event_now(afb_api_get_event_loop(api), CLOCK_MONOTONIC, &usec); + sd_event_add_time(afb_api_get_event_loop(api), &timerHandle->evtSource, CLOCK_MONOTONIC, usec+timerHandle->delay*1000, 250, TimerNext, timerHandle); } -uint64_t LockWait(afb_api_t apiHandle, uint64_t utimeout) { +uint64_t LockWait(afb_api_t api, uint64_t utimeout) { uint64_t current_usec, pre_usec; - struct sd_event *event = afb_api_get_event_loop(apiHandle); + struct sd_event *event = afb_api_get_event_loop(api); sd_event_now(event, CLOCK_MONOTONIC, &pre_usec); sd_event_run(event, utimeout); diff --git a/afb-timer.h b/afb-timer.h index 5050436..1d1ebb7 100644 --- a/afb-timer.h +++ b/afb-timer.h @@ -30,7 +30,6 @@ extern "C" { // ---------------------- typedef struct TimerHandleS { - int magic; int count; int delay; const char*uid; @@ -43,11 +42,10 @@ typedef struct TimerHandleS { typedef int (*timerCallbackT)(TimerHandleT *context); -extern int TimerEvtInit (afb_api_t apiHandle); -extern void TimerEvtStart(afb_api_t apiHandle, TimerHandleT *timerHandle, timerCallbackT callback, void *context); +extern void TimerEvtStart(afb_api_t api, TimerHandleT *timerHandle, timerCallbackT callback, void *context); extern void TimerEvtStop(TimerHandleT *timerHandle); -extern uint64_t LockWait(afb_api_t apiHandle, uint64_t utimeout); +extern uint64_t LockWait(afb_api_t api, uint64_t utimeout); #ifdef __cplusplus } #endif diff --git a/curl-wrap.h b/curl-wrap.h index ab91bca..26fe210 100644 --- a/curl-wrap.h +++ b/curl-wrap.h @@ -20,9 +20,6 @@ #include <curl/curl.h> -extern char *curl_wrap_url (const char *base, const char *path, - const char *const *query, size_t * size); - extern int curl_wrap_perform (CURL * curl, char **result, size_t * size); extern void curl_wrap_do(CURL *curl, void (*callback)(void *closure, int status, CURL *curl, const char *result, size_t size), void *closure); diff --git a/filescan-utils.h b/filescan-utils.h index a74dcb3..d6c645f 100644 --- a/filescan-utils.h +++ b/filescan-utils.h @@ -95,12 +95,12 @@ static inline char *GetBindingDirPath_v2() __attribute__((alias("GetBindingDirPath_v2"))) static char *GetBindingDirPath(); #else -static char *GetBindingDirPath_v3(struct afb_api_x3* apiHandle) +static char *GetBindingDirPath_v3(struct afb_api_x3* api) { - return GetBindingDirPath_(afb_api_x3_rootdir_get_fd(apiHandle)); + return GetBindingDirPath_(afb_api_x3_rootdir_get_fd(api)); } __attribute__((alias("GetBindingDirPath_v3"))) -static char *GetBindingDirPath(struct afb_api_x3* apiHandle); +static char *GetBindingDirPath(struct afb_api_x3* api); #endif /** diff --git a/qafbwebsocketclient.cpp b/qafbwebsocketclient.cpp index f0f3dce..0cbc274 100644 --- a/qafbwebsocketclient.cpp +++ b/qafbwebsocketclient.cpp @@ -81,6 +81,7 @@ void QAfbWebsocketClient::close() * \param api Api to call. * \param verb Verb to call. * \param arg Argument to pass. + * \param closure callback to call at the verb reply */ void QAfbWebsocketClient::call(const QString& api, const QString& verb, const QJsonValue& arg, closure_t closure) { |