亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sapi.c

?? 一些基于IRA環境開發的zigbee實例程序
?? C
?? 第 1 頁 / 共 3 頁
字號:
/**************************************************************************************************
  Filename:       sapi.c
  Revised:        $Date: 2007-11-13 14:49:34 -0800 (Tue, 13 Nov 2007) $
  Revision:       $Revision: 15924 $

  Description:    Z-Stack Simple Application Interface.


  Copyright 2007 Texas Instruments Incorporated. All rights reserved.

  IMPORTANT: Your use of this Software is limited to those specific rights
  granted under the terms of a software license agreement between the user
  who downloaded the software, his/her employer (which must be your employer)
  and Texas Instruments Incorporated (the "License").  You may not use this
  Software unless you agree to abide by the terms of the License. The License
  limits your use, and you acknowledge, that the Software may not be modified,
  copied or distributed unless embedded on a Texas Instruments microcontroller
  or used solely and exclusively in conjunction with a Texas Instruments radio
  frequency transceiver, which is integrated into your product.  Other than for
  the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  works of, modify, distribute, perform, display or sell this Software and/or
  its documentation for any purpose.

  YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  PROVIDED 揂S IS?WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.

  Should you have any questions regarding your right to use this Software,
  contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************/

/******************************************************************************
 * INCLUDES
 */

#include "ZComDef.h"
#include "hal_drivers.h"
#include "OSAL.h"
#include "OSAL_Tasks.h"
#include "OSAL_Custom.h"

#if defined ( MT_TASK )
  #include "MTEL.h"
#endif

#include "nwk.h"
#include "APS.h"
#include "ZDApp.h"

#include "osal_nv.h"
#include "NLMEDE.h"
#include "AF.h"
#include "OnBoard.h"
#include "nwk_util.h"
#include "ZDProfile.h"
#include "ZDObject.h"
#include "hal_led.h"
#include "hal_key.h"
#include "sapi.h"
#include "MT_SAPI.h"
#ifdef LCD_SUPPORTED
 #include "lcd128_64.h"
#endif


extern uint8 zgStartDelay;
extern uint8 zgSapiEndpoint;
/*********************************************************************
 * CONSTANTS
 */

// Message ID's for application user messages must be in 0xE0-0xEF range
#define ZB_USER_MSG                       0xE0
#define SAPICB_DATA_CNF   0xE0
#define SAPICB_BIND_CNF   0xE1
#define SAPICB_START_CNF  0xE2

/*********************************************************************
 * TYPEDEFS
 */

/*********************************************************************
 * GLOBAL VARIABLES
 */

// The order in this table must be identical to the task initialization calls below in osalInitTask.
const pTaskEventHandlerFn tasksArr[] = {
  macEventLoop,
  nwk_event_loop,
  Hal_ProcessEvent,
#if defined( MT_TASK )
  MT_ProcessEvent,
#endif
  APS_event_loop,
  ZDApp_event_loop,

  SAPI_ProcessEvent
};

const uint8 tasksCnt = sizeof( tasksArr ) / sizeof( tasksArr[0] );
uint16 *tasksEvents;

endPointDesc_t sapi_epDesc;
uint8 sapi_TaskID;
static uint16 sapi_bindInProgress;

/*********************************************************************
 * LOCAL FUNCTIONS
 */

void SAPI_ProcessZDOMsgs( zdoIncomingMsg_t *inMsg );
static void SAPI_SendCback( uint8 event, uint8 status, uint16 data );

static void SAPI_StartConfirm( uint8 status );
static void SAPI_SendDataConfirm( uint8 handle, uint8 status );
static void SAPI_BindConfirm( uint16 commandId, uint8 status );
static void SAPI_FindDeviceConfirm( uint8 searchType,
                                        uint8 *searchKey, uint8 *result );
static void SAPI_ReceiveDataIndication( uint16 source,
                              uint16 command, uint16 len, uint8 *pData  );
static void SAPI_AllowBindConfirm( uint16 source );

/******************************************************************************
 * @fn          zb_SystemReset
 *
 * @brief       The zb_SystemReset function reboots the ZigBee device.  The
 *              zb_SystemReset function can be called after a call to
 *              zb_WriteConfiguration to restart Z-Stack with the updated
 *              configuration.
 *
 * @param       none
 *
 * @return      none
 */
void zb_SystemReset ( void )
{
  SystemReset();
}

/******************************************************************************
 * @fn          zb_StartRequest
 *
 * @brief       The zb_StartRequest function starts the ZigBee stack.  When the
 *              ZigBee stack starts, the device reads configuration parameters
 *              from Nonvolatile memory and the device joins its network.  The
 *              ZigBee stack calls the zb_StartConrifm callback function when
 *              the startup process completes.
 *
 * @param       none
 *
 * @return      none
 */
void zb_StartRequest()
{
  uint8 logicalType;

  // Start the device
  // start delay = min(NWK_START_DELAY, zgStartDelay) + rand() - only for fresh start, not restore
  if ( zgStartDelay < NWK_START_DELAY )
    zgStartDelay = 0;
  else
    zgStartDelay -= NWK_START_DELAY;

  // check that bad combinations of compile flag definitions and device type
  zb_ReadConfiguration( ZCD_NV_LOGICAL_TYPE, sizeof(uint8), &logicalType );
   if (  ( logicalType > ZG_DEVICETYPE_ENDDEVICE )        ||
#if defined( RTR_NWK )
  #if defined( ZDO_COORDINATOR )
          // Only RTR or Coord possible
         ( logicalType == ZG_DEVICETYPE_ENDDEVICE )   ||
  #else
          // Only RTR possible
          ( logicalType != ZG_DEVICETYPE_ROUTER )     ||
  #endif
#else
  #if defined( ZDO_COORDINATOR )
          // Error
          ( 1 )                                     ||
  #else
          // only ED possible
          ( logicalType != ZG_DEVICETYPE_ENDDEVICE )  ||
  #endif
#endif
          ( 0 ) )
   {
     // error configuration
     SAPI_SendCback( SAPICB_START_CNF, ZInvalidParameter, 0 );
   }
   else
   {
     ZDOInitDevice(zgStartDelay);
   }

  return;
}

/******************************************************************************
 * @fn          zb_BindDevice
 *
 * @brief       The zb_BindDevice function establishes or removes a 慴inding? *              between two devices.  Once bound, an application can send
 *              messages to a device by referencing the commandId for the
 *              binding.
 *
 * @param       create - TRUE to create a binding, FALSE to remove a binding
 *              commandId - The identifier of the binding
 *              pDestination - The 64-bit IEEE address of the device to bind to
 *
 * @return      The status of the bind operation is returned in the
 *              zb_BindConfirm callback.
 */
void zb_BindDevice ( uint8 create, uint16 commandId, uint8 *pDestination )
{
  zAddrType_t destination;
  uint8 ret = ZB_ALREADY_IN_PROGRESS;

  if ( create )
  {
    if (sapi_bindInProgress == 0xffff)
    {
      if ( pDestination )
      {
        destination.addrMode = Addr64Bit;
        osal_cpyExtAddr( destination.addr.extAddr, pDestination );

        ret = APSME_BindRequest( sapi_epDesc.endPoint, commandId,
                                            &destination, sapi_epDesc.endPoint );

        if ( ret == ZSuccess )
        {
          // Find nwk addr
          ZDP_NwkAddrReq(pDestination, ZDP_ADDR_REQTYPE_SINGLE, 0, 0 );
          osal_start_timerEx( ZDAppTaskID, ZDO_NWK_UPDATE_NV, 250 );
        }
      }
      else
      {
        ret = ZB_INVALID_PARAMETER;
        destination.addrMode = Addr16Bit;
        destination.addr.shortAddr = NWK_BROADCAST_SHORTADDR;
        if ( ZDO_AnyClusterMatches( 1, &commandId, sapi_epDesc.simpleDesc->AppNumOutClusters,
                                                sapi_epDesc.simpleDesc->pAppOutClusterList ) )
        {
          // Try to match with a device in the allow bind mode
          ret = ZDP_MatchDescReq( &destination, NWK_BROADCAST_SHORTADDR,
              sapi_epDesc.simpleDesc->AppProfId, 1, &commandId, 0, (cId_t *)NULL, 0 );
        }
        else if ( ZDO_AnyClusterMatches( 1, &commandId, sapi_epDesc.simpleDesc->AppNumInClusters,
                                                sapi_epDesc.simpleDesc->pAppInClusterList ) )
        {
          ret = ZDP_MatchDescReq( &destination, NWK_BROADCAST_SHORTADDR,
              sapi_epDesc.simpleDesc->AppProfId, 0, (cId_t *)NULL, 1, &commandId, 0 );
        }

        if ( ret == ZB_SUCCESS )
        {
          // Set a timer to make sure bind completes
          osal_start_timerEx(sapi_TaskID, ZB_BIND_TIMER, AIB_MaxBindingTime);
          sapi_bindInProgress = commandId;
          return; // dont send cback event
        }
      }
    }

    SAPI_SendCback( SAPICB_BIND_CNF, ret, commandId );
  }
  else
  {
    // Remove local bindings for the commandId
    BindingEntry_t *pBind;

    // Loop through bindings an remove any that match the cluster
    while ( pBind = bindFind( sapi_epDesc.simpleDesc->EndPoint, commandId, 0 ) )
    {
      bindRemoveEntry(pBind);
    }
    osal_start_timerEx( ZDAppTaskID, ZDO_NWK_UPDATE_NV, 250 );
  }
  return;
}
/******************************************************************************
 * @fn          zb_PermitJoiningRequest
 *
 * @brief       The zb_PermitJoiningRequest function is used to control the
 *              joining permissions and thus allow or disallow new devices from
 *              joining the network.
 *
 * @param       destination - The destination parameter indicates the address
 *                            of the device for which the joining permissions
 *                            should be set. This is usually the local device
 *                            address or the special broadcast address that denotes
 *                            all routers and coordinator ( 0xFFFC ). This way
 *                            the joining permissions of a single device or the
 *                            whole network can be controlled.
 *              timeout -  Indicates the amount of time in seconds for which
 *                         the joining permissions should be turned on.
 *                         If timeout is set to 0x00, the device will turn off the
 *                         joining permissions indefinitely. If it is set to 0xFF,
 *                         the joining permissions will be turned on indefinitely.
 *
 *
 * @return      ZB_SUCCESS or a failure code
 *
 */

uint8 zb_PermitJoiningRequest ( uint16 destination, uint8 timeout )
{
#if defined( ZDO_MGMT_PERMIT_JOIN_REQUEST )
  zAddrType_t dstAddr;

  dstAddr.addrMode = Addr16Bit;
  dstAddr.addr.shortAddr = destination;

  return( (uint8) ZDP_MgmtPermitJoinReq( &dstAddr, timeout, 0, 0 ) );
#else
  return ZUnsupportedMode;
#endif
}
/******************************************************************************
 * @fn          zb_AllowBind
 *
 * @brief       The zb_AllowBind function puts the device into the
 *              Allow Binding Mode for a given period of time.  A peer device
 *              can establish a binding to a device in the Allow Binding Mode
 *              by calling zb_BindDevice with a destination address of NULL
 *
 * @param       timeout - The number of seconds to remain in the allow binding
 *                        mode.  Valid values range from 1 through 65.
 *                        If 0, the Allow Bind mode will be set false without TO
 *                        If greater than 64, the Allow Bind mode will be true
 *
 * @return      ZB_SUCCESS if the device entered the allow bind mode, else
 *              an error code.
 */
void zb_AllowBind ( uint8 timeout )

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲香肠在线观看| 另类的小说在线视频另类成人小视频在线 | 国产精品免费网站在线观看| 蓝色福利精品导航| 日韩三区在线观看| 日日夜夜精品视频天天综合网| 91国偷自产一区二区三区观看| 最新久久zyz资源站| 白白色 亚洲乱淫| 日韩毛片精品高清免费| 99久久久国产精品免费蜜臀| 亚洲色图欧美在线| 91黄色激情网站| 亚洲大片精品永久免费| 欧美三级电影在线看| 亚洲成人av一区二区| 欧美精品久久久久久久久老牛影院| 五月天精品一区二区三区| 欧美日韩五月天| 人人精品人人爱| 欧美成人综合网站| 国产精品正在播放| 国产精品理论在线观看| 91小视频免费看| 亚洲成人自拍一区| 日韩欧美激情一区| 国产福利91精品一区二区三区| 久久久99精品久久| kk眼镜猥琐国模调教系列一区二区| 日韩毛片高清在线播放| 在线免费不卡电影| 免费人成网站在线观看欧美高清| 欧美xxxx在线观看| 成人性色生活片| 有码一区二区三区| 欧美一区二区三区四区视频| 国产在线精品一区二区夜色 | 性久久久久久久| 日韩欧美一卡二卡| 成人污污视频在线观看| 亚洲人xxxx| 91麻豆精品国产91久久久久久 | 欧美日韩综合色| 蜜桃视频在线观看一区| 亚洲精品一区二区三区四区高清| 成人精品国产福利| 亚洲综合一区二区精品导航| 91精品一区二区三区久久久久久 | 99久久婷婷国产精品综合| 亚洲综合免费观看高清完整版在线| 一区二区三区四区在线播放| 欧美人妇做爰xxxⅹ性高电影| 国产在线乱码一区二区三区| 综合电影一区二区三区| 欧美一区二区三区免费观看视频| 国产精品一区二区在线观看网站| 亚洲人成网站在线| 欧美一级欧美三级在线观看| 国产成人av电影| 亚洲成av人片在线观看无码| 日韩一级免费观看| jiyouzz国产精品久久| 一区二区免费在线播放| 亚洲国产高清在线观看视频| 久久97超碰色| 宅男噜噜噜66一区二区66| 国产精品福利一区| 国产精品1区2区3区| 欧美一区二区在线视频| 蜜桃精品视频在线观看| 欧美亚洲一区二区在线观看| 在线观看91视频| 不卡视频一二三四| 视频一区二区国产| 成人精品gif动图一区| 日韩亚洲欧美一区二区三区| 国产精品第一页第二页第三页| 国产午夜精品理论片a级大结局| 成人亚洲一区二区一| 亚洲国产欧美在线| 国产婷婷精品av在线| 欧美日韩精品免费观看视频| 成人黄色网址在线观看| 免费高清在线一区| 日本欧洲一区二区| 久久久久久影视| 欧美日韩国产中文| 97se亚洲国产综合自在线不卡| 五月婷婷激情综合| 亚洲丝袜自拍清纯另类| xnxx国产精品| 5566中文字幕一区二区电影| 91丨九色丨蝌蚪富婆spa| 国产麻豆精品在线| 免费视频最近日韩| 亚洲成人精品影院| 亚洲欧洲国产专区| 国产色产综合产在线视频| 这里是久久伊人| 欧美三级中文字幕在线观看| www.亚洲激情.com| 国产99精品国产| 久久se精品一区精品二区| 婷婷久久综合九色综合伊人色| 亚洲欧美视频一区| 亚洲国产激情av| 久久久精品综合| 亚洲精品在线电影| 日韩一区二区在线看片| 欧美日本免费一区二区三区| 色悠悠久久综合| 最新欧美精品一区二区三区| 欧美激情综合五月色丁香| 久久在线免费观看| 精品国产乱码久久久久久浪潮| 欧美美女喷水视频| 欧美日本视频在线| 欧美日韩在线免费视频| 色欧美片视频在线观看在线视频| 北条麻妃国产九九精品视频| 福利一区二区在线观看| 国产一区二区三区黄视频 | 国产日韩欧美不卡在线| 欧美成人三级在线| 日韩欧美色综合网站| 91精品国产品国语在线不卡| 欧美精品久久久久久久多人混战| 欧美日韩一区精品| 欧美午夜在线一二页| 欧美色图一区二区三区| 欧美日韩国产精选| 制服丝袜一区二区三区| 欧美日韩免费观看一区二区三区 | 国产精品久久久久9999吃药| 国产午夜精品一区二区| 日本一区二区三区免费乱视频| 久久嫩草精品久久久精品一| 久久精品亚洲国产奇米99| 国产日韩av一区二区| 欧美高清一级片在线观看| 中文字幕永久在线不卡| 亚洲日本在线观看| 亚洲一二三区不卡| 日韩福利视频导航| 久久国产福利国产秒拍| 国产一区二区不卡| 成人黄色在线网站| 91九色02白丝porn| 欧美视频一区二区三区四区 | 亚洲一区二区3| 日韩福利电影在线观看| 久久精品国产久精国产| 国产精品中文字幕日韩精品| 国产成人三级在线观看| 91在线看国产| 欧美欧美欧美欧美首页| 日韩精品一区二区三区蜜臀| 久久久久久久精| 亚洲欧洲另类国产综合| 亚洲小少妇裸体bbw| 麻豆精品久久精品色综合| 国产麻豆精品久久一二三| 99久久国产免费看| 欧美欧美午夜aⅴ在线观看| 日韩欧美精品在线| 国产精品理论在线观看| 亚洲国产成人91porn| 激情文学综合插| av成人动漫在线观看| 欧美日韩精品高清| 久久综合久久综合亚洲| 国产精品全国免费观看高清| 亚洲资源中文字幕| 久久国产精品一区二区| 不卡免费追剧大全电视剧网站| 在线观看成人免费视频| 精品三级在线看| 亚洲欧洲综合另类| 日韩—二三区免费观看av| 国产成人福利片| 精品婷婷伊人一区三区三| 久久女同精品一区二区| 亚洲综合色成人| 国产美女主播视频一区| 色婷婷精品大在线视频| 日韩视频在线一区二区| 中文字幕一区二区三区乱码在线| 视频一区二区三区入口| 国产大陆a不卡| 欧美日韩免费电影| 久久精品亚洲精品国产欧美kt∨| 亚洲一区在线观看免费| 狠狠色狠狠色综合日日91app| 91麻豆国产福利在线观看| 欧美成人一区二区三区片免费| 亚洲人成影院在线观看| 黑人巨大精品欧美一区| 欧美影院精品一区| 欧美激情一区二区三区四区| 日韩精品乱码av一区二区|