我对Arduino 101上的BLE外设有以下疑问:
当前观察:我只能使用API setAdvertisedServiceUuid和setLocalName来宣传服务uuids和本地名称。
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
答案 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