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

pc-ble-driver: sd_ble_gattc_read() why length is (ATT-1) instead (ATT-3) ?

Hi 
I use nrf-ble-driver ver.4.1.1 with PCA10031 dongle (nRF51844 chip on board) and "connectivity_4.1.1_1m_with_s130_2.0.1.hex" firmware for that dongle. in this case ATT_MTU = 23.

In description of function sd_ble_gattc_read() says: 
"If the Characteristic or Descriptor to be read is longer than ATT_MTU-1, this function must be called multiple times with appropriate offset to read the complete value."

Its all ok and work fine, but I have a stupid question: why ATT_MTU-1  but not ATT_MTU-3 ?

In peripheral I have characteristic 23 bytes len and really after call 2 times an sd_ble_gattc_read(),  I receive first 22 bytes and second 1 bytes in 2 packets. in other words I receive all data, but I assumed that first packet should be 20 bytes len (ATT_MTU-3) and second packet = 3 bytes len.

Continuing this one more question: when I enable notification for this characteristic, on BLE_GATTC_EVT_HVX event I receive only 20 bytes and can't get more, but if to follow the logic of ATT_MTU description, I have to receive 22 bytes.

Tell me please, where could I get confused?

Thanks.

Parents
  • I added these comments to my code to illustrate, might be useful:

    // |<-------------------------------------------- Slave -> Master Data Packet -------------------------------------->|
    // |                                                                                                                 |
    // +-----------------------------------------------------------------------------------------------------------------+
    // |                                            BLE Data Packet Min/Max/eg(186)                                      |
    // +-----------------------------------------------------------------------------------------------------------------+
    // |                                     1MHz: 10/265/217 octets, 2MHz: 11/266/218 octets                            |
    // +----------+--------+--------------------------------------------------------------------------------------+------+
    // |          | Access |                                                                                      |      |
    // | Preamble | Address|         Protocol Data Unit PDU                                                       | CRCC |
    // +----------+--------+--------------------------------------------------------------------------------------+------+
    // |   1 (2)  |    4   |                                                   2-257                              |  3   |
    // |          |        +-----------+------------------------------------------------------------------+-------+      |
    // |          |        | LL Header |  Payload                                                         |  MIC  |      |
    // |          |        +-----------+------------------------------------------------------------------+ (opt) |      |
    // |          |        |   2       |                                       0-251                      |   4   |      |
    // |          |        |           +--------+---------------------------------------------------------+       |      |
    // |          |        |           | L2CAP  |                                                         |       |      |
    // |          |        |           | Header |  ATT Data                                               |       |      |
    // |          |        |           +--------+---------------------------------------------------------+       |      |
    // |          |        |           |   4    |                              0-247                      |       |      |
    // |          |        |           |        +-----+-------+-------------------------------------------+       |      |
    // |          |        |           |        | ATT | ATT   |                                           |       |      |
    // |          |        |           |        | Op  | Attrib|  ATT Payload                              |       |      |
    // |          |        |           |        +-----+-------+-------------------------------------------+       |      |
    // |  1 (2)   |   4    |  2        |   4    |  1  |  2    |                0-244                      |  (4)  |  3   |
    // +----------+--------+-----------+--------+-----+-------+-------------------------------------------+-------+------+
    //                                                        /                                           \
    //                                                      /                                               \
    //                                                    /                                                   \
    //                                                  /                                                       \
    //                                                /                                                           \
    //                                              /                                                               \
    //                                            |<---------------------- eg Payload 186 bytes --------------------->|
    //
    //
    // Preamble is 1 byte for LE 1MHz (BLE 4.2) and 2 bytes for 2MHz (BLE 5.0). If the first bit of the ADDRESS is 0 the preamble
    // will be 0xAA otherwise 0x55.
    // The MIC field is optional used when we are using an encrypted connection

Reply Children
No Data
Related