在 C++ 中为 CurieBLE 导致非常量绑定错误的 Arduino 代码

Arduino code that causes a Non-const binding error in c++ for CurieBLE

为了将 xcode 用作我的 IDE,我试图将 BLE 示例代码从 .ino 移植到 .cpp 。习惯了ino和cpp语言之间的微小变化,却猝不及防的报错了,如下。我正在使用 core-libs101 库的主分支,我已将其链接到我的 xcode cpp 项目。

在 Arduino LEDExample 草图中,以下程序有效: (此处可用:https://github.com/01org/corelibs-arduino101/blob/master/libraries/CurieBLE/examples/peripheral/led/led.ino

BLEService ledService(...);
BLECharCharacteristic switchChar(...);

...
ledService.addCharacteristic(switchChar);

但是,当我在 .cpp 中尝试同样的操作时,出现 "non-const lvalue reference to type 'BLECharacteristic' cannot bind to a value of unrelated type 'BLECharacteristic' " 编译错误。当我将 BLECharCharacteristic 的类型更改为 BLECharacteristic,并保持其他一切不变时,没有编译错误。

例如: //.cpp代码

#include "CurieBLE.h"

BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214");
BLECharCharacteristic myFailedChar("19B10001-E8F2-537E-4F6C-D104768A1214");
BLECharacteristic myWorkingChar("19B10002-E8F2-537E-4F6C-D104768A1214");

int main(int argc, const char * argv[]) {

    //throws compile error: non-const lvalue reference to type 'BLECharacteristic' cannot bind to a value of unrelated type 'BLECharacteristic'
    ledService.addCharacteristic(myFailedChar);

    //Does not throw compile error.
    ledService.addCharacteristic(myWorkingChar);

    return 0
}

与嵌入式 C++ 相比,我更喜欢嵌入式 C,所以这可能是一个业余错误,但我无法理解它。任何帮助将不胜感激!

CurieBLE 示例是为 Arduino 编写的,使用的 c++ 代码与 Arduino 环境高度耦合,请不要费心尝试移植。