Arduino 101 - BLE查询:特征和广告

时间:2016-01-04 19:57:21

标签: arduino bluetooth-lowenergy

我对Arduino 101上的BLE外设有以下疑问:

  1. 可以在广告包中通告任何特征值(动态数据)而不是UUID。如果是这样的API是什么?我的目标是在adv数据包中获取任何温度数据,而不是连接到外设。
  2. 当前观察:我只能使用API​​ setAdvertisedServiceUuid和setLocalName来宣传服务uuid​​s和本地名称。

    2.在下面的代码中,我能够在第一个实例中启动并捕获广告,但在字母实例中,begin具有错误的返回值。我做错了吗?我们的想法是开始和停止广告,甚至可能更改广告数据。

    #include <CurieBle.h>
    
    
    void setup() {  
        // set LED pin to output mode
        pinMode(ledPin, OUTPUT);
        Serial.begin(9600); 
    }
    
    void loop() {  
        //BLE Peripheral
        BLEPeripheral * blePeripheral = new BLEPeripheral; 
    
        //Set the Local Name
        blePeripheral->setLocalName("MyDevice");
    
        //Start Advertising
        blePeripheral->begin();
    
        //Run the advertisement for 20 seconds
        delay(20000);
    
        //Stop the advertisement
        blePeripheral->end();
    
        //Delete the BLE Peripheral
        delete blePeripheral;
    
        //Wait 5 seconds before starting the next adv
        delay(5000);
    }
    

    任何帮助将不胜感激。

    感谢。 Swaroop

1 个答案:

答案 0 :(得分:0)

BLEPeripheral blePeripheral;  // BLE Peripheral Device (the board you're programming)
BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // BLE LED Service

// BLE LED Switch Characteristic - custom 128-bit UUID, read and writable by central
BLEUnsignedCharCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);

https://www.arduino.cc/en/Reference/BLEPeripheralConstructor