This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2642R: How to find the length of a characteristic

Part Number: CC2642R

Using a project based on the simple_central example, I have connected to a peripheral device (based on the simple_peripheral example).

I have discovered the service, and retrieved the handles of the characteristics.

One of the characteristics is a write-only characteristic.  How can I determine the length of the value for this characteristic?

  • Hi,

    Check the BLE Custom Profile Simplelink Academy module. It contains a thorough navigation of the methods and APIs used to create and discover the aspects of characteristics. 

    https://dev.ti.com/tirex/explore/node?node=AKui.0P6XA0Q2Q70ZaYksA__pTTHBmu__LATEST

    Hope this helps,

    Rafael

  • Rafael,

    While there is a great deal of information describing how to create characteristics on the peripheral, there is nothing in the Custom Profile Simplelink Academy module that describes how, from the central, to discover the length of a characteristic.

    Thanks,
    Dave

  • Rafael

    While there is a great deal of information describing how to create characteristics on the peripheral, there is nothing in the Custom Profile Simplelink Academy module that describes how, from the central, to discover the length of a characteristic.

    Does anyone know if it's even possible for a central to determine the length/size of a characteristic?

    Thanks,
    Dave

  • Dave,

    Sorry; I missed your reply.

    In the reference I sent, the section Implementation of a service --> GATT Server callbacks --> Write callback contains the details about the write callback function that receives the peer's data. One of its parameters is len, which is the length of the incoming data.

    Then in this section there is an implementation of the procedure to double-check the length and avoid any overruns.

    I think this is what you are looking for, isn't it?

    Hope this helps,

    Rafael

  • Rafael,

    I believe that what you are describing takes place on the simplePeripheral side.

    I am looking for functionality on the simpleCentral side.  After the simpleCentral discovers the characteristics of the peripheral, can it determine the size of a write-only characteristic?

    Thanks,
    Dave

  • Dave,

    I apologize for the delay; we were hit by power and internet outages due to a snowstorm and this delayed everything. 

    I had to double-check this information and found the following, based on the simple_central project: 

    At <simple_central.c>, the function SimpleCentral_processGATTDiscEvent(gattMsgEvent_t *pMsg) discovers the characteristics and attributes from the peripheral and copies them to the pMsg union.

    It is a bit hard to track the number of members and unions, but the information is on the following structs in the file <att.h>:

    typedef struct
    {
      uint16 numPairs;  //!< Number of attribute handle-UUID pairs found
      uint16 len;       //!< Size of each attribute handle-value pair
      uint8 *pDataList; //!< List of 1 or more attribute handle-value pairs (2 to ATT_MTU_SIZE-2)
      uint16 dataLen;   //!< Length of data written into pDataList. Not part of actual ATT Response
    } attReadByTypeRsp_t;

    typedef struct
    {
      uint16 startHandle;   //!< First requested handle number (must be first field)
      uint16 endHandle;     //!< Last requested handle number
      attAttrBtType_t type; //!< 2-octet UUID to find
      uint16 len;           //!< Length of value
      uint8 *pValue;        //!< Attribute value to find (0 to ATT_MTU_SIZE-7)
    } attFindByTypeValueReq_t;

    These two structures are indirectly available as part of the pMsg union. So, to find the size of the attribute data you need to access pMsg->msg.readByTypeRsp.dataLen and to find the size of the data you access pMsg->msg.findByTypeValueReq.len

    Hope this helps,

    Rafael

  • Rafael,

    I am not understanding your information.  You say: "and to find the size of the data you access pMsg->msg.findByTypeValueReq.len".

    The attFindByTypeValueReq_t data structure is for making a request; you have to fill in the fields and send it to the BLE stack.  It is not for receiving information.

    I don't yet see a method to achieve my goal.

    ~Dave