This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Please fix the enum in ble_gatts.h

When compiling C++ code that includes ble_gatts.h you get errors like the following:

C:/....../nrf51822/Include/s110/nrf_svc.h:21:6: error: impossible constraint in 'asm' );
^

With C code it is fine. The error is that an enum is used rather than #define's for the SD_BLE_GATTS constants. When you change the enum to #define's it works fine.

See this question where I found the solution: stackoverflow.com/.../using-c-headers-in-c-code-in-gnu-error-including-inline-assembly-impossible

Please can you fix it? (And I guess there may be similar enum issues elsewhere.)

Here is the code that works:


/**
 * @brief GATTS API SVC numbers.
 */
#define SD_BLE_GATTS_SERVICE_ADD         (BLE_GATTS_SVC_BASE+0)     /**< Add a service. */
#define SD_BLE_GATTS_INCLUDE_ADD         (BLE_GATTS_SVC_BASE+1)     /**< Add an included service. */
#define SD_BLE_GATTS_CHARACTERISTIC_ADD  (BLE_GATTS_SVC_BASE+2)     /**< Add a characteristic. */
#define SD_BLE_GATTS_DESCRIPTOR_ADD      (BLE_GATTS_SVC_BASE+3)     /**< Add a generic attribute. */
#define SD_BLE_GATTS_VALUE_SET           (BLE_GATTS_SVC_BASE+4)     /**< Set an attribute value. */
#define SD_BLE_GATTS_VALUE_GET           (BLE_GATTS_SVC_BASE+5)     /**< Get an attribute value. */
#define SD_BLE_GATTS_HVX                 (BLE_GATTS_SVC_BASE+6)     /**< Handle Value Notification or Indication. */
#define SD_BLE_GATTS_SERVICE_CHANGED     (BLE_GATTS_SVC_BASE+7)     /**< Perform a Service Changed Indication to one or more peers. */
#define SD_BLE_GATTS_RW_AUTHORIZE_REPLY  (BLE_GATTS_SVC_BASE+8)     /**< Reply to an authorization request for a read or write operation on one or more attributes. */
#define SD_BLE_GATTS_SYS_ATTR_SET        (BLE_GATTS_SVC_BASE+9)     /**< Set the persistent system attributes for a connection. */
#define SD_BLE_GATTS_SYS_ATTR_GET        (BLE_GATTS_SVC_BASE+10)    /**< Get updated persistent system attributes after terminating a connection. */

Related