This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC26XX BLE V2.1 and C++ ?

Other Parts Discussed in Thread: SYSBIOS

Is it possible to use C++ instead of C with IAR and compiling the BLE v2.1 application project?

My thought is, for example with simpleBLEcentral -> the main.c and simpleBLEcentral.c can be converted to c++ code and the library/stack/profiles/etc can remain in c code (e.g. with extern C directives).

I did see one other post on the forum referring to BLE 1.4 stack using Clib and C++ requiring Dlib (which required some modifications). Is this still the case?

thanks

  • Hi CM2015,

    We don't officially support C++ on the CC26xx. 
     

    It may be possible to get it working, using the method you described above. Our 1.4 stack is for the cc254x device which is 8051 based with no RTOS where the v2.1 stack is ARM based with a TI RTOS image included, so anything related to BLE v1.4 isn't really related.

    What is your use-case such that C++ is necessary?

  • Hi Sean,

    Mainly for code compatibility and porting of previous code. I attempted the method I described and it seems like it should work (despite some incompatible type errors which is to be expected since I did not modify the c code to c++).

    Although it is not officially supported, I do see that all of your header files have the necessary
    #ifdef __cplusplus
    extern "C"
    {
    #endif

    If you know of any potential problems I might run into though please let me know.

    Thanks!
  • As long as you can interface to the RTOS and stack images appropriately with your C++ code, you should be okay. There are no red flags that I know of.

    Feel free to post if you have issues, and we'll try to help. If you are successful, also please consider posting for other users benefit.
  • I was indeed successful in my plan, The steps were as follows :
    1) changed simpleBLEcentral.c to simpleBLEcentral.cpp, changed main.c to main.cpp.
    2) changed c/c++ project compile settings to 'extension based'.
    3) In simpleBLEcentral.cpp changed Semaphore_post(sem); calls to Semaphore_post((ti_sysbios_knl_Semaphore_Object*)sem);
    Also changed req.pValue = GATT_bm_alloc(.... to req.pValue = (unsigned char *)GATT_bm_alloc(....
    Also changed sbcEvt_t *pMsg = ICall_malloc(.. to sbcEvt_t *pMsg = (sbcEvt_t*)ICall_malloc(...