Problems with BLE Mesh in a C++ project.

I am using NCS Connect SDK version 2.6.0

I am trying to create an array of models and found a problem with using Zephry macros in C++ projects. My main.cpp is as below

BT_MESH_MODEL_CFG_SRV is defined in cfg_srv.h as

BT_MESH_MODEL_CNT_CB is defined in access.h

Which is where the problem lies. The macro is defined for C language only and cannot be used with a C++ compiler as it uses compound literals.

Does anyone have any suggestion to resolve this impase

Appreciate any suggestions.

Thanks

Parents Reply Children
  • Adding some extra comment for clearity:

    Yes it is only supported in C. The suggestion for anyone who wants to use .cpp is to create a .c file where they instantiate composition data and expose pointer to that composition data through a header file. Then use this pointer in main.cpp. Or, simpler, move the entire mesh initialization to a .c file and call some init function from main.cpp.

  • Thanks Jonathan
    Appreciate the response.