(1) I am using GNU C++ to develop my application with nRF5 SDK. I found the STATIC_ASSERT_SIMPLE and STATIC_ASSERT_MSG macros defined in app_util.h are not working with C++. The followings are suggested to be added in the next SDK release.
#ifdef __GNUC__ #ifdef __cplusplus #define STATIC_ASSERT_SIMPLE(EXPR) static_assert(EXPR, "unspecified message") #define STATIC_ASSERT_MSG(EXPR, MSG) static_assert(EXPR, MSG) #else #define STATIC_ASSERT_SIMPLE(EXPR) _Static_assert(EXPR, "unspecified message") #define STATIC_ASSERT_MSG(EXPR, MSG) _Static_assert(EXPR, MSG) #endif #endif
The best way is to remove all ASSERT and STATIC_ASSERT usages in SDK. This is because RTOS (and other frameworks) has already provided these definitions. So, there will be "redefinition error" during compilation.
From the viewpoint of application, BLE is only a component (sub-system) used for communication. But current nRF5 SDK treats itself as the whole application, not sub-system. So, it defines/implements a lot of things which should be better to be handled independently. This does make trouble when integrating the SDK to bigger systems.
With nRF52840, we can implement bigger and complicated application. At the same time, it would be better to use RTOS and C++ to simplify the software structure. For example, I have defined a Serial Port Service (SPS) class with four virtual functions:
virtual void onCommStarted() {}; // Notification has been enabled virtual void onCommStopped() {}; // Notification has been disabled virtual void onRxDataReady(const uint8_t* data, int length) {}; // New data received virtual void onTxDataEmpty() {}; // Service is ready to accept new data to be transmitted
In application level, we can derive the class and override these virtual functions to provide certain functionalities. This will make the software structure more clear and easier to maintain. The SDK is very matured now. I think it is time to consider C++ integration.
(2) In app_timer.h, the following conditional compilation code allows only either none-RTOS or FreeRTOS. But I amy using other RTOS and the whole code segment must be disabled. It would be better to have another definition to disable it.
#ifndef FREERTOS #define APP_TIMER_TICKS(MS) \ ((uint32_t)ROUNDED_DIV( \ (MS) * (uint64_t)APP_TIMER_CLOCK_FREQ, \ 1000 * (APP_TIMER_CONFIG_RTC_FREQUENCY + 1))) #else #include "FreeRTOSConfig.h" #define APP_TIMER_TICKS(MS) (uint32_t)ROUNDED_DIV((MS)*configTICK_RATE_HZ,1000) #endif