diff options
author | 2017-06-12 09:36:17 +0200 | |
---|---|---|
committer | 2017-06-12 09:36:17 +0200 | |
commit | 4788a840abe82f2c0f20b027589085d29051763c (patch) | |
tree | d33ff23a53b548287dfb7c34a4c678375f07fa22 /high-can-binding/high-can-binding-hat.cpp | |
parent | 96c638490f1e8a871c3072ae3dfab2b1e7a02b7f (diff) |
Migration to binding v2
Change-Id: I05e93ff74db3f9e7b31a7348ea0fa23d16b737c7
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'high-can-binding/high-can-binding-hat.cpp')
-rw-r--r-- | high-can-binding/high-can-binding-hat.cpp | 54 |
1 files changed, 21 insertions, 33 deletions
diff --git a/high-can-binding/high-can-binding-hat.cpp b/high-can-binding/high-can-binding-hat.cpp index 01f6ab1..0bf7090 100644 --- a/high-can-binding/high-can-binding-hat.cpp +++ b/high-can-binding/high-can-binding-hat.cpp @@ -1,47 +1,35 @@ #include "high-can-binding-hat.hpp" #include <cstddef> /// Interface between the daemon and the binding -const struct afb_binding_interface *binder_interface; -extern "C" -{ - #include <afb/afb-service-itf.h> - struct afb_service srvitf; -}; -static const struct afb_verb_desc_v1 verbs[]= + +static int init_service(); + +static const struct afb_verb_v2 verbs[]= { - { .name= "subscribe", .session= AFB_SESSION_NONE, .callback= subscribe, .info= "subscribe to notification of CAN bus messages." }, - { .name= "unsubscribe", .session= AFB_SESSION_NONE, .callback= unsubscribe, .info= "unsubscribe a previous subscription." }, - { .name= "get", .session= AFB_SESSION_NONE, .callback= get, .info= "high can get viwi request." }, + { .verb= "subscribe", .callback= subscribe, .auth = NULL, .session = 0 }, + { .verb= "unsubscribe", .callback= unsubscribe, .auth = NULL, .session = 0 }, + { .verb= "get", .callback= get, .auth = NULL, .session = 0 }, + { .verb= NULL, .callback=NULL, .auth = NULL, .session = 0 } }; -static const struct afb_binding binding_desc { - AFB_BINDING_VERSION_1, - { - "High level CAN bus service", - "high-can", - verbs - } +const struct afb_binding_v2 afbBindingV2 = { + .api = "high-can", + .specification = "", + .verbs = verbs, + .preinit = NULL, + .init = init_service, + .onevent = onEvent, + .noconcurrency = 1 }; -const struct afb_binding *afbBindingV1Register (const struct afb_binding_interface *itf) -{ - binder_interface = itf; - NOTICE(binder_interface, "high level afbBindingV1Register"); - - return &binding_desc; -} /// @brief Initialize the binding. /// -/// @param[in] service Structure which represent the Application Framework Binder. -/// /// @return Exit code, zero if success. -int afbBindingV1ServiceInit(struct afb_service service) +int init_service() { - srvitf = service; - //NOTICE(binder_interface, "before afb_daemon_require_api"); - //afb_daemon_require_api(binder_interface->daemon, "low-can", 1); - NOTICE(binder_interface, "high level binding is initializing"); - initHigh(service); - NOTICE(binder_interface, "high level binding is initialized and running"); + NOTICE("high level binding is initializing"); + afb_daemon_require_api("low-can", 1); + initHigh(); + NOTICE("high level binding is initialized and running"); return 0; } |