📄 zdcache.s51
字号:
// 193 // Skip first byte == total length of descriptor.
// 194 if (ZDO_ParseSimpleDescBuf( data+1, &desc )) {
// 195 // malloc failed -- we can't do this...
// 196 return ZDP_NOT_PERMITTED;
// 197 }
// 198
// 199 if ( (desc.AppNumInClusters <= CACHE_CR_MAX) &&
// 200 (desc.AppNumOutClusters <= CACHE_CR_MAX) )
// 201 {
// 202 byte epIdx = getIdxEP( idx, desc.EndPoint );
// 203
// 204 if ( epIdx == CACHE_EP_MAX )
// 205 {
// 206 rtrn = ZDP_NOT_PERMITTED;
// 207 }
// 208 else
// 209 {
// 210 SimpleDescriptionFormat_t *pDesc = &(SimpDesc[idx][epIdx]);
// 211
// 212 osal_memcpy( pDesc->pAppInClusterList, desc.pAppInClusterList,
// 213 desc.AppNumInClusters*sizeof(uint16) );
// 214 osal_memcpy( pDesc->pAppOutClusterList, desc.pAppOutClusterList,
// 215 desc.AppNumOutClusters*sizeof(uint16) );
// 216
// 217 pDesc->EndPoint = desc.EndPoint;
// 218 pDesc->AppProfId = desc.AppProfId;
// 219 pDesc->AppDeviceId = desc.AppDeviceId;
// 220 pDesc->AppDevVer = desc.AppDevVer;
// 221 pDesc->Reserved = desc.Reserved;
// 222 pDesc->AppNumInClusters = desc.AppNumInClusters;
// 223 pDesc->AppNumOutClusters = desc.AppNumOutClusters;
// 224
// 225 rtrn = ZDP_SUCCESS;
// 226 }
// 227 }
// 228
// 229 // free up the malloc'ed cluster lists
// 230 if (desc.AppNumInClusters) {
// 231 osal_mem_free(desc.pAppInClusterList);
// 232 }
// 233 if (desc.AppNumOutClusters) {
// 234 osal_mem_free(desc.pAppOutClusterList);
// 235 }
// 236
// 237 return rtrn;
// 238 }
// 239
// 240 /*********************************************************************
// 241 * @fn processFindNodeCacheReq
// 242 *
// 243 * @brief Process a Find_node_cache_req
// 244 *
// 245 * @return none
// 246 */
// 247 static void processFindNodeCacheReq( byte *data )
// 248 {
// 249 uint16 aoi = BUILD_UINT16( data[0], data[1] );
// 250 byte idx = getIdx( aoi );
// 251
// 252 if ( idx == CACHE_DEV_MAX )
// 253 {
// 254 idx = getIdxExt ( data+2 );
// 255 }
// 256
// 257 if ( idx != CACHE_DEV_MAX )
// 258 {
// 259 byte buf[2+2+Z_EXTADDR_LEN];
// 260
// 261 buf[0] = LO_UINT16( ZDAppNwkAddr.addr.shortAddr );
// 262 buf[1] = HI_UINT16( ZDAppNwkAddr.addr.shortAddr );
// 263 buf[2] = LO_UINT16( NwkAddr[idx] );
// 264 buf[3] = HI_UINT16( NwkAddr[idx] );
// 265 osal_cpyExtAddr( buf+4, ExtAddr[idx] );
// 266
// 267 SendMsg( Find_node_cache_rsp, 2+2+Z_EXTADDR_LEN, buf );
// 268 }
// 269 }
// 270
// 271 /*********************************************************************
// 272 * @fn processMgmtCacheReq
// 273 *
// 274 * @brief Process a Mgmt_cache_req
// 275 *
// 276 * @return none
// 277 */
// 278 static void processMgmtCacheReq( byte idx )
// 279 {
// 280 const byte max =
// 281 (((CACHE_DEV_MAX-idx) * (2 + Z_EXTADDR_LEN) + 1) < MAX_PKT_LEN) ?
// 282 ((CACHE_DEV_MAX-idx) * (2 + Z_EXTADDR_LEN) + 1) : MAX_PKT_LEN;
// 283 byte *buf = osal_mem_alloc( max );
// 284 byte status = ZDP_INSUFFICIENT_SPACE;
// 285 byte cnt = 1;
// 286
// 287 if ( buf == NULL )
// 288 {
// 289 buf = &status;
// 290 }
// 291 else
// 292 {
// 293 byte *ptr = buf;
// 294 *ptr++ = ZDP_SUCCESS;
// 295 *ptr++ = getCnt();
// 296 *ptr++ = idx;
// 297 *ptr++ = 0;
// 298
// 299 for ( idx = getNth( idx ); idx < CACHE_DEV_MAX; idx++ )
// 300 {
// 301 if ( cnt >= (max - (2 + Z_EXTADDR_LEN)) )
// 302 {
// 303 break;
// 304 }
// 305
// 306 if ( NwkAddr[idx] != INVALID_NODE_ADDR )
// 307 {
// 308 ptr = osal_cpyExtAddr( ptr, ExtAddr[idx] );
// 309 *ptr++ = LO_UINT16( NwkAddr[idx] );
// 310 *ptr++ = HI_UINT16( NwkAddr[idx] );
// 311 cnt += (2 + Z_EXTADDR_LEN);
// 312 buf[3]++;
// 313 }
// 314 }
// 315 }
// 316
// 317 SendMsg( Mgmt_Cache_rsp, cnt, buf );
// 318
// 319 if ( buf != NULL )
// 320 {
// 321 osal_mem_free( buf );
// 322 }
// 323 }
// 324
// 325 /*********************************************************************
// 326 * @fn getCnt
// 327 *
// 328 * @return The count of valid cache entries.
// 329 *
// 330 */
// 331 static byte getCnt( void )
// 332 {
// 333 byte cnt = 0;
// 334 byte idx;
// 335
// 336 for ( idx = 0; idx < CACHE_DEV_MAX; idx++ )
// 337 {
// 338 if ( NwkAddr[idx] != INVALID_NODE_ADDR )
// 339 {
// 340 cnt++;
// 341 }
// 342 }
// 343
// 344 return cnt;
// 345 }
// 346
// 347 /*********************************************************************
// 348 * @fn getIdx
// 349 *
// 350 * @brief Find the idx into the Discovery Cache Arrays corresponding to
// 351 * the given short address.
// 352 *
// 353 * @param uint16 - a valid 16 bit short address.
// 354 *
// 355 * @return If address found, return the valid index, else CACHE_DEV_MAX.
// 356 *
// 357 */
// 358 static byte getIdx( uint16 addr )
// 359 {
// 360 byte idx;
// 361
// 362 for ( idx = 0; idx < CACHE_DEV_MAX; idx++ )
// 363 {
// 364 if ( addr == NwkAddr[idx] )
// 365 {
// 366 break;
// 367 }
// 368 }
// 369
// 370 return idx;
// 371 }
// 372
// 373 /*********************************************************************
// 374 * @fn getNth
// 375 *
// 376 * @param byte - the Nth idx sought.
// 377 *
// 378 * @return If N or more entries exist, return the index of the Nth entry,
// 379 * else CACHE_DEV_MAX.
// 380 *
// 381 */
// 382 static byte getNth( byte Nth )
// 383 {
// 384 byte cnt = 0;
// 385 byte idx;
// 386
// 387 for ( idx = 0; idx < CACHE_DEV_MAX; idx++ )
// 388 {
// 389 if ( NwkAddr[idx] != INVALID_NODE_ADDR )
// 390 {
// 391 if ( cnt++ >= Nth )
// 392 {
// 393 break;
// 394 }
// 395 }
// 396 }
// 397
// 398 return idx;
// 399 }
// 400
// 401 /*********************************************************************
// 402 * @fn getIdxExt
// 403 *
// 404 * @brief Find the idx into the Discovery Cache Arrays corresponding to
// 405 * the given IEEE address.
// 406 *
// 407 * @param byte * - a valid buffer containing an extended IEEE address.
// 408 *
// 409 * @return If address found, return the valid index, else CACHE_DEV_MAX.
// 410 *
// 411 */
// 412 static byte getIdxExt( byte *ieee )
// 413 {
// 414 byte idx;
// 415
// 416 for ( idx = 0; idx < CACHE_DEV_MAX; idx++ )
// 417 {
// 418 if ( osal_ExtAddrEqual( ieee, ExtAddr[idx] ) &&
// 419 (NwkAddr[idx] != INVALID_NODE_ADDR) )
// 420 {
// 421 break;
// 422 }
// 423 }
// 424
// 425 return idx;
// 426 }
// 427
// 428 /*********************************************************************
// 429 * @fn getIdxEP
// 430 *
// 431 * @brief Find the idx into the EndPoint Array corresponding to the idx of a
// 432 * cached short address.
// 433 *
// 434 * @param byte - a valid index of a cached 16 bit short address.
// 435 * @param byte - the EndPoint of interest.
// 436 *
// 437 * @return If EndPoint found, return the valid index, else CACHE_EP_MAX.
// 438 *
// 439 */
// 440 static byte getIdxEP( byte idx, byte ep )
// 441 {
// 442 byte epIdx;
// 443
// 444 for ( epIdx = 0; epIdx < EPCnt[idx]; epIdx++ )
// 445 {
// 446 if ( ep == EPArr[idx][epIdx] )
// 447 {
// 448 break;
// 449 }
// 450 }
// 451
// 452 if ( epIdx == EPCnt[idx] )
// 453 {
// 454 epIdx = CACHE_EP_MAX;
// 455 }
// 456
// 457 return epIdx;
// 458 }
// 459
// 460 /*********************************************************************
// 461 * @fn purgeAddr
// 462 *
// 463 * @brief Purge every instance of given network address from Discovery Cache.
// 464 *
// 465 * @param uint16 - a 16-bit network address.
// 466 *
// 467 */
// 468 static byte purgeAddr( uint16 addr )
// 469 {
// 470 byte idx, cnt = 0;
// 471
// 472 for ( idx = 0; idx < CACHE_DEV_MAX; idx++ )
// 473 {
// 474 if ( NwkAddr[idx] == addr )
// 475 {
// 476 NwkAddr[idx] = INVALID_NODE_ADDR;
// 477 cnt++;
// 478 }
// 479 }
// 480
// 481 return cnt;
// 482 }
// 483
// 484 /*********************************************************************
// 485 * @fn purgeIEEE
// 486 *
// 487 * @brief Purge every instance of given IEEE from Discovery Cache.
// 488 *
// 489 * @param ZLongAddr_t - a valid IEEE address.
// 490 *
// 491 */
// 492 static byte purgeIEEE( byte *ieee )
// 493 {
// 494 byte idx, cnt = 0;
// 495
// 496 for ( idx = 0; idx < CACHE_DEV_MAX; idx++ )
// 497 {
// 498 if ( osal_ExtAddrEqual( ieee, ExtAddr[idx] ) &&
// 499 (NwkAddr[idx] != INVALID_NODE_ADDR) )
// 500 {
// 501 NwkAddr[idx] = INVALID_NODE_ADDR;
// 502 cnt++;
// 503 }
// 504 }
// 505
// 506 return cnt;
// 507 }
// 508 #endif
// 509
// 510 /*********************************************************************
// 511 * @fn ZDCacheInit
// 512 *
// 513 * @brief Initialize ZDO Cache environment.
// 514 *
// 515 */
// 516 void ZDCacheInit( void )
// 517 {
// 518
// 519 msgAddr.endPoint = ZDO_EP;
// 520 msgAddr.addrMode = afAddr16Bit;
// 521 msgAddr.addr.shortAddr = INVALID_NODE_ADDR;
// 522 radius = AF_DEFAULT_RADIUS;
// 523 (void)secUse;
// 524
// 525 #if ( CACHE_DEV_MAX > 0 )
// 526 byte idx;
// 527
// 528 for ( idx = 0; idx < CACHE_DEV_MAX; idx++ )
// 529 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -