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

Long Attributes

Hi, I need to have long attributes. So I need 'Read Blob' operation for read and Queued writes ('Prepare Write' and 'Execute Write'). Does Soft Device for nrf51822 support mentioned commands?

Best regards, Artem Zemlyanukhin

  • Hi there,

    I am guessing the issue here is that the SDK does not support BLE_EVT_USER_MEM_REQUEST yet, so that is why is not being handled in ble_evt_dispatch.

    I will let the people in charge of the SDK know of this and see if they can help you out.

    Regards,

    Carles

  • Hi,

    As I see in ble.h, 'BLE_EVT_USER_MEM_REQUEST' is a member of enum BLE_COMMON_EVTS:

    enum BLE_COMMON_EVTS { BLE_EVT_TX_COMPLETE = BLE_EVT_BASE, /< Transmission Complete. */ BLE_EVT_USER_MEM_REQUEST, /< User Memory request. */ BLE_EVT_USER_MEM_RELEASE /**< User Memory release. */ };

    For example, event 'BLE_EVT_TX_COMPLETE ' is used in GLS service. It is processed in 'ble_gls_on_ble_evt' calling from 'ble_evt_dispatch'. So I suppose, BLE_EVT_USER_MEM_REQUEST event I must handle in function calling from 'ble_evt_dispatch' too. But stack don't call 'ble_evt_dispatch' with such event..

    Can I use any new options for attributes which I need to Long Read?

    Thank you for your response!

  • There shouldn't be any problems making this work. I just did a quick test, as in the attachment, and I'm not able to see any problems when testing with iOS.

    If you take this zip, place it in Boards/nrf6310/ble/, you should be able to see everything working, as long as you have replaced the softdevice headers included in the SDK with the ones from the 6.0.0 zip.

    If you don't get it working, I'd be interested to see what this example outputs on the UART.

    ble_app_lbs-long-write.zip

  • Hi,

    Thanks a lot for code example. I tested it, it works but not completely.

    At first to get additional information I added at the end of 'on_ble_evt' some code:

    if(p_ble_evt->header.evt_id == BLE_GATTS_EVT_WRITE) { sprintf(buffer, "Event 0x50: 0x%lx 0x%lx\r\n", p_ble_evt->evt.gatts_evt.params.write.len, *(uint8_t *)p_ble_evt->evt.gatts_evt.params.write.data); simple_uart_putstring(buffer); }

    I can't ability to use iPhone now, so I used TI usb-dongle (CC2540) with their software.

    Here is the sequence of my actions:

    1. Connect with device
    2. Send first 'Prepare Write Request' handle = 0x11, offset = 0, data = 01
    3. Send second 'Prepare Write Request' handle = 0x11, offset = 1, data = 02
    4. Send third 'Prepare Write Request' handle = 0x11, offset = 2, data = 03
    5. Send 'Execute Write Request'
    6. Send 'Read Request'

    Here is log:

    start Event: 0x10 Event: 0x12 memory requested, 0x1 Event: 0x2 Event: 0x50 Event 0x50: 0x0 0x0 Event: 0x3

    As you can see (also I sow it via debug) stack don't give me data in 'BLE_GATTS_EVT_WRITE' (len = 0, data = 0). But when I tried to read attribute after these operations, I received in 'Read Respnse' correct data: 01 02 03. In other words new attribute value was set, but I couldn't receive this new value in handler ('BLE_GATTS_EVT_WRITE' event). I viewed in debuger value of 'queued_write_buffer' (member of 'mem_block' union) passed as parameter in sd_ble_user_mem_reply. 'queued_write_buffer' had correct value: { 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, //first write (handler, offset, length, value) 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, //second write 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03 //third write }

    I tried to set attr_md.wr_auth = 1. In this case data in 'BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST' event handler is correct. I sent for example 3 PrepareWrite packets: - 2 bytes (0x01 and 0x02) with offset = 0 - 2 bytes (0x03 and 0x04) with offset = 2 - 2 bytes (0x05 and 0x06) with offset = 4

    and I received 4 (not 3) 'BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST' events: - for first write with correct data - for second write with correct data - for third write with correct data - extra event with data = 0, offset = 0, len = 0.

    when I sent 2 writes, I received 3 events. and in case of 1 write, I received 2 events. What does this extra event mean?

    1. What does it mean 'if (&p_ble_evt->evt.common_evt.params.user_mem_release.mem_block == &mem_block)' in 'BLE_EVT_USER_MEM_RELEASE' case? It's never true...

    2. As I read in your docemetation, stack send to application 'BLE_EVT_USER_MEM_REQUEST' event after first 'Prepare Write Request' but really it does it only after Send 'Execute Write Request'.

    3. Also my dongle didn't receive 'Prepare Write Response' packets, it received only 'Execute Write Response'. Is this possible? Or this bug of TI software?

  • Hi,

    Thanks a lot for code example. I tested it, it works but not completely.

    At first to get additional information I added at the end of 'on_ble_evt' some code:

    if(p_ble_evt->header.evt_id == BLE_GATTS_EVT_WRITE) { sprintf(buffer, "Event 0x50: 0x%lx 0x%lx\r\n", p_ble_evt->evt.gatts_evt.params.write.len, *(uint8_t *)p_ble_evt->evt.gatts_evt.params.write.data); simple_uart_putstring(buffer); }

    I can't ability to use iPhone now, so I used TI usb-dongle (CC2540) with their software.

    Here is the sequence of my actions:

    1. Connect with device
    2. Send first 'Prepare Write Request' handle = 0x11, offset = 0, data = 01
    3. Send second 'Prepare Write Request' handle = 0x11, offset = 1, data = 02
    4. Send third 'Prepare Write Request' handle = 0x11, offset = 2, data = 03
    5. Send 'Execute Write Request'
    6. Send 'Read Request'

    Here is log:

    start Event: 0x10 Event: 0x12 memory requested, 0x1 Event: 0x2 Event: 0x50 Event 0x50: 0x0 0x0 Event: 0x3

    As you can see (also I sow it via debug) stack don't give me data in 'BLE_GATTS_EVT_WRITE' (len = 0, data = 0). But when I tried to read attribute after these operations, I received in 'Read Respnse' correct data: 01 02 03. In other words new attribute value was set, but I couldn't receive this new value in handler ('BLE_GATTS_EVT_WRITE' event). I viewed in debuger value of 'queued_write_buffer' (member of 'mem_block' union) passed as parameter in sd_ble_user_mem_reply. 'queued_write_buffer' had correct value: { 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, //first write (handler, offset, length, value) 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, //second write 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03 //third write }

    I tried to set attr_md.wr_auth = 1. In this case data in 'BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST' event handler is correct. I sent for example 3 PrepareWrite packets: - 2 bytes (0x01 and 0x02) with offset = 0 - 2 bytes (0x03 and 0x04) with offset = 2 - 2 bytes (0x05 and 0x06) with offset = 4

    and I received 4 (not 3) 'BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST' events: - for first write with correct data - for second write with correct data - for third write with correct data - extra event with data = 0, offset = 0, len = 0.

    when I sent 2 writes, I received 3 events. and in case of 1 write, I received 2 events. What does this extra event mean?

    1. What does it mean 'if (&p_ble_evt->evt.common_evt.params.user_mem_release.mem_block == &mem_block)' in 'BLE_EVT_USER_MEM_RELEASE' case? It's never true...

    2. As I read in your docemetation, stack send to application 'BLE_EVT_USER_MEM_REQUEST' event after first 'Prepare Write Request' but really it does it only after Send 'Execute Write Request'.

    3. Also my dongle didn't receive 'Prepare Write Response' packets, it received only 'Execute Write Response'. Is this possible? Or this bug of TI software?

Related