📄 mt_af.s51
字号:
// 105 //First the Endpoint
// 106 epDesc->simpleDesc = ( SimpleDescriptionFormat_t * )
// 107 osal_mem_alloc( sizeof( SimpleDescriptionFormat_t ) );
// 108
// 109 if ( epDesc->simpleDesc )
// 110 {
// 111 epDesc->endPoint = *pData++;
// 112 epDesc->simpleDesc->EndPoint = epDesc->endPoint;
// 113
// 114 epDesc->task_id = &MT_TaskID;
// 115
// 116 //Now for the simple description part
// 117 epDesc->simpleDesc->AppProfId = BUILD_UINT16( pData[1],pData[0]);
// 118 pData += sizeof( uint16 );
// 119 epDesc->simpleDesc->AppDeviceId = BUILD_UINT16( pData[1],pData[0]);
// 120 pData += sizeof( uint16 );
// 121 epDesc->simpleDesc->AppDevVer = (*pData++) & AF_APP_DEV_VER_MASK ;
// 122 epDesc->simpleDesc->Reserved = (*pData++) & AF_APP_FLAGS_MASK ;
// 123
// 124 epDesc->simpleDesc->AppNumInClusters = *pData++;
// 125
// 126 if (epDesc->simpleDesc->AppNumInClusters)
// 127 {
// 128 epDesc->simpleDesc->pAppInClusterList = (uint16 *)
// 129 osal_mem_alloc(ZTEST_DEFAULT_PARAM_LEN*sizeof(uint16));
// 130
// 131 for (i=0; i<ZTEST_DEFAULT_PARAM_LEN; i++) {
// 132 epDesc->simpleDesc->pAppInClusterList[i] = BUILD_UINT16(*pData, 0);
// 133 pData++;
// 134 }
// 135 }
// 136 else
// 137 {
// 138 pData += ZTEST_DEFAULT_PARAM_LEN;
// 139 }
// 140
// 141 epDesc->simpleDesc->AppNumOutClusters = *pData++;
// 142
// 143 if (epDesc->simpleDesc->AppNumOutClusters)
// 144 {
// 145 epDesc->simpleDesc->pAppOutClusterList = (uint16 *)
// 146 osal_mem_alloc(ZTEST_DEFAULT_PARAM_LEN*sizeof(uint16));
// 147
// 148 for (i=0; i<ZTEST_DEFAULT_PARAM_LEN; i++) {
// 149 epDesc->simpleDesc->pAppOutClusterList[i] = BUILD_UINT16(*pData, 0);
// 150 pData++;
// 151 }
// 152 }
// 153 else
// 154 {
// 155 pData += ZTEST_DEFAULT_PARAM_LEN;
// 156 }
// 157
// 158 epDesc->latencyReq = (afNetworkLatencyReq_t)*pData;
// 159
// 160 if ( afFindEndPointDesc( epDesc->endPoint ) == NULL )
// 161 {
// 162 af_stat = afRegister( epDesc );
// 163 }
// 164 }
// 165 else
// 166 {
// 167 osal_mem_free( epDesc );
// 168 af_stat = afStatus_MEM_FAIL;
// 169 }
// 170 }
// 171
// 172 len = SPI_0DATA_MSG_LEN + SPI_RESP_LEN_AF_DEFAULT;
// 173 MT_SendSPIRespMsg( af_stat, SPI_CMD_AF_REGISTER, len, SPI_RESP_LEN_AF_DEFAULT );
// 174
// 175 break;
// 176
// 177 case SPI_CMD_AF_SENDMSG:
// 178 {
// 179 #if ( AF_KVP_SUPPORT )
// 180 afKVPCommandFormat_t kvp;
// 181 afAddOrSend_t addOrSend;
// 182 byte frameType;
// 183 #else
// 184 endPointDesc_t *epDesc;
// 185 byte transId;
// 186 #endif
// 187 afAddrType_t dstAddr;
// 188 cId_t cId;
// 189 byte txOpts, radius, srcEP;
// 190
// 191 #if ( AF_KVP_SUPPORT )
// 192 frameType = *pData;
// 193 #endif
// 194 pData++;
// 195 txOpts = *pData++;
// 196 radius = *pData++;
// 197
// 198 // Fill the AF structures with the data received.
// 199 dstAddr.addrMode = afAddr16Bit;
// 200 dstAddr.addr.shortAddr = BUILD_UINT16( pData[1], pData[0] );
// 201 pData += 2;
// 202 dstAddr.endPoint = *pData++;
// 203
// 204 srcEP = *pData++;
// 205 cId = BUILD_UINT16( pData[1], pData[0] );
// 206 pData += 2;
// 207 #if ( AF_KVP_SUPPORT )
// 208 addOrSend = (afAddOrSend_t)(*pData++);
// 209 kvp.TransSeqNumber = *pData++;
// 210 kvp.CommandType = *pData++;
// 211 kvp.AttribDataType = *pData++;
// 212 kvp.AttribId = BUILD_UINT16( pData[1], pData[0] );
// 213 pData += 2;
// 214 kvp.ErrorCode = *pData++;
// 215 kvp.DataLength = *pData++;
// 216 kvp.Data = pData;
// 217
// 218 af_stat = afAddOrSendMessage( &dstAddr, srcEP, cId,
// 219 addOrSend, frameType, &kvp.TransSeqNumber,
// 220 kvp.CommandType, kvp.AttribDataType, kvp.AttribId, kvp.ErrorCode,
// 221 kvp.DataLength, kvp.Data, (txOpts & ~AF_DISCV_ROUTE),
// 222 (txOpts & AF_DISCV_ROUTE), radius );
// 223 #else
// 224 pData++;
// 225 transId = *pData++;
// 226 pData += 5;
// 227 len = *pData++;
// 228 epDesc = afFindEndPointDesc( srcEP );
// 229 if ( epDesc == NULL )
// 230 {
// 231 af_stat = afStatus_INVALID_PARAMETER;
// 232 }
// 233 else
// 234 {
// 235 af_stat = AF_DataRequest( &dstAddr, epDesc, cId, len, pData,
// 236 &transId, txOpts, radius );
// 237 }
// 238 #endif
// 239
// 240 len = SPI_0DATA_MSG_LEN + SPI_RESP_LEN_AF_DEFAULT;
// 241 MT_SendSPIRespMsg( af_stat, SPI_CMD_AF_SENDMSG,
// 242 len, SPI_RESP_LEN_AF_DEFAULT );
// 243 }
// 244 break;
// 245 }
// 246 }
// 247 #endif // #if defined ( MT_AF_FUNC )
// 248
// 249 #if defined ( MT_AF_CB_FUNC )
// 250 /*********************************************************************
// 251 * @fn af_MTCB_IncomingData
// 252 *
// 253 * @brief Process the callback subscription for AF Incoming data.
// 254 *
// 255 * @param pkt - Incoming AF data.
// 256 *
// 257 * @return none
// 258 */
// 259 void af_MTCB_IncomingData( void *pkt )
// 260 {
// 261 afIncomingMSGPacket_t *MSGpkt = (afIncomingMSGPacket_t *)pkt;
// 262 #if ( AF_KVP_SUPPORT )
// 263 afIncomingKVPPacket_t *KVPpkt = (afIncomingKVPPacket_t *)pkt;
// 264 #endif
// 265 byte *memPtr, *ptr;
// 266 /* Frametype, WasBroadcast, LinkQuality, SecurityUse, SrcAddr,
// 267 * SrcEndpoint, DestEndpoint, ClusterId, TransCnt, TransId, CmdType,
// 268 * AttribDataType, AttribId, ErrorCode, TransDataLen =
// 269 * 1+1+1+1+2+1+1+2+1+1+1+2+1+1+1.
// 270 */
// 271 const byte len = 18 + ZTEST_DEFAULT_AF_DATA_LEN;
// 272 byte dataLen;
// 273
// 274 if ( MSGpkt->hdr.event != AF_INCOMING_MSG_CMD )
// 275 {
// 276 #if ( AF_KVP_SUPPORT )
// 277 dataLen = KVPpkt->cmd.DataLength;
// 278 #else
// 279 return;
// 280 #endif
// 281 }
// 282 else
// 283 {
// 284 dataLen = MSGpkt->cmd.DataLength;
// 285 }
// 286
// 287 if ( dataLen > ZTEST_DEFAULT_AF_DATA_LEN )
// 288 {
// 289 dataLen = ZTEST_DEFAULT_AF_DATA_LEN;
// 290 }
// 291
// 292 memPtr = osal_mem_alloc( len );
// 293 if ( !memPtr )
// 294 {
// 295 return;
// 296 }
// 297 ptr = memPtr;
// 298
// 299 #if ( AF_KVP_SUPPORT )
// 300 if ( MSGpkt->hdr.event != AF_INCOMING_MSG_CMD )
// 301 {
// 302 *ptr++ = KVPpkt->hdr.event;
// 303 *ptr++ = KVPpkt->wasBroadcast;
// 304 *ptr++ = KVPpkt->LinkQuality;
// 305 *ptr++ = KVPpkt->SecurityUse;
// 306 *ptr++ = HI_UINT16( KVPpkt->srcAddr.addr.shortAddr );
// 307 *ptr++ = LO_UINT16( KVPpkt->srcAddr.addr.shortAddr );
// 308 *ptr++ = KVPpkt->srcAddr.endPoint;
// 309 *ptr++ = KVPpkt->endPoint;
// 310 *ptr++ = HI_UINT16( KVPpkt->clusterId );
// 311 *ptr++ = LO_UINT16( KVPpkt->clusterId );
// 312 *ptr++ = KVPpkt->totalTrans;
// 313 *ptr++ = KVPpkt->cmd.TransSeqNumber;
// 314 *ptr++ = KVPpkt->cmd.CommandType;
// 315 *ptr++ = KVPpkt->cmd.AttribDataType;
// 316 *ptr++ = HI_UINT16( KVPpkt->cmd.AttribId );
// 317 *ptr++ = LO_UINT16( KVPpkt->cmd.AttribId );
// 318 *ptr++ = KVPpkt->cmd.ErrorCode;
// 319 *ptr++ = KVPpkt->cmd.DataLength;
// 320 osal_memcpy( ptr, KVPpkt->cmd.Data, dataLen );
// 321 }
// 322 else
// 323 #endif
// 324 {
// 325 *ptr++ = MSGpkt->hdr.event;
// 326 *ptr++ = MSGpkt->wasBroadcast;
// 327 *ptr++ = MSGpkt->LinkQuality;
// 328 *ptr++ = MSGpkt->SecurityUse;
// 329 *ptr++ = HI_UINT16( MSGpkt->srcAddr.addr.shortAddr );
// 330 *ptr++ = LO_UINT16( MSGpkt->srcAddr.addr.shortAddr );
// 331 *ptr++ = MSGpkt->srcAddr.endPoint;
// 332 *ptr++ = MSGpkt->endPoint;
// 333 *ptr++ = HI_UINT16( MSGpkt->clusterId );
// 334 *ptr++ = LO_UINT16( MSGpkt->clusterId );
// 335 osal_memset( ptr, 0, 7 );
// 336 ptr += 7;
// 337 osal_memcpy( ptr, MSGpkt->cmd.Data, dataLen );
// 338 }
// 339
// 340 if ( dataLen < ZTEST_DEFAULT_AF_DATA_LEN )
// 341 {
// 342 osal_memset( (ptr + dataLen), 0, (ZTEST_DEFAULT_AF_DATA_LEN - dataLen) );
// 343 }
// 344
// 345 #if defined (ZTOOL_P1) || defined (ZTOOL_P2)
// 346 MT_BuildAndSendZToolCB( SPI_CB_AF_DATA_IND, len, memPtr );
// 347 #endif
// 348 osal_mem_free( memPtr );
// 349 }
// 350 #endif // #if defined ( MT_AF_CB_FUNC )
// 351
// 352 /*********************************************************************
// 353 *********************************************************************/
//
//
// 0 bytes of memory
//
//Errors: none
//Warnings: none
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -