亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
成人综合激情网| 色悠悠亚洲一区二区| 亚洲黄色性网站| 亚洲美女精品一区| 国产精品剧情在线亚洲| 国产精品免费av| 国产精品拍天天在线| 中文字幕在线观看不卡| 成人欧美一区二区三区小说 | 亚洲午夜在线视频| 一区二区三区欧美亚洲| 亚洲小说春色综合另类电影| 视频在线观看国产精品| 亚洲国产精品人人做人人爽| 午夜av一区二区| 蜜桃av一区二区| 久久99精品国产91久久来源| 国产成人午夜99999| 9人人澡人人爽人人精品| 91免费小视频| 欧美唯美清纯偷拍| 日韩三级中文字幕| 国产欧美精品一区二区色综合| 亚洲国产激情av| 亚洲另类中文字| 青青草成人在线观看| 国产一区不卡视频| 色狠狠桃花综合| 欧美一区二区三区男人的天堂| 久久午夜羞羞影院免费观看| 国产精品久久一卡二卡| 午夜天堂影视香蕉久久| 国产精品99久久久久久似苏梦涵 | 国产成人精品三级| 在线看不卡av| 精品国产91洋老外米糕| 《视频一区视频二区| 天堂蜜桃91精品| 国产99久久久国产精品潘金网站| 95精品视频在线| 日韩欧美综合在线| 亚洲视频一区二区在线| 久久精品噜噜噜成人88aⅴ| www.日本不卡| 日韩欧美高清一区| 亚洲一区免费在线观看| 国产福利一区二区三区| 欧美四级电影在线观看| 久久综合狠狠综合久久综合88| 亚洲综合一区二区精品导航| 国产成人在线观看| 欧美一区二区三区四区视频| 亚洲欧美怡红院| 国产成人av影院| 51精品久久久久久久蜜臀| 中文字幕视频一区| 国产乱码精品一区二区三区av| 在线视频你懂得一区| 国产精品日日摸夜夜摸av| 久久国产婷婷国产香蕉| 欧美日韩一卡二卡| 中文字幕一区二区三区色视频 | 国产亚洲一区二区三区在线观看| 亚洲va中文字幕| 91在线观看美女| 中文av一区特黄| 精品制服美女丁香| 日韩精品一区二区三区swag| 日本大胆欧美人术艺术动态| 欧美日韩大陆在线| 亚洲一区二区三区四区在线观看| 99视频热这里只有精品免费| 国产日韩欧美制服另类| 久久99在线观看| 欧美大片一区二区三区| 开心九九激情九九欧美日韩精美视频电影 | 亚洲欧洲精品一区二区精品久久久| 国产一区二区三区四区五区美女| 日韩欧美激情在线| 精品在线播放午夜| 26uuuu精品一区二区| 久久99热狠狠色一区二区| 欧美电影免费观看高清完整版| 日韩国产欧美三级| 欧美videos大乳护士334| 麻豆精品新av中文字幕| 欧美精品一区二区三区视频| 国产美女精品在线| 2020日本不卡一区二区视频| 国产乱码精品一区二区三| 中文字幕巨乱亚洲| 91蝌蚪porny| 午夜精品影院在线观看| 日韩一区二区在线看| 国内精品视频666| 国产女主播一区| 一本色道a无线码一区v| 亚洲国产精品久久一线不卡| 欧美乱熟臀69xxxxxx| 另类综合日韩欧美亚洲| 精品精品国产高清一毛片一天堂| 岛国精品在线观看| 亚洲综合激情另类小说区| 欧美精选一区二区| 狠狠v欧美v日韩v亚洲ⅴ| 国产精品久久久久毛片软件| 在线观看日产精品| 久久精品99国产精品| 中文字幕制服丝袜成人av| 欧美日韩一区高清| 国产成人日日夜夜| 一区二区国产盗摄色噜噜| 欧美电视剧在线观看完整版| 色天天综合色天天久久| 老色鬼精品视频在线观看播放| 亚洲欧洲国产专区| 日韩精品一区二区三区在线 | 欧美视频一区在线| 国产在线观看一区二区| 亚洲午夜一区二区三区| 久久精品在线观看| 欧美精品日韩综合在线| 不卡的电影网站| 蜜桃视频在线一区| 一区二区三区免费网站| 久久精品人人做| 91精品欧美久久久久久动漫| 99久久国产免费看| 国产一区二区三区综合| 日韩高清一区在线| 亚洲人成在线观看一区二区| 久久久亚洲午夜电影| 欧美福利视频一区| 色婷婷亚洲综合| 成人性视频免费网站| 麻豆视频观看网址久久| 亚洲gay无套男同| 一区二区三区自拍| 国产欧美在线观看一区| 日韩欧美一区二区三区在线| 欧美影院精品一区| 成人精品视频网站| 国产麻豆午夜三级精品| 另类综合日韩欧美亚洲| 水蜜桃久久夜色精品一区的特点| 亚洲私人影院在线观看| 国产喷白浆一区二区三区| 精品国产91九色蝌蚪| 日韩三级在线观看| 日韩欧美国产一区二区在线播放| 欧美日韩亚洲综合在线 | 欧美乱熟臀69xxxxxx| 欧美天堂亚洲电影院在线播放| 91免费观看国产| 色综合色综合色综合色综合色综合 | 制服丝袜成人动漫| 欧美猛男超大videosgay| 欧美午夜精品电影| 欧美优质美女网站| 欧美日韩国产综合一区二区三区 | 人妖欧美一区二区| 天堂蜜桃一区二区三区| 美女一区二区三区在线观看| 美女一区二区三区| 国产专区欧美精品| 9i在线看片成人免费| 成人久久18免费网站麻豆| 成人免费观看视频| 色偷偷成人一区二区三区91| 色噜噜久久综合| 51久久夜色精品国产麻豆| 日韩一区二区在线观看视频播放| 精品盗摄一区二区三区| 久久久久久影视| 国产精品久久综合| 亚洲成在线观看| 九九精品一区二区| caoporn国产一区二区| 欧美三级韩国三级日本三斤| 欧美另类videos死尸| 欧美成人午夜电影| 国产欧美一区二区在线| 亚洲精品伦理在线| 精品一区中文字幕| 91视频com| 欧美大肚乱孕交hd孕妇| 中文字幕国产精品一区二区| 亚洲综合一区二区| 国产精品一级片| 欧美伊人久久大香线蕉综合69| 欧美一卡二卡在线| 国产精品麻豆网站| 夜夜亚洲天天久久| 精品一区二区三区蜜桃| 成人aaaa免费全部观看| 欧美一区二区三区在线电影| 国产精品国产三级国产三级人妇| 日本特黄久久久高潮| av在线不卡免费看| 精品99999|