Skip to content
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

how should I set an description for 2902 based code`/ #623

Open
JopWerff opened this issue Dec 29, 2023 · 3 comments
Open

how should I set an description for 2902 based code`/ #623

JopWerff opened this issue Dec 29, 2023 · 3 comments

Comments

@JopWerff
Copy link

Hi h2zero,

I have a bit a problem getting things done with 2902 based stuff. I tried self several ways - researched a little - had a look to this keyboard stuff of sivar2311. But I didn't get it. I'm a real newbie in the area of BLE.

I searched also for examples in the NewBLE-library but nothing to find what is a bit alike what I want to do.

Can you help me?

Here my code to convert to using NimBLED from using the original BLE Library:

NimBLECharacteristic* pCharacteristicTEMP = pBmeService->createCharacteristic(TEMP_UUID, NIMBLE_PROPERTY::NOTIFY);

BLEDescriptor* pBLEDescriptorTEMP = pCharacteristicTEMP->createDescriptor(BLEUUID((uint16_t)0x2902));
pBLEDescriptorTEMP->setValue("BME temperature Celsius");
pCharacteristicTEMP->addDescriptor(pBLEDescriptorTEMP);

These last 3 lines: how I have to implement this in the NimBLE-way?

Jop

@h2zero
Copy link
Owner

h2zero commented Dec 29, 2023

In this library the 2902 is automatic when the characteristic has the notification property. You need to delete those 3 lines.

@JopWerff
Copy link
Author

Not quite clear to me. How the descriptor will get its content in this "2902-automatic" way?

Here my more complete code that makes difference between Celsius and Fahrenheit, dependent of a compiler directive.

  // Create NimBLE Characteristics and Create a NimBLE Descriptor
  // Temperature
  #ifdef temperatureCelsius
    pCharacteristicTEMP = pBmeService->createCharacteristic(TEMP_UUID, NIMBLE_PROPERTY::NOTIFY);

    NimBLEDescriptor* pNimBLEDescriptorTEMP = pCharacteristicTEMP->createDescriptor(BLEUUID((uint16_t)0x2902));
    pNimBLEDescriptorTEMP->setValue("BME temperature Celsius");
    pCharacteristicTEMP->addDescriptor(pNimBLEDescriptorTEMP);
    
  #else
    pCharacteristicTEMP = pBmeService->createCharacteristic(TEMP_UUID, NIMBLE_PROPERTY::NOTIFY);

    NimBLEDescriptor* pNimBLEDescriptorTEMP = pCharacteristicTEMP->createDescriptor(BLEUUID((uint16_t)0x2902));   
    pNimBLEDescriptorTEMP->setValue("BME temperature Fahrenheit");
    pCharacteristicTEMP->addDescriptor(pNimBLEDescriptorTEMP);
  #endif  

How I have to implement this in NimBLE making a distinguish between these temperature scales?

Regards,
Jop

@h2zero
Copy link
Owner

h2zero commented Dec 30, 2023

That's is not what the 2902 descriptor is for, it's only for setting the client notification subscription status.

You'll want to use some other method to achieve what you are doing here.

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