ArduinoCore-arc32 icon indicating copy to clipboard operation
ArduinoCore-arc32 copied to clipboard

Peripheral not connectable when broadcasting characteristic value

Open don opened this issue 7 years ago • 0 comments

Issue #420 added support for broadcasting a characteristic value. This works now, however I'm not able to connect to the peripheral. (Sample code below.)

nRF Connect (Samsung S8 with Android 7.0) has a connect button but the connection always fails. nRF Connect (iPhone 7 with iOS 11.2.5) reports the peripheral is not connectable.

not-connectable

// Broadcast Characteristic Value
// Simple counter that broadcasts a value

#ifdef ARDUINO_ARCH_ARC32 // Arduino 101
  #include <CurieBLE.h>
#else
  #include <BLEPeripheral.h>
#endif

uint8_t value = 0;

BLEPeripheral peripheral;
BLEService service = BLEService("EEE0");
BLEShortCharacteristic characteristic = BLEShortCharacteristic("EEE1", BLERead | BLENotify | BLEBroadcast);

void setup() {
  Serial.begin(9600);

  peripheral.setLocalName("BLEBroadcast");
  peripheral.setAdvertisedServiceUuid(service.uuid());

  peripheral.addAttribute(service);
  peripheral.addAttribute(characteristic);

  characteristic.setValue(value);

  peripheral.begin();
  characteristic.broadcast();

  Serial.println(F("BLE Broadcast Count"));
}

void loop() {
    peripheral.poll();
    characteristic.setValue(value);    
    delay(1000);
    value++;
}

https://gist.github.com/don/536d9f1d605d9bfffcd99b5716a72cb4

I see similar behavior with the version 2 of the API https://gist.github.com/don/aa2d924e0214b8b43e10a8e0ddd4243d

don avatar Jan 26 '18 06:01 don