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.

CC2650: Sending an array of 180 bytes over BLE

Part Number: CC2650
Other Parts Discussed in Thread: BLE-STACK,

I have an array which has 180 signed integers each under 1 byte. Every few minutes, the array gets new values but they are always under 1 byte. Therefore, every few minutes I need to send 180 bytes over BLE.

Would this be just as simple as changing the MAX_PDU_SIZE to atleast 180 bytes and then just calling MyService_SetParameter or would I have to have multiple Write ATT procedures?

I am running BLE stack (2_02_00_31) . 

  • There are different options for you.

    1. You can change to the MAX_PDU_SIZE to suit your need and then just use GATT_WriteLongCharDesc() to send the data over the air. BLE-STACK will do the fragmentation for you.

    2. You can also enable BT 4.2 feature, data length extension and just use GATT_WriteCharValue() to send the data.
    You can find our software developer's guide for more information regarding API usage and DLE.
  • Thanks Christin.

    Is there an example of either one of these methods? I want a little more clarification on  a couple things (I am trying to use the GATT_WriteLongCharDesc() function). My application is a direct modification of project zero.

    1. Where would I find the taskId?

    2. How is the offset incorporated?

    3. Would I get the connection handle by simply doing : pEvent->linkCmpl.connectionHandle?

    Here is my current code: I have a separate clock that calls this function every few minutes.

    static void data_performTask(){

    attPrepareWriteReq_t writeReq;

    writeReq.offset= 0;

    writeReq.len = data_len;

    writeReq.handle = 0;

    writeReq.pValue = osal_mem_alloc(data_len);

    osal_mem_cpy(writeReq.pValue,data, data_len);

    status = GATT_WritelongCharDesc(connHandle, writeReq, ?????)

    }

  • Hi,

    There are no specific example for using GATT_WriteLongCharDesc, but you can take a look at simple_central project or multi-role project which has the usage of 

    GATT_WriteCharValue(). The usage is fairly similar. 

    1. Where would I find the taskId?

    -->The TaskID is already defined in the project called "selfEntity"

    2. How is the offset incorporated?

    --> The BLE stack will take care of the shifting of you. You only need to setup the data structure.

    3. Would I get the connection handle by simply doing : pEvent->linkCmpl.connectionHandle?

    --> I am not sure which function you are talking about when you said pEvent->linkCmpl.connectionHandle, but you can always get the connection handle by using following API  GAPRole_GetParameter and set the param to be GAPROLE_CONNHANDLE.

  • Thanks for the reply.


     3 more quick questions:

    1. Instead of 180 bytes, I actually have more because some values are negative. So my array is actually an int16_t array instead of uint8. attPrepareWriteReq_t has the 'pValue' variable set to uint8. Typecasting would not work in this case so is there another function for this?

    2. I don't have a BLE sniffer on the other end (just using light blue app) so when I am sending an array using GATT_WriteLongCharDesc, will the dev kit transmit all the values and then the characteristic will return to its initial value of 0? or will it send the data one array value at a time such that I can see it on the app?

    3. In my project zero application, where is the handle defined for the attPrepareWriteReq_t struct? I do not know how to find the handle? The way they did it on the simple_central project isn't very intuitive and it won't apply to my project since the launchpad is a peripheral. I simply set it as writeReq.handle = 0 but that is incorrect.

  • Hi,

    You will just have to reassemble your data at the receiver end.

    I am a bit confused right now. Are you planning on using GATT_WriteLongCharDesc to light blue app? You need to make sure that your receiver end has the characteristics you are going to write to. (I would recommend you to finish the simplelink academy training :custom profiles section)

    And then you need to implement client role in your project zero to do reading or writing data from or to the GATT server. Please take a look at our software developer's guide for adding client role into your project.

    Or else what you can do is using notification to send data to the phone end.
  • Hi Christin,

    I am simply using the light blue app to check if my data has been written to the characteristic.

    I have a custom service I already created. Previously I was writing to characteristics that were a max of 10 bytes. I could actually see the value update on light blue (using Service_SetParameter function).

    Now for this new characteristic, I am using Gatt_WriteLongCharDesc because I need to send about 250 bytes for one of the characteristics.

    I believe the "writeReq.handle = 0;" is incorrect because I do not know the handle of the characteristic (since we were told to leave it at 0 when we declared it).

    How would I find the handle without a sniffer?

    Since the phone is the client and the CC2650 is actually the server, I simply need to set up client code on the phone not the launchpad correct? The phone simply reads data that is being sent and never writes to the server.

    Thanks,

    Arsh Buch

  • So I am now modifying the simple_peripheral app.

    I turned on the DLE using BT 4.2 as per the developers guide. However, still don't really know the handle of the data. I don't know if I can move forward without knowing that.

    Since I am basically copying the format from other examples, it must be the handle that is incorrect?

    Here is my code in my perform task function:

    uint8_t connHandle;
            uint8_t status;
            attPrepareWriteReq_t writeReq;
            writeReq.handle=0;
            writeReq.offset = 0;
            writeReq.len =len
            writeReq.pValue=data;;
            GAPRole_GetParameter(GAPROLE_CONNHANDLE,&connHandle);
            status = GATT_WriteLongCharDesc(connHandle,&writeReq,selfEntity); // OR GATT_WriteLongCharValue(connHandle, &writeReq,selfEntity)

  • If you just want your project zero to have characteristics updated itself(not by the client(phone)), then you can just use Service_SetParameter .
    GATT_WriteLongCharDesc or GATT_WriteCharDesc are used by the client to write the data to the server.

    And you don't need to get the handle value since the handle value is only needed when you want client to update characteristics values on the server.

    Also you will have to make sure that your phone app support DLE.
  • Interesting.
    I had tried that first:
    myService_SetParameter(SERVICE_DATA, DRUGABUSESERVICE_DATA_LEN, array_data);

    where array_data is the array of 180 values and nothing showed up on the light blue app for this characteristic ( I am using an iPhone). It did show up for other characteristics however. Is this because there may not be DLE for the iphone yet? or because I get warnings for integer truncation (my array is int16_t).

    Thanks,

    Arsh Buch

  • As you can see from the app description :
    "LightBlue Explorer can connect you to all of your devices that use Bluetooth 4.0 Low Energy (also known as Bluetooth Smart, or Bluetooth Light)."
    itunes.apple.com/.../id557428110
  • Yes. exactly! so when I open the characteristic, I can see that there are 250 bytes of 0's  (thats my initial value). The value simply does not change using Set Parameter. This means that it must be the integer truncation issue even though I set my array to be of int16_t

    Thanks!