Add get() and list() API
[apps/agl-service-can-low-level.git] / low-can-binding / binding / low-can-hat.cpp
index 7113b69..2b5baa3 100644 (file)
@@ -32,16 +32,40 @@ extern "C"
 {
        static int initv2();
 
+       static constexpr struct afb_auth loa_afb_auth(const unsigned loa)
+       {
+               struct afb_auth a = {};
+               a.type = afb_auth_LOA;
+               a.loa = loa;
+               return a;
+       }
+
+       static constexpr struct afb_auth perm_afb_auth(const char* permission)
+       {
+               struct afb_auth a = {};
+               a.type = afb_auth_Permission;
+               a.text = permission;
+               return a;
+       }
+
+       static const struct afb_auth afb_auth_loa_1 = { loa_afb_auth(1) };
+       static const struct afb_auth afb_auth_perm = { perm_afb_auth("urn:AGL:permission::platform:can:write") };
+
        static const struct afb_verb_v2 verbs[]=
        {
-               { .verb= "subscribe", .callback= subscribe, .auth= NULL, .session= AFB_SESSION_NONE},
-               { .verb= "unsubscribe", .callback= unsubscribe, .auth= NULL, .session= AFB_SESSION_NONE},
-               { .verb= NULL, .callback= NULL, .auth= NULL, .session= 0}
+               { .verb= "auth", .callback= auth, .auth= &afb_auth_perm, .info="Authentification against service to get the required level of confidence", .session= AFB_SESSION_NONE},
+               { .verb= "subscribe", .callback= subscribe, .auth= NULL, .info="Let subscribe to signals", .session= AFB_SESSION_NONE},
+               { .verb= "unsubscribe", .callback= unsubscribe, .auth= NULL, .info="Let unsubscribe signals", .session= AFB_SESSION_NONE},
+               { .verb= "write", .callback= write, .auth= &afb_auth_loa_1, .info="Write a single CAN message on a CAN bus", .session= AFB_SESSION_LOA_1},
+               { .verb= "get", .callback= get, .auth=NULL, .info="get a current value of CAN message", .session= AFB_SESSION_NONE},
+               { .verb= "list",.callback= list, .auth=NULL, .info="get a supported CAN message list", .session= AFB_SESSION_NONE},
+               { .verb= NULL, .callback= NULL, .auth= NULL, .info=NULL, .session= 0}
        };
 
        const struct afb_binding_v2 afbBindingV2 {
                .api = "low-can",
                .specification = NULL,
+               .info = "API to Low level CAN service, read and decode the bus",
                .verbs = verbs,
                .preinit = NULL,
                .init = initv2,
@@ -67,7 +91,7 @@ extern "C"
                if(application_t::instance().get_diagnostic_manager().initialize())
                        return 0;
 
-               ERROR("There was something wrong with CAN device Initialization.");
+               AFB_ERROR("There was something wrong with CAN device Initialization.");
                return 1;
        }
 };