3rd Party Modules

Starting on Movesense device lib v1.7.0 the framework supports concept of 3rd party modules. The modules are (at the moment) source code only packages that can be easily incorporated into any application. This document describes the structure of the module folder as well as what must done in an app to use a 3rd party module.

Module structure

The structure of a 3rd party module is basically same as a movesense sensor application minus the CMakeLists.txt-file. It contains wbresources-subfolder with an empty .cpp file and any API definitions (.yaml -files) as well as C/C++ files (.c, .cpp, .h, .hpp) in the main module folder:

<module_dir> + wbresources
             +-+- some_service.yaml
               +- resources.cpp (empty)
             +-  ModuleFile1.h
             +-  ModuleFile1.cpp
             +-  ModuleFile2.h
             +-  ModuleFile2.cpp

The new build system finds all API definitions in wbresources and compiles them to resources, and all source files from the module folder and includes them into the build.

Using a Module

To add a 3rd party module in your sensor application you need to:

1. Include module folder into the cmake of your application:

You can do that either from command line when calling cmake:

cmake.exe ... -DMOVESENSE_MODULES=<path_to_module_folder> ...

or add them to the CMakeLists.txt file of your application:

# Create a list with all the modules
if(NOT DEFINED MOVESENSE_MODULES)
    list(APPEND MOVESENSE_MODULES ${CMAKE_CURRENT_LIST_DIR}/<path_to_module1_folder>)
    list(APPEND MOVESENSE_MODULES ${CMAKE_CURRENT_LIST_DIR}/<path_to_module2_folder>)
endif()

2. Include the needed .h-files in the .cpp-files of your application:

If the module contains a service (or other LaunchableModule) you need to include the .h-file of the LaunchableModule in the App.cpp file. If the module contains plain C/C++ code just include them in source files where you need.

3. Add the LaunchableModule(s) to the MOVESENSE_PROVIDERS_BEGIN/MOVESENSE_PROVIDERS_END block in App.cpp -file:

MOVESENSE_PROVIDERS_BEGIN(2)

MOVESENSE_PROVIDER_DEF(MyAppService)
MOVESENSE_PROVIDER_DEF(ExternalModuleClass)

MOVESENSE_PROVIDERS_END(2)

NOTE: Do not forget to increment the number in _BEGIN / _END macros to match the count!