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.

[参考译文] CC2674R10:如何发送包含256字节特性的完整数据

Guru**** 2387060 points
Other Parts Discussed in Thread: CC1354P10, AFE4960, SYSCONFIG, CC2674R10, TMP117
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1296752/cc2674r10-how-to-send-the-full-data-of-a-characteristic-which-contain-256-bytes

器件型号:CC2674R10
主题中讨论的其他器件:AFE4960SysConfig、CC1354P10、 TMP117

大家好、

我将 PROJECT_ZERO 用于我的项目。 我修改温度处理以通过 SPI 从 AFE4960发送 ECG 数据。 在原始程序中 App_Process,温度是浮空的,使用 GAT45I Cfg 作为通知。  

我要通过无线发送的数据长度为256个字节。 与 GATT45Cc App_Process Cesg,这一过程是在任务背景下完成的。 我只能使用通知发送256中的前20个字节、并且无法将所有数据全部发送出去。 您能提供一些解决这个问题的建议吗?

另一个问题是 、传感器的数据每128ms 更新一次、 如果发现我的程序读取和发送数据时速度很慢、我如何才能使其快速读取更新的 数据?

非常感谢

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

    Matthew 您好!

    感谢您的联系。

    请帮助我回答以下问题。

    1. 您正在使用哪个 SDK 版本?
    2. 您配置的 PDU 的最大大小(字节)是多少? 请参阅 SysConfig 中的 ble.maxPDUSize 或一般配置。
    3. 您是否在电话上启用了通知? 右侧的"启用"开关。

    我建议查看 此处的 simple_serial_socket_server 示例 (使用通知、最大 PDU 大小为255)。

    Br、

    大卫。

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

    尊敬的 David:

    感谢您的答复。

    1。我使用的 SDK 是 simplelink_cc13xx_cc26xx_sdk_7_10_01_24、项目0适用于 CC1354P10_1、我针对 CC2674R10修改了它

    2.我设置的最大尺寸为255

    3.是的,我在电话中启用了通知,并得到了20字节的通知消息,如下面的红框。 在禁用通知时捕获 pic。

     对于  simple_serial_socket_server 示例、该示例针对 cc26x2、我尝试将其修改为 cc2674、但它无法正常工作、我在此 线程中提出了问题

    马修

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

    Matthew 您好!

    您能否多分享一下您对代码所做的修改? (代码片段)

    您是否也将特征的大小增加到255?

    我可能值得使用蓝牙监听器进行检查、看看 TX 有效载荷是否实际为255左右、以便在中央器件(手机)上发现问题。

    simple_serial_socket_server 示例可以帮助您了解为增加大小的有效载荷而需要考虑的具体修改。

    Br、

    大卫。

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

    Matthew 您好!

    请允许我用一天的时间来讲解代码。

    手机应该不会受到限制、但是能够监听器始终有助于确保外设有效载荷大小符合预期。

    我猜 TMP117_DataVal 是在另一个文件中定义的? simple_gat_profile.c? 您是否也增加了特征的大小?

    Br、

    大卫。

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

    尊敬的 David:

     TMP117_DataVal 定义如下、长度设为256。 电话收到的通知是20字节

    // Characteristic "Data" Properties (for declaration)
    static uint8_t TMP117_DataProps = GATT_PROP_READ | GATT_PROP_NOTIFY;
    // Characteristic "Data" Value variable
    static uint8_t TMP117_DataVal[TMP117_DATA_LEN] = {0};
    
    
    //  Characteristic DATA 1 defines
    #define TMP117_DATA_ID   3
    #define TMP117_DATA_UUID 0xAA01
    #define TMP117_DATA_LEN  256

    马修

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

    Matthew、您好!

    仔细查看您的代码、我无法看到您分配通知的位置。 代码应该与 SimpleStreamServerI-translation Node ()函数(链接到我们的 GitHub)类似。 函数如下所示:

    /*********************************************************************
     * @fn          SimpleStreamServer_transmitNode
     *
     * @brief       Transmits as much as possible of a SimpleStreamNode_t node
     *              over BLE notifications.
     *
     * @param       node - The node to send
     *
     * @return      SUCCESS, FAILURE, INVALIDPARAMETER, MSG_BUFFER_NOT_AVAIL,
     *              bleNotCOnnected, bleMemAllocError, blePending, bleInvaludMtuSize or
     *              bleTimeout
     */
    static bStatus_t SimpleStreamServer_transmitNode( SimpleStreamNode_t* node)
    {
        bStatus_t ret = SUCCESS;
        attHandleValueNoti_t noti;
        linkDBInfo_t connInfo;
    
        // Find out what the maximum MTU size is
        ret = linkDB_GetInfo(node->connHandle, &connInfo);
    
        // Queue up as many notification slots as possible
        if ( (ret == SUCCESS) && (node != NULL) ) {
    
            // Determine allocation size
            uint16_t allocLen = (node->len - node->offset);
            if ( allocLen > (connInfo.MTU - SSS_NOTI_HDR_SIZE) )
            {
                allocLen = connInfo.MTU - SSS_NOTI_HDR_SIZE;
            }
    
            noti.len = 0;
            noti.pValue = (uint8 *)GATT_bm_alloc( node->connHandle, ATT_HANDLE_VALUE_NOTI,
                                                  allocLen, &noti.len );
    
            // If allocation was successful, copy out data out of the buffer and send it
            if (noti.pValue) {
    
                memcpy(noti.pValue, (void *) ((uint8_t *) node->payload + node->offset), noti.len);
    
                // The outgoing data attribute offset is 4
                noti.handle = SimpleStreamServerAttrTbl[4].handle;
    
                ret = GATT_Notification( node->connHandle, &noti, FALSE );
    
                // If unable to send the message, free allocated buffers and return
                if ( ret != SUCCESS )
                {
                    GATT_bm_free( (gattMsg_t *)&noti, ATT_HANDLE_VALUE_NOTI );
                }
                else
                {
                    // Increment node data offset
                    node->offset += noti.len;
                }
            }
            else
            {
                // Unable to allocate space for a notification, return failure
                ret = bleMemAllocError;
            }
        }
    
        return ret;
    }

    如您所见、有一个到 GATT_BM_ALLOC()的调用先分配实际通知。 我在您的代码片段中看不到该函数。 当我们通过无线方式发送通知时、它应该位于某个位置。 我想确认我们为每份通知分配的时间长度。 使用我们调用 GATT_Notification ()的函数也会有所帮助。

    通过获取蓝牙监听器日志、我们可以确定我们发送的是具有预期长度的负载、并且手机未正确处理该负载、或者我们发送的数量不正确、并且问题出在外围设备上。

    此致、

    1月

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

    大家好、Jan、

    我  在 iCall_api_lite.c 文件中找不到函数 GATT_BM_alloc ()、但我项目中的这个块被标记为未使用、我在项目中找不到任何其他对此函数的调用。 函数 I call notification 为 Gatt45g App_Process Cesg. 无法 查看此功能处理通知的方式。

    #ifndef STACK_LIBRARY
    /* This variable exit on teh stack side, and it is always equal to the maximum
     number of possible connection. It is also used in a file share between
    application and stack. */
    uint8 linkDBNumConns = MAX_NUM_BLE_CONNS;
    
    /*********************************************************************
     * @fn      GATT_bm_alloc
     *
     * @brief   GATT implementation of the allocator functionality.
     *
     *          Note: This function should only be called by GATT and
     *                the upper layer protocol/application.
     *
     * @param   connHandle - connection that message is to be sent on.
     * @param   opcode - opcode of message that buffer to be allocated for.
     * @param   size - number of bytes to allocate from the heap.
     * @param   pSizeAlloc - number of bytes allocated for the caller from the heap.
     *
     * @return  pointer to the heap allocation; NULL if error or failure.
     */
    void *GATT_bm_alloc(uint16 connHandle, uint8 opcode, uint16 size, uint16 *pSizeAlloc)
    {
      if (pfnBMAlloc != NULL)
      {
        return (*pfnBMAlloc)(BM_MSG_GATT, size, connHandle, opcode, pSizeAlloc);
      }
    
      return ((void *)NULL);
    }
    
    /*********************************************************************
     * @fn      GATT_bm_free
     *
     * @brief   GATT implementation of the de-allocator functionality.
     *
     * @param   pMsg - pointer to the message containing the memory to free.
     * @param   opcode - opcode of the message.
     *
     * @return  none
     */
    void GATT_bm_free(gattMsg_t *pMsg, uint8 opcode)
    {
      if (pfnBMFree != NULL)
      {
        (*pfnBMFree)(BM_MSG_GATT, pMsg, opcode);
      }
    }
    
    /*********************************************************************
     * @fn      L2CAP_bm_alloc
     *
     * @brief   L2CAP implementation of the allocator functionality.
     *
     *          Note: This function should only be called by L2CAP and
     *                the upper layer protocol/application.
     *
     * @param   size - number of bytes to allocate from the heap.
     *
     * @return  pointer to the heap allocation; NULL if error or failure.
     */
    void *L2CAP_bm_alloc( uint16 size )
    {
      if (pfnBMAlloc != NULL)
      {
        return (*pfnBMAlloc)(BM_MSG_L2CAP, size, 0, 0, NULL);
      }
    
      return ((void *)NULL);
    }
    #endif /* !STACK_LIBRARY */
    

    马修

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

    Matthew、您好!

    提供的函数用于在使用 GATT_Notification ()发送通知有效载荷之前动态分配通知有效载荷。

    此致、

    1月