Skip to content

indicate() [4/5] not working in 2.x #922

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
Berg0162 opened this issue Mar 27, 2025 · 2 comments · May be fixed by #943
Open

indicate() [4/5] not working in 2.x #922

Berg0162 opened this issue Mar 27, 2025 · 2 comments · May be fixed by #943
Labels
bug Something isn't working

Comments

@Berg0162
Copy link

Dear H2zero,
During the process of updating some code from NimBLE-Arduino version 1.x to 2.x I came across the following (consistent and reproducible) behavior, that should get your attention because of the underlying problem.

In 1.x the following snippet is working perfectly and the client confirms the "indicate", and the check never returns false!

.
uint8_t Server_authResponse[6] = {0x03, 0x12, 0x00, 0x00, 0x00, 0x00};
.
.
// Server replies with a packet: 03 12 ## ## ## ## containing (4 byte --> 32 bit unsigned int) Response (TxChar 32)
if(!pServer_SteeringDEVCharTx->indicate(Server_authResponse, 6)) {  // Array of 6 bytes
    DEBUG_PRINTLN("Indicate authResponse Failed!");
}

However, in 2.x the very same code snippet is no longer working!
No compiler complains (like undefined use of indicate(...) )

  1. the check never returns false
  2. the client does not get the Indicate and as a consequence never confirms "indicate"

As if pServer_SteeringDEVCharTx->indicate(Server_authResponse, 6) is never executed!

The following workaround is working perfectly in 2.x:

// Server replies with a packet: 03 12 ## ## ## ## containing (4 byte --> 32 bit unsigned int) Response (TxChar 32)
pServer_SteeringDEVCharTx->setValue(Server_authResponse, 6); // Array of 6 bytes
if(!pServer_SteeringDEVCharTx->indicate()) { 
    DEBUG_PRINTLN("Indicate authResponse Failed!");
}

I could not find in the (migration or code) documentation that indicate() has changed this way in version 2.x

indicate() [4/5]
bool NimBLECharacteristic::indicate(const uint8_t * value, size_t length, uint16_t connHandle = BLE_HS_CONN_HANDLE_NONE) const
Send an indication.

Parameters
[in]	value	A pointer to the data to send.
[in]	length	The length of the data to send.
[in]	connHandle	Connection handle to send an individual indication, or BLE_HS_CONN_HANDLE_NONE to send the indication to all subscribed clients.
Returns
True if the indication was sent successfully, false otherwise.

The workaround is simple again, but it has possibly a serious underlying cause.
Thanks in advance!

@h2zero
Copy link
Owner

h2zero commented Mar 27, 2025

@Berg0162 Thanks, I am currently looking into this and some similar issues that I hope to resolve shortly.

@h2zero h2zero added the bug Something isn't working label Mar 27, 2025
@h2zero
Copy link
Owner

h2zero commented Apr 23, 2025

@Berg0162 Please try with the merging of nimble core 1.6, 8f32a23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants