Skip to content

Jira 913 BLESubscribed, BLEUnsubscribed Event Handlers are not called #531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vshymanskyy opened this issue Apr 12, 2017 · 15 comments
Open

Comments

@vshymanskyy
Copy link

vshymanskyy commented Apr 12, 2017

For example, in following scenario (Nordic UART Service implementation):

#include <CurieBLE.h>

BLEService        NUS    ("713D0000-503E-4C75-BA94-3148F18D941E");
BLECharacteristic rxChar ("713D0003-503E-4C75-BA94-3148F18D941E", BLEWrite | BLEWriteWithoutResponse, BLE_MAX_ATTR_DATA_LEN);
BLECharacteristic txChar ("713D0002-503E-4C75-BA94-3148F18D941E", BLERead  | BLENotify,               BLE_MAX_ATTR_DATA_LEN);

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

  // begin initialization
  BLE.begin();

  // set the local name peripheral advertises
  BLE.setLocalName("NUS test");

  BLE.setAdvertisedService(NUS);

  // add the characteristic to the service
  NUS.addCharacteristic(rxChar);
  NUS.addCharacteristic(txChar);

  // add service
  BLE.addService(NUS);

  // assign event handlers for connected, disconnected to peripheral
  BLE.setEventHandler(BLEConnected, blePeripheralConnectHandler);
  BLE.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler);

  // assign event handlers for characteristics
  rxChar.setEventHandler(BLEWritten,      rxCharWritten);
  txChar.setEventHandler(BLESubscribed,   txCharSubscribed);
  txChar.setEventHandler(BLEUnsubscribed, txCharUnsubscribed);

  // set an initial value for characteristics
  unsigned char empty[0] = {};
  rxChar.setValue(empty, 0);
  txChar.setValue(empty, 0);

  // start advertising
  BLE.advertise();

  Serial.println("Bluetooth device active, waiting for connections...");
}

void loop() {
  // poll for BLE events
  BLE.poll();
}

void blePeripheralConnectHandler(BLEDevice central) {
  // central connected event handler
  Serial.print("Connected event, central: ");
  Serial.println(central.address());
}

void blePeripheralDisconnectHandler(BLEDevice central) {
  // central disconnected event handler
  Serial.print("Disconnected event, central: ");
  Serial.println(central.address());
}

void txCharSubscribed(BLEDevice central, BLECharacteristic ch) {
    Serial.println("Subscribed");
}

void txCharUnsubscribed(BLEDevice central, BLECharacteristic ch) {
    Serial.println("Unsubscribed");
}

void rxCharWritten(BLEDevice central, BLECharacteristic ch) {
    const uint8_t* data = ch.value();
    uint32_t len = ch.valueLength();

    Serial.print("Got data:");
    Serial.write(data, len);

    txChar.setValue((uint8_t*)data, len);
}
@sandeepmistry
Copy link
Contributor

@vshymanskyy thanks for the excellent issue report! I've confirmed the issue on my board using the sketch you provided.

@SidLeung can something at Intel look into this please?

@russmcinnis
Copy link
Contributor

I reproduced the results using another 101 as the central and the sketch in this issue is not seeing the subscribe/unsubscribe events.

@russmcinnis
Copy link
Contributor

tracked by jira 913

@novashah novashah added this to the Elnath milestone Apr 17, 2017
@novashah novashah changed the title BLESubscribed, BLEUnsubscribed Event Handlers are not called Jira 913 BLESubscribed, BLEUnsubscribed Event Handlers are not called Apr 25, 2017
@russmcinnis
Copy link
Contributor

The event handlers are being called. Jira 913 has been updated and resolved. This is not released yet.

@russmcinnis
Copy link
Contributor

Will re-test when merged for Elnath.

@russmcinnis
Copy link
Contributor

testing other BLE issues, this will be re-tested when we get something final for Elnath.

@d1runberg
Copy link

Any news on this?

@SidLeung
Copy link
Contributor

Issue duplicated, failure determined, correction implemented, and it is in the pipeline for official release.

@russmcinnis
Copy link
Contributor

Will retest for the official release.

@russmcinnis
Copy link
Contributor

will test when bootes/elnath released.

@kitsunami kitsunami removed this from the Elnath milestone Aug 30, 2017
@vshymanskyy
Copy link
Author

Any updates?

@russmcinnis
Copy link
Contributor

Maybe Dino can provide info
@bigdinotech

@vshymanskyy
Copy link
Author

@bigdinotech hey are there any news?

@vshymanskyy
Copy link
Author

ping ping ping ))

@vshymanskyy
Copy link
Author

Guys, what's the plan?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants