Skip to content

Porting code with 2901 descriptors #411

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

Closed
jackjansen opened this issue Jun 15, 2022 · 5 comments
Closed

Porting code with 2901 descriptors #411

jackjansen opened this issue Jun 15, 2022 · 5 comments

Comments

@jackjansen
Copy link

I'm porting code where I've created 2901 descriptors for almost everything with

class BLE2901 : public BLEDescriptor {
public:
  BLE2901(const char *description) : BLEDescriptor(BLEUUID((uint16_t)0x2901)) { setValue((uint8_t *)description, strlen(description)); }
};

static BLE2901 levelVBat2901("Battery Level");

and then later add pChar->addDescriptor(levelVBat2901) .

I'm under the impression that this code will have to be restructured, but really posting this issue to ask if I've overlooked something...

@h2zero
Copy link
Owner

h2zero commented Jun 15, 2022

Hi @jackjansen, sorry for the lack of documentation regarding this. Unfortunately what you're trying to port "should" work but I missed adding the default parameters to the descriptor constructor.

There are 2 options to resolve this:

  1. add the extra required parameters to your construction (properties and max length)
  2. add default values to the NimBLEDescriptor constructor and submit a PR

I like the second option best 😄

@jackjansen
Copy link
Author

Hmm. So if I understand you correctly statically allocating a NimBLEDescriptor should work? I didn't go down this path because the examples suggested I should use pChar->createDescriptor() in stead of creating the descriptor myself and then calling pChar->addDescriptor().

@h2zero
Copy link
Owner

h2zero commented Jun 17, 2022

Yes, the code has changed since the examples were made. You can create and add descriptors/characteristics outside and add them later now.

@jackjansen
Copy link
Author

I actually like the Nimble-Arduino code structure for creating the descriptors much better than my old static allocation code.

So I've converted my code, and I won't be submitting a PR.

@h2zero
Copy link
Owner

h2zero commented Jun 20, 2022

Cool, sounds good. I'll update the code later then.

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

No branches or pull requests

2 participants