【问题标题】:Arduino 101 - BLE Queries: Characteristics and AdvertisementArduino 101 - BLE 查询:特性和广告
【发布时间】:2016-01-04 19:57:21
【问题描述】:

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

  1. 可以在广告数据包中发布任何特征值(动态数据)而不是 UUID。如果是这样,那么 API 是什么?我的目标是获取 adv 数据包中的任何温度数据,而不是连接到外围设备。

当前观察:我只能使用 API setAdvertisedServiceUuid 和 setLocalName 来宣传服务 uuid 和本地名称。

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);
}

任何帮助将不胜感激。

谢谢。 斯沃鲁普

【问题讨论】:

    标签: arduino bluetooth-lowenergy


    【解决方案1】:
    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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-06
      相关资源
      最近更新 更多