This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

sd_ble_user_mem_reply with S110 stack v8

Hello there.

I'm porting some code that previously worked on S110 stack v7 to stack v8 and I'am experiencing some issues.

After receiving a BLE_EVT_USER_MEM_REQUEST, I send back a sd_ble_user_mem_reply with a connection handle of 0 and a null pointer (as I have nothing to send at this time). There, I get the error code NRF_ERROR_DATA_SIZE and get into my hard fault handler.

I also tried setting up a dummy ble_user_mem_block_t pointing to a dummy char, but I have the same problem.

This code was working with stack v7, but it's not anymore and I can't figure out why.

So, am I using the function correctly ? What should I do to use it correctly ? Any hint would be greatly appreciated.

  • Several things I don't understand here.

    When you get a BLE_EVT_USER_MEM_REQUEST you say you reply with a null pointer as "you have nothing to send", however the user mem request is sent by the stack to you when the peer has something to send and is doing a long write. It's asking you for memory to store the long write into. Do you mean that at this time you don't wish to receive data?

    Where are you getting an NRF_ERROR_DATA_SIZE error? The user mem reply call doesn't generate that error, the only likely thing I can see which does is the sd_ble_evt_get() call in your main event loop. If you're getting that, then the buffer you're giving it just isn't large enough. How big is the buffer you're passing to sd_ble_evt_get(), mine's 72 bytes or 18 uint32_t's.

    It would make some sense that if something is trying to do a long write, it's going to be sending a max length packet.

  • Thanks for the remark regarding the buffer size, I had a look at this. Playing with it, I realised the NRF51 is receiving malformed data which is causing the error. (So it has nothing to do with the NRF51 nor the stack.)

Related