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.

CC2640R2 接收透传数据打印至串口发现不全。

Other Parts Discussed in Thread: CC2541, CC2640

协议栈:simplelink_cc2640r2_sdk_1_50_00_58

处理器:CC2640R2

问题描述:

使用“simple_serial_socket_server”例程:https://github.com/ti-simplelink/ble_examples/tree/master/examples/rtos/CC26X2R1_LAUNCHXL/ble5apps/simple_serial_socket_server

连接参数为:

// Minimum connection interval (units of 1.25ms) if automatic parameter update request is enabled
#define DEFAULT_DESIRED_MIN_CONN_INTERVAL 32
// Maximum connection interval (units of 1.25ms) if automatic parameter update request is enabled
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL 48
// Slave latency to use if automatic parameter update request is enabled
#define DEFAULT_DESIRED_SLAVE_LATENCY 0
// Supervision timeout value (units of 10ms) if automatic parameter update request is enabled
#define DEFAULT_DESIRED_CONN_TIMEOUT 500

成功连接上后,使用安卓微信小程序向蓝牙模块发送 25KB 的图片数据,通过串口打印出来之后发现数据不全,请问有什么方法可以解决吗?

  • 是否能在新版本的协议栈上测试一下?这个例程是基于2.20.00.00以上的:github.com/.../simplelink_cc2640r2_sdk-2.20
  • 这个协议栈在串口处理部分还有蓝牙数据接收不部分的处理是一样的,接收到数据之后在回调函数中将透传数据写入 list,然后调用“UART_write()”写串口函数,在串口写回调中一直写。但是我打印出来发现数据不全,不可能 CC2640 处理不及吧,我用 CC2541 都可以接受完全的。
  • 我发现“UART_write()”函数的函数头里面有这么一段话:
    * @warning Do not call %UART_write() from its own callback function when in
    * #UART_MODE_CALLBACK.
    为什么例程中还要在“uartWriteCallback”中调用 UART_write() 呢?

    static void uartWriteCallback(UART_Handle handle, void *txBuf, size_t size)
    {
    // Free the last printed buffer
    if (NULL != uartCurrentMsg)
    {
    ICall_free(uartCurrentMsg);
    uartCurrentMsg = NULL;
    }

    // If the list is not empty, start another write
    if (!List_empty(&uartWriteList))
    {
    uartCurrentMsg = (uartMsg_t *) List_get(&uartWriteList);
    UART_write(uartHandle, uartCurrentMsg->buffer, uartCurrentMsg->len);
    }
    else
    {
    uartWriteActive = 0;
    }
    }
  • 这个warning是指在UART_MODE_CALLBACK模式下,不要在driver自身的回调函数中调用UART_read()或UART_write(),会导致额外的任务或者堆栈需求
  • 我直接使用这个基于2.20.00.00以上的例程:github.com/.../simplelink_cc2640r2_sdk-2.20
    安卓手机 APP 发送 25KB 的数据给 BLE 模块,BLE 模块串口打印出来的数据还是漏了。
    请问这是什么问题?我把“POWER_SAVING”都关了的。