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

📄 wsn_coordinator.c

📁 内部包含如何用rs232来和rs485通信的示范代码
💻 C
📖 第 1 页 / 共 2 页
字号:
        }
    }*/
}
/****************************************************************************
 * NAME: JZA_vAppDefineTasks
 *
 * DESCRIPTION:
 * Called by Zigbee stack during initialisation to allow the application to
 * initialise any tasks that it requires. This application requires none.
 ****************************************************************************/
PUBLIC void JZA_vAppDefineTasks(void)
{
}
/****************************************************************************
 * NAME: JZA_boAppStart
 *
 * DESCRIPTION:
 * Called by Zigbee stack during initialisation. Sets up the profile
 * information and starts the networking activity
 ****************************************************************************/
PUBLIC bool_t JZA_boAppStart(void)
{
    JZS_vStartStack();
    return TRUE;
}
/****************************************************************************
 * NAME: JZA_eAfKvpObject
 *
 * DESCRIPTION:
 * Called when a KVP transaction has been received with a matching endpoint.
 *
 * PARAMETERS:      Name           RW  Usage
 *                  afSrcAddr      R   Address of sender device
 *                  u8DstEndpoint  R   Endpoint at receiver
 *                  pu8ClusterId   R   Pointer to cluster ID
 *                  eCommandTypeId R   KVP command type
 *                  u16AttributeId R   KVP attribute ID
 *                  pu8AfduLength  R   Pointer to length of data
 *                  pu8Afdu        R   Data array
 ****************************************************************************/
PUBLIC bool_t JZA_bAfKvpObject(APS_Addrmode_e eAddrMode,
                               uint16 u16AddrSrc,
                               uint8 u8SrcEP,
                               uint8 u8LQI,
                               uint8 u8DstEP,
                               uint8 u8ClusterId,
                               uint8 *pu8ClusterIDRsp,
                               AF_Transaction_s *puTransactionInd,
                               AF_Transaction_s *puTransactionRsp)
{
	return KVP_SUCCESS;
}
/****************************************************************************
 * NAME: JZA_vAfKvpResponse
 *
 * DESCRIPTION:
 * Called after a KVP transaction with acknowledgement request, when the
 * acknowledgement arrives. In this application no action is taken as no
 * KVP transaction acknowledgements are expected.
 *
 * PARAMETERS:      Name                   RW  Usage
 *                  srcAddressMod          R   Address of sender device
 *                  transactionSequenceNum R   KVP transaction number
 *                  commandTypeIdentifier  R   KVP command type
 *                  dstEndPoint            R   Endpoint at receiver
 *                  clusterID              R   Cluster ID
 *                  attributeIdentifier    R   KVP attribute ID
 *                  errorCode              R   Result code
 *                  afduLength             R   Length of payload data
 *                  pAfdu                  R   Payload data array
 ****************************************************************************/
PUBLIC void JZA_vAfKvpResponse(APS_Addrmode_e eAddrMode,
                               uint16 u16AddrSrc,
                               uint8 u8SrcEP,
                               uint8 u8LQI,
                               uint8 u8DstEP,
                               uint8 u8ClusterID,
                               AF_Transaction_s *puTransactionInd)
{
}
/****************************************************************************
 * NAME: JZA_pu8AfMsgObject
 *
 * DESCRIPTION:
 * Called when a MSG transaction has been received with a matching endpoint.
 *
 * PARAMETERS:      Name           RW  Usage
 *                  afSrcAddr      R   Address of sender device
 *                  dstEndPoint    R   Endpoint at receiver
 *                  clusterID      R   Pointer to cluster ID
 *                  afduLength     R   Pointer to length of data
 *                  pAfdu          R   Data array
 ****************************************************************************/
PUBLIC bool_t JZA_bAfMsgObject(APS_Addrmode_e eAddrMode,
                               uint16 u16AddrSrc,
                               uint8 u8SrcEP,
                               uint8 u8LQI,
                               uint8 u8DstEP,
                               uint8 u8ClusterID,
                               uint8 *pu8ClusterIDRsp,
                               AF_Transaction_s *puTransactionInd,
                               AF_Transaction_s *puTransactionRsp)
{
	uint16 u16Humidity;
	uint16 u16BattVoltage;
	uint16 u16Temperature;


    if ((eAddrMode == APS_ADDRMODE_SHORT) && (u8DstEP == WSN_DATA_SINK_ENDPOINT))
    {
        if(u8ClusterID == WSN_CID_SENSOR_READINGS)
        {
            u16BattVoltage  = puTransactionInd->uFrame.sMsg.au8TransactionData[1];
            u16BattVoltage  = u16BattVoltage << 8;
            u16BattVoltage |= puTransactionInd->uFrame.sMsg.au8TransactionData[0];

            u16ADC3_Result  = puTransactionInd->uFrame.sMsg.au8TransactionData[3];
            u16ADC3_Result  = u16ADC3_Result << 8;
            u16ADC3_Result |= puTransactionInd->uFrame.sMsg.au8TransactionData[2];

            u16ADC4_Result  = puTransactionInd->uFrame.sMsg.au8TransactionData[5];
            u16ADC4_Result  = u16ADC4_Result << 8;
            u16ADC4_Result |= puTransactionInd->uFrame.sMsg.au8TransactionData[4];
        }
         while(bAHI_DacPoll() != 000);
         vAHI_DacOutput(E_AHI_AP_DAC_1,u16ADC3_Result); /* put AtoD result on to the DAC */

         while(bAHI_DacPoll() != 000);
         vAHI_DacOutput(E_AHI_AP_DAC_2,u16ADC4_Result);
    }
    return 0;
}
/****************************************************************************
 * NAME: JZA_vZdpResponse
 *
 * DESCRIPTION:
 * Called when a ZDP response frame has been received. In this application no
 * action is taken as no ZDP responses are anticipated.
 *
 * PARAMETERS:      Name           RW  Usage
 *                  u8Type         R   ZDP response type
 *                  pu8Payload     R   Payload buffer
 *                  u8PayloadLen   R   Length of payload
 ****************************************************************************/
PUBLIC void JZA_vZdpResponse(uint8  u8Type,
                             uint8  u8LQI,
                             uint8 *pu8Payload,
                             uint8  u8PayloadLen)
{
}
/****************************************************************************
 * NAME: JZA_vStackEvent
 *
 * DESCRIPTION:
 * Called by Zigbee stack to pass an event up to the application.
 ****************************************************************************/
PUBLIC void JZA_vStackEvent(teJZS_EventIdentifier eEventId,
                            tuJZS_StackEvent *puStackEvent)
{
    if (eEventId == JZS_EVENT_NWK_STARTED)
    {
		uint8 u8InputClusterCnt      = 1;
		uint8 au8InputClusterList[]  = {WSN_CID_SENSOR_READINGS};
		uint8 u8OutputClusterCnt     = 0;
		uint8 au8OutputClusterList[] = {};

		(void)afmeAddSimpleDesc(WSN_DATA_SINK_ENDPOINT,
								WSN_PROFILE_ID,
								0x0000,
								0x00,
								0x00,
								u8InputClusterCnt,
								au8InputClusterList,
								u8OutputClusterCnt,
								au8OutputClusterList);
        bNwkStarted = TRUE;
    }
}
PRIVATE void vPutC0(unsigned char c)
{
    while ((u8AHI_UartReadLineStatus(E_AHI_UART_0) & E_AHI_UART_LS_THRE ) == 0);
    vAHI_UartWriteData(E_AHI_UART_0,c);
}
PRIVATE void vPutC1(unsigned char c)
{
    while ((u8AHI_UartReadLineStatus(E_AHI_UART_1) & E_AHI_UART_LS_THRE ) == 0);
    vAHI_UartWriteData(E_AHI_UART_1,c);
}
PRIVATE void DELAY_TIME(int mSec)
{
    vAHI_WakeTimerEnable(E_AHI_WAKE_TIMER_1,TRUE);
    vAHI_WakeTimerStart(E_AHI_WAKE_TIMER_1,mSec*32);//mSec*32=1ms
    vAHI_CpuDoze();
}
/****************************************************************************/
/***        END OF FILE                                                   ***/
/****************************************************************************/

⌨️ 快捷键说明

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