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.

LP-CC1352P7: How to send multi byte (96000 bytes) data from LP-CC1352P7 to other BLE peripheral?

Part Number: LP-CC1352P7
Other Parts Discussed in Thread: CC1352P7, CC2650,

Hello TI,

I have ported the code simple_serial_socket_client from this github link,

https://github.com/TexasInstruments/ble_examples/tree/simplelink_cc13xx_26xx_sdk-6.40/examples/rtos/LP_CC2651R3SIPA/ble5apps/simple_serial_socket_client.

Problem and solution while porting this example code to CC1352P7-4 is on this link,

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1344799/re-lp-cc1352p7-data-streamer-example-code-for-lp-cc1352p7/5148462 

I can send 244 bytes from UART terminal of CC1352P7 over the BLE connection to my ble peripheral CC2650 by pasting the bytes in UART terminal.

Now I want to send a array of 96000 bytes from LP-CC1352P7 to CC2650.

Basically what should be the coding approach and procedure to achieve this?

Thank you

Dnyaneshvar Salve

  • Hi,

    Thank you for reaching out.

    A few elements to consider:
    - The throughput offered by a Bluetooth LE link is lower than the UART throughput
    - The RAM left by your application won't allow you to store 96000 bytes in RAM.
    - Data not fitting in RAM will be lost

    For these reasons, I would suggest to input the data to the device by small chunks. New chunks of data should be inputted either after the data has been properly transferred (i.e. notification response is received) or after a small delay corresponding to the transfer time (i.e. 4-5 connection intervals, assuming each chunk is transmitted in one connection event and that no more than 2-3 packets in a row are left).

    I hope this will help,

    Best regards,

  • Hello Clement,

    I want to give some details.

    In function static void SimpleSerialSocketClient_processAppMsg(ssscEvt_t *pMsg){

    I have writtern code in case SSSC_EVT_OUTGOING_DATA:

    case SSSC_EVT_OUTGOING_DATA:
        {
            // You could do processing of data here ...
            // ... for now, just send the data read from UART over the air
            //copy data from uartReadBuffer into buffer very SSSC_EVT_OUTGOING_DATA is received
            if (bufferIndex < BUFFER_SIZE - 1) {
                buffer[bufferIndex++] = uartReadBuffer[0]; // Append the first character from uartReadBuffer
                buffer[bufferIndex] = '\0'; // Null-terminate the string
            } else {
            //reset if buffer full
                bufferIndex = 0;
            }
            // Search for the "scan" string inside the buffer
               if (strstr(buffer, "send") != NULL) {
                   // The "send" string is found in the buffer, perform some action
                   // For example, you can send a message over UART or take any other action
                   UART2_write(uartHandle, "send string found!\r\n", strlen("send string found!\r\n"), NULL);
                   bufferIndex = 0;
                   memset(buffer, 0, BUFFER_SIZE);
                   send_image_data = 1;
                   uint16_t connHandle2 = connHandle;
                   Send_image_byte_array(connHandle2);
            }
            // Start another read
            UART2_read(uartHandle, uartReadBuffer, UART_MAX_READ_SIZE, NULL);
    
            break;
        }


    void Send_image_byte_array(uint16_t connHandle) function is used to send 200 bytes image data (Byte array is in image.h) when "send" string is found inside buffer array (buffer array reads string from uartReadBuffer).

    I type "send" on keyboard to call this function Send_image_byte_array(uint16_t connHandle).

    So as of now I can send complete 96000 bytes from CC1352 to my BLE peripheral device (CC2650);

    But the only problem is i need to type "send" every time after 200 bytes are sent.

    every time i need to press keyboard to satisfy the case SSSC_EVT_OUTGOING_DATA and then execute Send_image_byte_array(uint16_t connHandle) function.

    How can I acheive this by only typing the "send" string once and call function Send_image_byte_array(uint16_t connHandle) repeatedly.

    (note - I dont want to use notification, so will not receive notification from CC2650 peripheral when CC1352 sends data to it)

    Thank you,

    Dnyaneshvar Salve

  • Hello,

    I have an update.

    now i have one clock object.

    Clock_Struct sendDataClock;
    
        Util_constructClock(&sendDataClock,
                            SimpleSerialSocketClient_genericClockHandler, 40, 0,
                            false,
                            SSSC_SEND_DATA_EVT);

    static void SimpleSerialSocketClient_taskFxn(UArg a0, UArg a1)
    {
        // Initialize application
        SimpleSerialSocketClient_init();
    
        buffer[0] = '\0';
        // Application main loop
        for (;;)
        {
            uint32_t events;
    
            events = Event_pend(syncEvent, Event_Id_NONE, SSSC_ALL_EVENTS,
            ICALL_TIMEOUT_FOREVER);
    
            if (events)
            {
                ICall_EntityID dest;
                ICall_ServiceEnum src;
                ICall_HciExtEvt *pMsg = NULL;
    
                if (ICall_fetchServiceMsg(&src, &dest,
                                          (void**) &pMsg) == ICALL_ERRNO_SUCCESS)
                {
                    if ((src == ICALL_SERVICE_CLASS_BLE) && (dest == selfEntity))
                    {
                        // Process inter-task message
                        SimpleSerialSocketClient_processStackMsg((ICall_Hdr*) pMsg);
                    }
    
                    if (pMsg)
                    {
                        ICall_freeMsg(pMsg);
                    }
                }
    
                // If RTOS queue is not empty, process app message
                if (events & SSSC_QUEUE_EVT)
                {
                    while (!Queue_empty(appMsgQueue))
                    {
                        ssscEvt_t *pMsg = (ssscEvt_t*) Util_dequeueMsg(appMsgQueue);
                        if (pMsg)
                        {
                            // Process message
                            SimpleSerialSocketClient_processAppMsg(pMsg);
    
                            // Free the space from the message
                            ICall_free(pMsg);
                        }
                    }
                }
    
                if (events & SSSC_START_DISCOVERY_EVT)
                {
                    SimpleSerialSocketClient_startDiscovery();
                }
    
                // Enable stream notifications
                if (events & SSSC_NOTI_ENABLE_EVT)
                {
                    // Enable notification for incoming data
                    bStatus_t retVal = SimpleStreamClient_enableNotifications(
                            connHandle);
    
                    if (retVal == SUCCESS)
                    {
                        // Consider notifications active
                        // (This might not be the case, we would have to read them back to make sure)
                        // Green LED indicates notifications is enabled
                        LED_setOn(ledHandle[CONFIG_LED_1], 100);
                    }
                }
                // Custom event to handle data sending
                if (events & SSSC_SEND_DATA_EVT)
                {
                    Send_image_byte_array(connHandle);
    //                sendingData = false; // Reset flag when done
                    Util_startClock(&sendDataClock);
                }
            }
        }
    }

    and  // Custom event to handle data sending

    static void SimpleSerialSocketClient_processAppMsg(ssscEvt_t *pMsg)
    {
    // same code as original code
    // same code as original code
    //
        case SSSC_EVT_OUTGOING_DATA:
        {
            // You could do processing of data here ...
            // ... for now, just send the data read from UART over the air
            //copy data from uartReadBuffer into buffer very SSSC_EVT_OUTGOING_DATA is received
            if (bufferIndex < BUFFER_SIZE - 1) {
                buffer[bufferIndex++] = uartReadBuffer[0]; // Append the first character from uartReadBuffer
                buffer[bufferIndex] = '\0'; // Null-terminate the string
            } else {
                //reset if buffer full
                bufferIndex = 0;
            }
            // Search for the "scan" string inside the buffer
               if (strstr(buffer, "send") != NULL) {
                   // The "scan" string is found in the buffer, perform some action
                   // For example, you can send a message over UART or take any other action
                   UART2_write(uartHandle, "Scan string found!\r\n", strlen("Scan string found!\r\n"), NULL);
                   bufferIndex = 0;
                   memset(buffer, 0, BUFFER_SIZE);
                   send_image_data = 1;
    //               uint16_t connHandle2 = connHandle;
    //               Send_image_byte_array(connHandle2);
    //            sendingData = true; // Set flag to indicate that data should be sent
    
                // Try to enable sendDataClock for the stream
                Util_startClock(&sendDataClock);
            }
            // Start another read
            UART2_read(uartHandle, uartReadBuffer, UART_MAX_READ_SIZE, NULL);
    
            break;
        }

    I can send the image byte array when i type "send" in uart terminal.
    in the case SSSC_EVT_OUTGOING_DATA: I am starting the clock.

    and clcok is generating the custome event.

    i stop the clock after image sending is complete 
    by calling Util_stopClock(&sendDataClock);

    The problem is I want to make it happen by reading response of data transfer over ble.

    status = SimpleStreamClient_sendData(connHandle,&pdataToSend[index],data_packet_len);

    The issue with periodic timer is it has hardcoded value. (40ms) (if i reduce the value data transfer suddenly fails)

    and does not take into scenarios of ble data transfer failure.

    So i want to confirm that my data is sent and then only i want to transmit next chunk of data.

    (I dont want notification, as it is going to reduce the throughput).

    thank you,

    Dnyaneshvar Salve



  • Hi Dnyaeshvar,

    If I understand correctly you need a callback for when the data has finished sending.

    How about using the SSSC_EVT_OUTGOING_DATA and posting an event?

    Cheers,

    Marie H

  • Hi

    can you please explain a little more in details.

    as fasr as i know SSSC_EVT_OUTGOING_DATA event is generated whenever there is key pressed on keyboard.

    that is SSSC_EVT_OUTGOING_DATA is generated when cc1352 uart port has some data received.

  • Hi Dnyaneshvar,

    You can ry looking at the BLE connection event callback, but I'm not sure whether this event contain any information on whether data was sent successfully.

    In our OAD implementation we have implemented a system where the OAD target requests blocks, and does not request the next block before the previous one was received successfully. Maybe you  could look into implementing something similar?

    Cheers,

    Marie H