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:如何从 LP-CC1352P7向其他 BLE 外设发送多字节(96000字节)数据?

Guru**** 2391365 points
Other Parts Discussed in Thread: CC1352P7, LP-CC1352P7, CC2650

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1354006/lp-cc1352p7-how-to-send-multi-byte-96000-bytes-data-from-lp-cc1352p7-to-other-ble-peripheral

器件型号:LP-CC1352P7
主题中讨论的其他器件:CC1352P7CC2650

您好、TI!

我已  从该 GitHub 链接移植代码 simple_serial_socket_client、

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

有关将此示例代码移植到 CC1352P7-4时的问题和解决方案、请访问此链接、

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 

我可以 通过 BLE 连接从 CC1352P7的 UART 终端发送244个字节、方法是在 UART 终端中粘贴这些字节。

现在、我要将一个96000字节的数组从 LP-CC1352P7发送到 CC2650。

基本上、实现该目标应该采用什么编码方法和过程?

谢谢!

D·萨尔维

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    感谢您与我们联系。

    需要考虑的几个因素:
    -低功耗蓝牙链路提供的吞吐量低于 UART 吞吐量
    -您的应用程序留下的 RAM 不允许您在 RAM 中存储96000字节。
    -数据不在 RAM 中将丢失

    出于这些原因、我建议用小块将数据输入到器件中。 应在数据已正确传输(即接收到通知响应)或传输时间相应的短暂延迟(即4-5个连接间隔、 假设在一个连接事件中传输每个块、并且连续中没有超过2-3个数据包)。

    我希望这将有所帮助、

    此致、

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Clement、

    我想提供一些详细信息。

    IN 函数  静态空 SimpleSerialSocketClient_processAppMsg (ssscEvt_t * pMsg){

    我有写代码  案例 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;
        }


    send_image_Byte_array (uint16_t connHandle)  函数用于发送 200字节 图像数据 (字节数组在 image.h 中) 当在 缓冲区数组中找到"send"字符串时(缓冲区数组从 uartReadBuffer 读取字符串)。

    我在键盘上键入"send"以调用该函数  send_image_Byte_array (uint16_t connHandle)。

    因此、到目前为止、我可以将完整的96000字节从 CC1352发送到我的 BLE 外设器件(CC2650);

    但唯一的问题是、每次 发送200个字节后我都需要键入"send"。

    每次我需要按键盘来满足机箱要求  SSSC_EVT_Outgoing_data 然后执行 send_image_Byte_array (uint16_t connHandle)  停止。

    如何通过只键入"send"字符串一次并调用函数来实现此目的  send_image_Byte_array (uint16_t connHandle) 重复。

    (注-我不想使用通知、因此当 CC1352向 CC2650外设发送数据时、不会从 CC2650外设接收通知)

    谢谢!

    D·萨尔维

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    我有新消息。

    现在我 有一个时钟对象。

    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);
                }
            }
        }
    }

    和  //自定义事件以处理数据发送

    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;
        }

    当我在 UART 终端中键入"send"时、我可以发送映像字节数组。
    在  案例 SSSC_EVT_Outgoing_data: 我正在启动时钟。

    而 clcok 会产生定制事件。

    我在图像发送完成后停止时钟  
    通过调用  Util_stopClock (&sendDataClock);

    问题是、我希望通过读取布尔数据传输的响应来实现这一目标。

    状态= SimpleStreamClient_sendData (connHandle、&pdataToSend[index]、data_packet_len);

    周期计时器的问题在于它具有硬编码值。 (40ms)(如果我减小数据传输突然失败的值)

    并且不考虑低数据传输故障的情况。

    因此、我想确认我的数据是否已发送、然后只想传输下一个数据块。

    (我不需要通知、因为它会降低吞吐量)。

    谢谢!

    D·萨尔维



  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Dnyaeshvar:

    如果我理解正确、您需要在数据发送完成时进行回调。

    如何使用 SSSC_EVT_outgoing_data 和发布事件?

    谢谢、

    M·H

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 :  

    您能详细解释一下吗?

    正如我所知道的那样 、 只要在键盘上按键、就会生成 SSSC_EVT_EXTING_DATA 事件。

    即、  当 cc1352 UART 端口接收到一些数据时、会生成 SSSC_EVT_Outgoing_data。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Dnyaneshvar:

    您可以仔细查看 BLE 连接事件回调、但我不确定该事件是否包含任何有关数据是否已成功发送的信息。

    在 OAD 实施中、我们实现了一个 OAD 目标请求阻止的系统、并且在成功接收前一个块之前不会请求下一个块。 也许您 可以考虑实施类似的方案吗?

    谢谢、

    M·H