⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mt_sapi.s51

📁 CC2430上开关控制灯和温度传感器采集两个例子
💻 S51
📖 第 1 页 / 共 2 页
字号:
//   93 
//   94     case SPI_CMD_SAPI_START_REQ:
//   95       zb_StartRequest();
//   96       break;
//   97 
//   98     case SPI_CMD_SAPI_BIND_DEVICE:
//   99       MT_ReverseBytes( &pData[3], Z_EXTADDR_LEN );
//  100       for ( i = 0; i < Z_EXTADDR_LEN ; i++ )
//  101       {
//  102         if ( pData[3+i] != 0x00 )
//  103         {
//  104           // Not a null destination address
//  105           break;
//  106         }
//  107       }
//  108       if ( i == Z_EXTADDR_LEN )
//  109       {
//  110         zb_BindDevice(pData[0], BUILD_UINT16(pData[2], pData[1]), (uint8 *)NULL);
//  111       }
//  112       else
//  113       {
//  114         zb_BindDevice(pData[0], BUILD_UINT16(pData[2], pData[1]), &pData[3]);
//  115       }
//  116       break;
//  117 
//  118     case SPI_CMD_SAPI_ALLOW_BIND:
//  119       zb_AllowBind( pData[0]);
//  120       break;
//  121 
//  122     case SPI_CMD_SAPI_SEND_DATA:
//  123       zb_SendDataRequest(BUILD_UINT16(pData[1], pData[0]), BUILD_UINT16(pData[3], pData[2]),
//  124                         pData[4], &pData[8], pData[5], pData[6], pData[7]);
//  125       break;
//  126 
//  127     case SPI_CMD_SAPI_READ_CFG:
//  128       i = (uint8)osal_nv_item_len( pData[0] );
//  129       pBuf = osal_mem_alloc(i+3);
//  130       if (pBuf)
//  131       {
//  132         pBuf[1] = pData[0]; // configId
//  133         pBuf[2] = i;        // len
//  134         if ( i )
//  135           ret = zb_ReadConfiguration(pData[0], i, pBuf+3);
//  136         else
//  137           ret = ZInvalidParameter;
//  138         pBuf[0] = ret;      // status
//  139         MT_BuildAndSendZToolCB( SPI_CB_SAPI_READ_CFG_RSP, i+3, pBuf );
//  140         osal_mem_free(pBuf);
//  141       }
//  142       ret = 0xff;   // Disable return spi message
//  143       break;
//  144 
//  145     case SPI_CMD_SAPI_WRITE_CFG:
//  146       ret = zb_WriteConfiguration(pData[0], pData[1], &pData[2]);
//  147       break;
//  148 
//  149     case SPI_CMD_SAPI_GET_DEV_INFO:
//  150       pBuf = osal_mem_alloc(Z_EXTADDR_LEN+1);
//  151       if (pBuf)
//  152       {
//  153         zb_GetDeviceInfo(pData[0], pBuf+1);
//  154         pBuf[0] = pData[0];
//  155         MT_BuildAndSendZToolCB( SPI_CB_SAPI_DEV_INFO_RSP, Z_EXTADDR_LEN+1, pBuf );
//  156         osal_mem_free(pBuf);
//  157       }
//  158       ret = 0xff;   // Disable return spi message
//  159       break;
//  160 
//  161     case SPI_CMD_SAPI_FIND_DEV:
//  162       // Currently only supports IEEE search
//  163       MT_ReverseBytes( pData, Z_EXTADDR_LEN );
//  164       zb_FindDeviceRequest(ZB_IEEE_SEARCH, pData);
//  165       break;
//  166 
//  167     case SPI_CMD_SAPI_PMT_JOIN:
//  168       ret = zb_PermitJoiningRequest( BUILD_UINT16( pData[1], pData[0] ), pData[2] );
//  169       break;
//  170 
//  171     default:
//  172       break;
//  173   }
//  174 
//  175   return ret;
//  176 }
//  177 #endif  // #if defined ( MT_SAPI_FUNC )
//  178 
//  179 #if defined ( MT_SAPI_CB_FUNC )
//  180 
//  181 /******************************************************************************
//  182  * @fn          zb_MTCallbackStartConfirm
//  183  *
//  184  * @brief       Process the callback subscription for zb_StartConfirm
//  185  *
//  186  * @param
//  187  *
//  188  * @return      none
//  189  */
//  190 void zb_MTCallbackStartConfirm( uint8 status )
//  191 {
//  192   uint8 memPtr[SPI_CB_SAPI_START_CNF_LEN];
//  193 
//  194   memPtr[0] = status;
//  195 
//  196 #if defined (ZTOOL_P1) || defined (ZTOOL_P2)
//  197   MT_BuildAndSendZToolCB( SPI_CB_SAPI_START_CNF, SPI_CB_SAPI_START_CNF_LEN, memPtr );
//  198 #endif
//  199 }
//  200 
//  201 /******************************************************************************
//  202  * @fn          zb_MTCallbackSendDataConfirm
//  203  *
//  204  * @brief       Process the callback subscription for zb_SendDataConfirm
//  205  *
//  206  * @param
//  207  *
//  208  * @return      none
//  209  */
//  210 void zb_MTCallbackSendDataConfirm( uint8 handle, uint8 status )
//  211 {
//  212   uint8 memPtr[SPI_CB_SAPI_SEND_DATA_CNF_LEN];
//  213 
//  214   memPtr[0] = handle;
//  215   memPtr[1] = status;
//  216 
//  217 #if defined (ZTOOL_P1) || defined (ZTOOL_P2)
//  218   MT_BuildAndSendZToolCB( SPI_CB_SAPI_SEND_DATA_CNF, SPI_CB_SAPI_SEND_DATA_CNF_LEN, memPtr );
//  219 #endif
//  220 }
//  221 
//  222 /******************************************************************************
//  223  * @fn          zb_MTCallbackBindConfirm
//  224  *
//  225  * @brief       Process the callback subscription for zb_BindConfirm
//  226  *
//  227  * @param
//  228  *
//  229  * @return      none
//  230  */
//  231 void zb_MTCallbackBindConfirm( uint16 commandId, uint8 status )
//  232 {
//  233   uint8 memPtr[SPI_CB_SAPI_BIND_CNF_LEN];
//  234 
//  235   memPtr[0] = HI_UINT16(commandId);
//  236   memPtr[1] = LO_UINT16(commandId);
//  237   memPtr[2] = status;
//  238 
//  239 #if defined (ZTOOL_P1) || defined (ZTOOL_P2)
//  240   MT_BuildAndSendZToolCB( SPI_CB_SAPI_BIND_CNF, SPI_CB_SAPI_BIND_CNF_LEN, memPtr );
//  241 #endif
//  242 }
//  243 /******************************************************************************
//  244  * @fn          zb_MTCallbackAllowBindConfirm
//  245  *
//  246  * @brief       Indicates when another device attempted to bind to this device
//  247  *
//  248  * @param
//  249  *
//  250  * @return      none
//  251  */
//  252 void zb_MTCallbackAllowBindConfirm( uint16 source )
//  253 {
//  254   uint8 memPtr[SPI_CB_SAPI_ALLOW_BIND_CNF_LEN];
//  255 
//  256   memPtr[0] = HI_UINT16(source);
//  257   memPtr[1] = LO_UINT16(source);
//  258 
//  259 #if defined (ZTOOL_P1) || defined (ZTOOL_P2)
//  260   MT_BuildAndSendZToolCB( SPI_CB_SAPI_ALLOW_BIND_CNF, SPI_CB_SAPI_ALLOW_BIND_CNF_LEN, memPtr );
//  261 #endif
//  262 
//  263 }
//  264 /******************************************************************************
//  265  * @fn          zb_MTCallbackFindDeviceConfirm
//  266  *
//  267  * @brief       Process the callback subscription for zb_FindDeviceConfirm
//  268  *
//  269  * @param
//  270  *
//  271  * @return      none
//  272  */
//  273 void zb_MTCallbackFindDeviceConfirm( uint8 searchType, uint8 *searchKey, uint8 *result )
//  274 {
//  275   uint8 memPtr[SPI_CB_SAPI_FIND_DEV_CNF_LEN];
//  276   uint16 addr = *((uint16*)searchKey);
//  277 
//  278   // Currently only supports IEEE Addr Search
//  279   memPtr[0] = ZB_IEEE_SEARCH;
//  280   memPtr[1] = HI_UINT16(addr);
//  281   memPtr[2] = LO_UINT16(addr);
//  282   osal_memcpy(&memPtr[3], result, Z_EXTADDR_LEN);
//  283   MT_ReverseBytes( &memPtr[3], Z_EXTADDR_LEN );
//  284 
//  285 #if defined (ZTOOL_P1) || defined (ZTOOL_P2)
//  286   MT_BuildAndSendZToolCB( SPI_CB_SAPI_FIND_DEV_CNF, SPI_CB_SAPI_FIND_DEV_CNF_LEN, memPtr );
//  287 #endif
//  288 }
//  289 
//  290 /******************************************************************************
//  291  * @fn          zb_MTCallbackReceiveDataIndication
//  292  *
//  293  * @brief       Process the callback subscription for zb_ReceiveDataIndication
//  294  *
//  295  * @param
//  296  *
//  297  * @return      none
//  298  */
//  299 void zb_MTCallbackReceiveDataIndication( uint16 source, uint16 command, uint16 len, uint8 *pData  )
//  300 {
//  301   uint8 *memPtr;
//  302   int8 i;
//  303   uint8 msgLen = SPI_CB_SAPI_RCV_DATA_IND_LEN + len;
//  304 
//  305   memPtr = osal_mem_alloc(msgLen);
//  306 
//  307   if (memPtr)
//  308   {
//  309     memPtr[0] = HI_UINT16(source);
//  310     memPtr[1] = LO_UINT16(source);
//  311     memPtr[2] = HI_UINT16(command);
//  312     memPtr[3] = LO_UINT16(command);
//  313     memPtr[4] = HI_UINT16(len);
//  314     memPtr[5] = LO_UINT16(len);
//  315 
//  316     for (i=0; i<len; i++)
//  317     {
//  318       memPtr[6+i] = pData[i];
//  319     }
//  320 
//  321 #if defined (ZTOOL_P1) || defined (ZTOOL_P2)
//  322     MT_BuildAndSendZToolCB( SPI_CB_SAPI_RCV_DATA_IND, msgLen, memPtr );
//  323 #endif
//  324     osal_mem_free( memPtr );
//  325   }
//  326 }
//  327 
//  328 #endif  // #if defined ( MT_SAPI_CB_FUNC )
//  329 
//  330 /*********************************************************************
//  331 *********************************************************************/
// 
// 
// 0 bytes of memory
//
//Errors: none
//Warnings: none

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -