What is an efficient way to stream data from 6 ADC over BLE?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
JoBa_4600301
Level 1
Level 1
First like given

Hi,

I'm looking to stream the data read from 6ADC over BLE.  I'm currently basing my code on the battery_level example but the communication is very slow -I'm getting 2 readings (2bytesx6) per second at the server side (windows computer running python script).   I think I'm not using the right command to send the data.  The way I'm doing it now is by using 6 services (see complete code attached) like this:

Thanks in advance for the help.

     ADC_StartConvert();

    ADC_IsEndConversion(ADC_WAIT_FOR_RESULT);

        adcResult = ADC_GetResult16(0u);

        adcResult1 = ADC_GetResult16(1u);

        adcResult2 = ADC_GetResult16(2u);

        adcResult3 = ADC_GetResult16(3u);

        adcResult4 = ADC_GetResult16(4u);

        adcResult5 = ADC_GetResult16(5u);

       

      mvolts0 = ADC_CountsTo_mVolts(0,adcResult);

    mvolts1 = ADC_CountsTo_mVolts(1,adcResult1);

    mvolts2 = ADC_CountsTo_mVolts(2,adcResult2);

    mvolts3 = ADC_CountsTo_mVolts(3,adcResult3);

    mvolts4 = ADC_CountsTo_mVolts(4,adcResult4);

    mvolts5 = ADC_CountsTo_mVolts(5,adcResult5);

        CYBLE_GATTS_HANDLE_VALUE_NTF_T tempHandle;

        tempHandle.attrHandle=CYBLE_PDIODE_DDIODE_CHAR_HANDLE;

        tempHandle.value.val = &mvolts0;  //(uint8 *)&mvolts1_int;

        tempHandle.value.len=sizeof(mvolts0);

        CyBle_GattsNotification(cyBle_connHandle,&tempHandle);

       

               tempHandle.attrHandle=CYBLE_PDIODE_2_DDIODE_CHAR_HANDLE;

        tempHandle.value.val = &mvolts1;

        tempHandle.value.len=sizeof(mvolts1);

        CyBle_GattsNotification(cyBle_connHandle,&tempHandle);

       

                tempHandle.attrHandle=CYBLE_PDIODE_3_DDIODE_CHAR_HANDLE;

        tempHandle.value.val = &mvolts2;

        tempHandle.value.len=sizeof(mvolts2);

        CyBle_GattsNotification(cyBle_connHandle,&tempHandle);

       

                       tempHandle.attrHandle=CYBLE_PDIODE_4_DDIODE_CHAR_HANDLE;

        tempHandle.value.val = &mvolts3;

        tempHandle.value.len=sizeof(mvolts3);

        CyBle_GattsNotification(cyBle_connHandle,&tempHandle);

       

                       tempHandle.attrHandle=CYBLE_PDIODE_5_DDIODE_CHAR_HANDLE;

        tempHandle.value.val = &mvolts4;

        tempHandle.value.len=sizeof(mvolts4);

        CyBle_GattsNotification(cyBle_connHandle,&tempHandle);

       

                       tempHandle.attrHandle=CYBLE_PDIODE_6_DDIODE_CHAR_HANDLE;

        tempHandle.value.val = &mvolts5;

        tempHandle.value.len=sizeof(mvolts5);

        CyBle_GattsNotification(cyBle_connHandle,&tempHandle);

       

         apiResult = CyBle_BassSendNotification(cyBle_connHandle, 0u,

                0u, sizeof(batteryLevel), &batteryLevel);

pastedImage_0.png

pastedImage_1.png

0 Likes
1 Solution
VenkataD_41
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi,

1. From BLE side we recommend you to check the status of the stack before sending the BLE packet as follows) and send the notification as quickly as possible.

/* Create a new notification packet */

    CYBLE_GATTS_HANDLE_VALUE_NTF_T notificationPacket;

   

/* Update Notification packet with the data.

     * Maximum data which can be sent is equal to (Negotiated MTU - 3) bytes. */

if(CyBle_GattGetBusStatus() == CYBLE_STACK_STATE_FREE)

{

    notificationPacket.attrHandle = CYBLE_CUSTOM_SERVICE_CUSTOM_CHARACTERISTIC_CHAR_HANDLE;

    notificationPacket.value.val = buffer;

    notificationPacket.value.len = negotiatedMtu - 3;

   

    /* Report data to BLE component */

    CyBle_GattsNotification(cyBle_connHandle, &notificationPacket);

}

2. Reduce the connection interval period in BLE component datasheet.

Please refer BLE throughput code example GATT Notification -Data Outgoing ( Day024_Throughput) from github (link given below):

PSoC-4-BLE/100_Projects_in_100_Days/Day024_Throughput at master · cypresssemiconductorco/PSoC-4-BLE ...

Thanks

Ganesh

View solution in original post

0 Likes
2 Replies
VenkataD_41
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi,

1. From BLE side we recommend you to check the status of the stack before sending the BLE packet as follows) and send the notification as quickly as possible.

/* Create a new notification packet */

    CYBLE_GATTS_HANDLE_VALUE_NTF_T notificationPacket;

   

/* Update Notification packet with the data.

     * Maximum data which can be sent is equal to (Negotiated MTU - 3) bytes. */

if(CyBle_GattGetBusStatus() == CYBLE_STACK_STATE_FREE)

{

    notificationPacket.attrHandle = CYBLE_CUSTOM_SERVICE_CUSTOM_CHARACTERISTIC_CHAR_HANDLE;

    notificationPacket.value.val = buffer;

    notificationPacket.value.len = negotiatedMtu - 3;

   

    /* Report data to BLE component */

    CyBle_GattsNotification(cyBle_connHandle, &notificationPacket);

}

2. Reduce the connection interval period in BLE component datasheet.

Please refer BLE throughput code example GATT Notification -Data Outgoing ( Day024_Throughput) from github (link given below):

PSoC-4-BLE/100_Projects_in_100_Days/Day024_Throughput at master · cypresssemiconductorco/PSoC-4-BLE ...

Thanks

Ganesh

0 Likes

Thanks, Ganesh,

I combined all the services' data into one and reduce the interval period to the minimum and I was able to achieve 100 samples a second.

0 Likes