Use afb_genskel tools to generate api definition
[apps/agl-service-can-low-level.git] / low-can-binding / binding / low-can-cb.cpp
index e84a9c7..3145065 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include "low-can-hat.hpp"
+#include "low-can-apidef.h"
 
 #include <map>
 #include <queue>
@@ -36,7 +37,6 @@
 #include "../diagnostic/diagnostic-message.hpp"
 #include "../utils/openxc-utils.hpp"
 
-
 ///******************************************************************************
 ///
 ///            SystemD event loop Callbacks
@@ -632,3 +632,25 @@ void list(struct afb_req request)
        else
                afb_req_fail(request, "error", NULL);
 }
+
+/// @brief Initialize the binding.
+///
+/// @param[in] service Structure which represent the Application Framework Binder.
+///
+/// @return Exit code, zero if success.
+int initv2()
+{
+       can_bus_t& can_bus_manager = application_t::instance().get_can_bus_manager();
+
+       can_bus_manager.set_can_devices();
+       can_bus_manager.start_threads();
+
+       /// Initialize Diagnostic manager that will handle obd2 requests.
+       /// We pass by default the first CAN bus device to its Initialization.
+       /// TODO: be able to choose the CAN bus device that will be use as Diagnostic bus.
+       if(application_t::instance().get_diagnostic_manager().initialize())
+               return 0;
+
+       AFB_ERROR("There was something wrong with CAN device Initialization.");
+       return 1;
+}