TI中文支持网
TI专业的中文技术问题搜集分享网站

怎样配置一个TouchLink Target?

添加预编译

BDB_TL_TARGET
INTER_PAN

然后用按键启动target,但是每次按下按键0后都会重启是怎么回事?还是说我的启动流程是错的?

 if(keys & HAL_KEY_SW_0)
   {
      HalLcdWriteString("BDB_TL!!", 3);
      //bdb_StartCommissioning(BDB_COMMISSIONING_MODE_INITIATOR_TL);
       bdb_TouchlinkSetAllowStealing(1);
       touchLinkTarget_EnableCommissioning( TOUCHLINK_TARGET_PERPETUAL-10 );
   }

Alvin Chen:

预编译BDB_TOUCHLINK_CAPABILITY_ENABLED == TRUE

你可以去看一下ZR Light (touchlink target) and ZR Switch (touchlink initiator)

启动设置为bdb_StartCommissioning(BDB_COMMISSIONING_MODE_INITIATOR_TL);

然后去追踪程序:

#if ( defined ( BDB_TL_INITIATOR ) && (BDB_TOUCHLINK_CAPABILITY_ENABLED == TRUE) )if(bdbAttributes.bdbCommissioningMode & BDB_COMMISSIONING_MODE_INITIATOR_TL){uint16 nwkAddr;//Does the device supports this commissioning mode?if(bdbAttributes.bdbNodeCommissioningCapability & BDB_TOUCHLINK_CAPABILITY){//Clear previous state and substatesosal_memset(&bdbCommissioningProcedureState,0,sizeof(bdbCommissioningProcedureState));bdbCommissioningProcedureState.bdbCommissioningState = BDB_COMMISSIONING_STATE_TL;// Get our short addressZMacGetReq( ZMacShortAddress, (byte*)&nwkAddr );// Check if address is invalidif ( nwkAddr >= NWK_BROADCAST_SHORTADDR_DEVZCZR ){initiatorSelectNwkParams();}touchLinkInitiator_StartDevDisc( );bdb_NotifyCommissioningModeStart(BDB_COMMISSIONING_TOUCHLINK);}

上面的程ZR Light (touchlink target) and ZR Switch (touchlink initiator)中callback已经写好了,具体流程去看Z-Stack 3.0 Developer's Guide

one Man:

回复 Alvin Chen:

您好
Z-Stack中已经有了BDB_TOUCHLINK_CAPABILITY_ENABLED的配置,如下:#if defined ( INTER_PAN ) && ( defined ( BDB_TL_INITIATOR ) || defined ( BDB_TL_TARGET ) )#define BDB_TOUCHLINK_CAPABILITY_ENABLED1#else#define BDB_TOUCHLINK_CAPABILITY_ENABLED0#endif
我现在是Target 收不到TouchLink的Scan Request。

Alvin Chen:

回复 one Man:

你有没有跳到 touchLinkInitiator_StartDevDisc( );这句话?

one Man:

回复 Alvin Chen:

有的,但target就是收不到REQUEST

Alvin Chen:

回复 one Man:

抓包又发出吗?没有response?

在touchLinkTargetApp_Init中注册了 bdbTL_RegisterInterPANCmdCallbacks(&touchLinkTarget_CmdCBs);

这个回调最后出去rsp。

static ZStatus_t targetNwkStartReqCB( afAddrType_t *srcAddr, bdbTLNwkStartReq_t *pReq, uint8 seqNum )
{
#if ZSTACK_END_DEVICE_BUILDreturn ( ZFailure );
#elseif ( touchLink_IsValidTransID( pReq->transID ) == FALSE ){return ( ZFailure );}dstAddr = *srcAddr;dstAddr.panId = 0xFFFF;zstack_tlTargetNwkStartReq_t *pTargetNwkStartReq;pTargetNwkStartReq = (zstack_tlTargetNwkStartReq_t*)zcl_mem_alloc( sizeof(zstack_tlTargetNwkStartReq_t) );zcl_memcpy(&(pTargetNwkStartReq->addr), &dstAddr, sizeof(afAddrType_t));zcl_memcpy(&(pTargetNwkStartReq->nwkStartReq), pReq, sizeof(bdbTLNwkStartReq_t));pTargetNwkStartReq->seqNum = seqNum;pTargetNwkStartReq->allowStealing = touchlinkAppAllowStealing;Zstackapi_tlTargetNwkStartReqInd(tlAppEntity, pTargetNwkStartReq);zcl_mem_free(pTargetNwkStartReq);return ( ZSuccess );
#endif
}

zstack_ZStatusValues Zstackapi_tlTargetNwkStartReqInd(ICall_EntityID appEntity, zstack_tlTargetNwkStartReq_t *pReq){// Build and send the message, then wait of the response messagereturn( sendReqDefaultRsp(appEntity, zstackmsg_CmdIDs_TL_TARGET_NWK_START_REC_IND,pReq, sizeof(zstackmsg_tlTargetNwkStartReq_t),matchTLTargetNetworkStartReqInd) );}

你用的是我让你用的那个两个ZR程序?

one Man:

回复 Alvin Chen:

Target 收到req后到了这里,但 抓包没发现scan Response

static ZStatus_t targetScanReqCB( afAddrType_t *srcAddr, bdbTLScanReq_t *pReq, uint8 seqNum )

{

 ZStatus_t ret = ZSuccess;

 int8 rssi;

 char buff[4];

 extern void HalLcdWriteStringValue( char *title, uint32 value, uint8 format, uint8 line );

 extern void HalLcdWriteString ( char *str, uint8 option);

 HalLcdWriteStringValue("TL_I", pReq->touchLinkInitiator,10, 1);

 if( pReq->touchLinkInitiator == FALSE )

 {

   return ZFailure;

 }

 rssi = touchLink_GetMsgRssi();

 sprintf(buff, "%d", rssi);

 HalLcdWriteString(buff,  2);

 if( rssi > TOUCHLINK_WORST_RSSI )

 {

   if ( pDiscoveredNwkParamList == NULL )

   {

     dstAddr = *srcAddr;

     dstAddr.panId = 0xFFFF;

     ret = touchLink_TargetSendScanRsp( TOUCHLINK_INTERNAL_ENDPOINT, &dstAddr, pReq->transID, seqNum );

     if ( ret == ZSuccess )

     {

       touchLinkTransID = pReq->transID;

     }

   }

 }

 HalLcdWriteStringValue("ret", ret, 10, 3);

 return ( ret ); //返回0

}

one Man:

回复 Alvin Chen:

因为我的板子是自己做的,所以没有用你说的那两个ZR程序,但是我是按照那两个程序来改的。

Alvin Chen:

回复 one Man:

我大致说一下,我这边是可以的,因为没带PC只能用Wireshark抓包就不上传了。

TARGET:

           zstack_bdbStartCommissioningReq.commissioning_mode =

       BDB_COMMISSIONING_MODE_NWK_STEERING|BDB_COMMISSIONING_MODE_NWK_FORMATION;

           Zstackapi_bdbStartCommissioningReq(zclSampleLight_Entity,&zstack_bdbStartCommissioningReq);

           touchLinkTarget_EnableCommissioning( TOUCHLINK_TARGET_PERPETUAL);

BDB_TL_INITIATOR :

zstack_bdbStartCommissioningReq_t zstack_bdbStartCommissioningReq;

       zstack_bdbStartCommissioningReq.commissioning_mode = BDB_COMMISSIONING_MODE_INITIATOR_TL;

       Zstackapi_bdbStartCommissioningReq(zclSampleSw_Entity,&zstack_bdbStartCommissioningReq);

one Man:

回复 Alvin Chen:

我在Samplelight找不到以下两个函数/变量
Zstackapi_bdbStartCommissioningReq,zstack_bdbStartCommissioningReq

Alvin Chen:

回复 one Man:

我这个是CC2652R,类似于bdb_StartCommissioning(BDB_COMMISSIONING_MODE_INITIATOR_TL);

赞(0)
未经允许不得转载:TI中文支持网 » 怎样配置一个TouchLink Target?
分享到: 更多 (0)