微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI蓝牙设计交流 > 删除。。。

删除。。。

时间:10-02 整理:3721RD 点击:

现在可以了。。

ouc qzy ,

你可以参考一下CC2640的ANCS例子,这个里面功能比较全,应用层面的代码应该和254x是兼容的,你可以移植:

http://processors.wiki.ti.com/index.php/Cc2640_ANCS_Sample

你好,

这个,你需要单步调试调试

第一步,开始发现服务DISC_ANCS_START

第二步,发现ANCS服务 DISC_ANCS_SVC

第三步,发现CHAR DISC_ANCS_CHAR

第四步,发现DISC_ANCS_CCCD。

你可以在下面的switch case中一个一个设置断点,开是否都可以跑到对应的函数里面。

希望我的回答对你有帮助。

static uint8 TimeAppDiscAlertNtf( uint8 state, gattMsgEvent_t *pMsg )

{

  uint8 newState = state;

  

  switch ( state )

  {

    case DISC_ANCS_START: 

      {

        uint8 uuid[ATT_UUID_SIZE] = ANCS_SVC_UUID;

        // Initialize service discovery variables

        timeAppSvcStartHdl = timeAppSvcEndHdl = 0;

        timeAppEndHdlIdx = 0;

        

        // Discover service by UUID

        GATT_DiscPrimaryServiceByUUID( timeAppConnHandle, uuid,

                                       ATT_UUID_SIZE, timeAppTaskId );     

        newState = DISC_ANCS_SVC;

      }

      break;

    case DISC_ANCS_SVC:

      // Service found, store handles

      if ( pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP &&

           pMsg->msg.findByTypeValueRsp.numInfo > 0 )

      {

        timeAppSvcStartHdl = ATT_ATTR_HANDLE(pMsg->msg.findByTypeValueRsp.pHandlesInfo, 0);

        timeAppSvcEndHdl = ATT_GRP_END_HANDLE(pMsg->msg.findByTypeValueRsp.pHandlesInfo, 0);

      }

      

      // If procedure complete

      if ( ( pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP  &&

             pMsg->hdr.status == bleProcedureComplete ) ||

           ( pMsg->method == ATT_ERROR_RSP ) )

      {

        // If service found

        if ( timeAppSvcStartHdl != 0 )

        {

          // Discover all characteristics

          GATT_DiscAllChars( timeAppConnHandle, timeAppSvcStartHdl,

                             timeAppSvcEndHdl, timeAppTaskId );

          

          newState = DISC_ANCS_CHAR;

        }

        else

        {

          // Service not found

          newState = DISC_FAILED;

        }

      }   

      break;

    case DISC_ANCS_CHAR:

      {

        uint8   i;

        uint8   *p;

        uint16  handle;

        uint16  uuid;

        

        // Characteristics found

        if ( pMsg->method == ATT_READ_BY_TYPE_RSP &&

             pMsg->msg.readByTypeRsp.numPairs > 0 &&

             pMsg->msg.readByTypeRsp.len == CHAR_DESC_HDL_UUID128_LEN )

        {

          // For each characteristic declaration

          p = pMsg->msg.readByTypeRsp.pDataList;

          for ( i = pMsg->msg.readByTypeRsp.numPairs; i > 0; i-- )

          {

            // Parse characteristic declaration

            handle = BUILD_UINT16(p[3], p[4]);

            uuid = BUILD_UINT16(p[5], p[6]);

                   

            // If looking for end handle

            if ( timeAppEndHdlIdx != 0 )

            {

              // End handle is one less than handle of characteristic declaration

              timeAppHdlCache[timeAppEndHdlIdx] = BUILD_UINT16(p[0], p[1]) - 1;

              

              timeAppEndHdlIdx = 0;

            }

            // If UUID is of interest, store handle

            switch ( uuid )

            {

              case ANCS_NOTIF_CHAR_UUID:

                timeAppHdlCache[HDL_ANCS_NTF_NOTIF_START] = handle;

                timeAppEndHdlIdx = HDL_ANCS_NTF_NOTIF_END;

                break;

                

              default:

                break;

            }

            

            p += CHAR_DESC_HDL_UUID128_LEN;

          }

          

        }

          

        // If procedure complete

        if ( ( pMsg->method == ATT_READ_BY_TYPE_RSP  &&

               pMsg->hdr.status == bleProcedureComplete ) ||

             ( pMsg->method == ATT_ERROR_RSP ) )

        {

          // Special case of end handle at end of service

          if ( timeAppEndHdlIdx != 0 )

          {

            timeAppHdlCache[timeAppEndHdlIdx] = timeAppSvcEndHdl;

            timeAppEndHdlIdx = 0;

          }

          // If didn't find mandatory characteristic

          if ( timeAppHdlCache[HDL_ANCS_NTF_NOTIF_START] == 0 )

          {

            newState = DISC_FAILED;

          }

          else if ( timeAppHdlCache[HDL_ANCS_NTF_NOTIF_START] <

                    timeAppHdlCache[HDL_ANCS_NTF_NOTIF_END] )

          {

            // Discover characteristic descriptors

            GATT_DiscAllCharDescs( timeAppConnHandle,

                                   timeAppHdlCache[HDL_ANCS_NTF_NOTIF_START] + 1,

                                   timeAppHdlCache[HDL_ANCS_NTF_NOTIF_END],

                                   timeAppTaskId );

                                        

            newState = DISC_ANCS_CCCD;

          }

          else

          {

            newState = DISC_IDLE;

          }

        }

      }     

      break;

      

      case DISC_ANCS_CCCD:

      {

        uint8 i;

        

        // Characteristic descriptors found

        if ( pMsg->method == ATT_FIND_INFO_RSP &&

             pMsg->msg.findInfoRsp.numInfo > 0 &&

             pMsg->msg.findInfoRsp.format == ATT_HANDLE_BT_UUID_TYPE )

        {

          // For each handle/uuid pair

          for ( i = 0; i < pMsg->msg.findInfoRsp.numInfo; i++ )

          {

            // Look for CCCD

            if ( ATT_BT_PAIR_UUID(pMsg->msg.findInfoRsp.pInfo, i) ==

                                                     GATT_CLIENT_CHAR_CFG_UUID )

            {

              // CCCD found

              timeAppHdlCache[HDL_ANCS_NTF_CCCD] =

                             ATT_BT_PAIR_HANDLE(pMsg->msg.findInfoRsp.pInfo, i);

              

              break;

            }

          }

        }

        

        // If procedure complete

        if ( ( pMsg->method == ATT_FIND_INFO_RSP  &&

               pMsg->hdr.status == bleProcedureComplete ) ||

             ( pMsg->method == ATT_ERROR_RSP ) )

        {

          newState = DISC_IDLE;

        }

      }

      break;

    default:

      break;

  }

  

  return newState;

}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top