Feature Request... Option To Set CCCD Value

File: BLEProperty.h

enum BLEProperty {
  BLEBroadcast            = 0x01,
  BLERead                 = 0x02,
  BLEWriteWithoutResponse = 0x04,
  BLEWrite                = 0x08,
  BLENotify               = 0x10,
  BLEIndicate             = 0x20,
  BLESetCCCD1             = 0x40 // New property just here
};

File: BLELocalCharacteristic.cpp

if (properties & (BLENotify | BLEIndicate))
{
   if (BLESetCCCD1)
        _cccdValue = 0x0001; // Set CCCD value = (0x) 01-00 
	  
    BLELocalDescriptor* cccd = new BLELocalDescriptor("2902", (uint8_t*)&_cccdValue, sizeof(_cccdValue));
  
    _descriptors.add(cccd);
}

Explanation: there's currently no way to set the CCCD value for the default descriptor that is created via "BLENotify" or "BLEIndicate". This means that any device that has subscribed to a service but not enabled the characteristic on its side... doesn't receive the notifications.

Also note that adding a new descriptor of the same type, i.e., 2902 and value 01-00... indeed appears within the characteristics as a 2nd 2902, but it does not work as a solution.

Also see my last few topics which provide additional information...

  1. Enabling Notifications (Video Example & Question?)
  2. How is BLENotify's default descriptor written to?
  3. Arduino Hack… Required or Not? (Notifications)
  4. Notifications And Indications Disabled (nRF Connect)
1 Like

I am working on the same stuff. Thank you for posting this here. You've nicely documented your process which I will be going through. Your solution looks great, particularly after reading about the process you went through drilling down to that. Wish I could add some value today, but if I learn anything new I will certainly post here.

1 Like

WOW! One new user posts 4 questions and right after the solution to all of those questions, thereby boosting his own user with 4 solves. Shortly after that "another" new user comes in and has just found the solution to his problem and likes are shared. AMAZING! Or something.. :face_with_raised_eyebrow:

WOW! One new user posts 4 questions and right after the solution to all of those questions, thereby boosting his own user with 4 solves. Shortly after that "another" new user comes in and has just found the solution to his problem and likes are shared. AMAZING! Or something.. :face_with_raised_eyebrow:

Would you like me to remove the "solves"? It's no problem. I have absolutely no intention or desire to boost my score.

I've spent quite a lot of time over the last 10 days learning about BLE, and after having arrived at a clear conclusion, I decided to link the relevant posts together, which has been appreciated already... "You've nicely documented your process...".

1 Like

IMO, there is no need to diminish what's happened here because it's not social media and I was able to find good information here because of these particular questions and phrases. And btw, I've already made progress on my own project. I might be new, but I can recognize value when I see it.

1 Like

Just an update after some testing today...

if (BLESetCCCD1) ... (produces warning: "enum constant in boolean context")

The next bit along, i.e., for enum 0x40 needs comparing of course, therefore:  "if (properties & BLESetCCCD1)"

Also, unfortunately, this fix only works for BLECharacteristic, e.g., BLEIntCharacteristic and BLEFloatCharacteristic crash the board immediately after compiling is complete (requires double button press to put into bootloader mode).

Furthermore, simply by only changing "_cccdValue(0x0000)" to _cccdValue(0x0001) crashes the board when not using BLECharacteristic (i.e., using the official master files, but with just this 1 digit changed)

I'm only working with arrays of data anyway, so I'm happy to continue using this as a temporary fix, but having the option to set the CCCD value properly would still be nice.