cancel
Showing results for 
Search instead for 
Did you mean: 

How to send complex payload via "aci_gatt_write_without_resp"

roman_tl
Associate II

I've looked through many examples (in particular p2p client ) but I can't find any that sends payload that's made of array

 

```

uint8_t pPayload[] = {0xFF, 0x01, 0x00, 0x05, 0xAA};
uint8_t payloadLength = sizeof(pPayload);


ret = aci_gatt_write_without_resp(aP2PClientContext[index].connHandle,
                                                      aP2PClientContext[index].P2PWriteToServerCharHdle,
                                                      payloadLength,
                                                      pPayload);

```

That's the payload that worked fine when I programmed on ESP32 NimBLE but on STM32 I can't seem to make it work.

Side note: Service and Characteristics use 128bit UUID and seem to be discovered correctly

4 REPLIES 4
STTwo-32
ST Employee

Hello @roman_tl and welcome to the ST Community :smiling_face_with_smiling_eyes:.

I suggest you to follow the sending procedure on the Cable replacement example. It should be really helpful.

Best Regards.

STTwo-32 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

roman_tl
Associate II

I've set up a virtual peripheral in LightBlue BLE debugger just to see the messages and it turns out that code given in p2p_client example can't work with 128-bit UUIDs.

After all corresponding flags to use 128-bit were set services and characteristics are discovered correctly, however, sending messages doesn't work - it returns success status but I don't see anything in debugger.

 

On the other hand switching to 16-bit UUIDs didn't cause any issues, the same code mentioned above works just fine.

 

Now I have to figure out how to fix this because 3-rd party hardware I'm trying to write to with uses 128-bit

roman_tl
Associate II

So the bug is in this piece:

 

/* store the characteristic handle not the attribute handle */
#if (UUID_128BIT_FORMAT==1)
handle = UNPACK_2_BYTE_PARAMETER(&pr->Handle_Value_Pair_Data[idx-14]);
#else
handle = UNPACK_2_BYTE_PARAMETER(&pr->Handle_Value_Pair_Data[idx-2]);
#endif

 

 

https://github.com/STMicroelectronics/STM32CubeWB/blob/cbe89b3b4318fd8b1c8a1e51024fac568274c3d3/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_p2pClient/STM32_WPAN/App/p2p_client_app.c#L413

 

For some reason `idx` resets to value less than 14 and that causes handle to be made from arbitrary memory location. I'll debug later why this bug occurs

I don't there is such a bug. Could you please specify why you think so.

Best Regards.

STTwo-32

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.