📄 homedemoenddevice.c
字号:
}
/****************************************************************************
*
* NAME: JZA_vAfKvpResponse
*
* DESCRIPTION:
* Used to send response to incoming KVP frame
*
* PARAMETERS: Name RW Usage
* eAddrMode R Address mode of incoming frame
* u16AddrSrc R Network address of source node
* u8SrcEP R Endpoint address of source node
* u8LQI R Link Quality Indication
* u8DstEP R Destination endpoint address
* u8ClusterId R Cluster ID of incoming frame
* *puTransactionInd R Pointer to incoming frame
*
* RETURNS:
* void
*
****************************************************************************/
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:
* Receives incoming MSG data frames.
*
* PARAMETERS: Name RW Usage
* eAddrMode R Address mode of incoming frame
* u16AddrSrc R Network address of source node
* u8SrcEP R Endpoint address of source node
* u8LQI R Link Quality Indication
* u8DstEP R Destination endpoint address
* u8ClusterId R Cluster ID of incoming frame
* *pu8ClusterIDRsp R Pointer to cluster ID of response frame
* *puTransactionInd R Pointer to incoming frame
* *puTransactionRsp R Pointer to response frame
* RETURNS:
* FALSE
*
****************************************************************************/
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)
{
return FALSE;
}
/****************************************************************************
*
* NAME: JZA_vZdpResponse
*
* DESCRIPTION:
* Called when a ZDP response frame has been received. In this case 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_vAppEventHandler
*
* DESCRIPTION:
* Called regularly by the task scheduler. This function reads the hardware
* event queue and processes the events therein. It is important that this
* function exits after a relatively short time so that the other tasks are
* not adversely affected.
*
****************************************************************************/
PUBLIC void JZA_vAppEventHandler(void)
{
tsHwIntData *psHwIntData;
static bool_t bEBStatus = 0;
if(!bEBStatus)
{
if (sDemoData.bJoined == TRUE)
{
/* Things to do when first called */
//vStartReadSensors(); /* Now done upon successful joining */
vLedControl(1, FALSE);
bEBStatus = TRUE;
}
}
/* Check queue for hardware interrupts, and process */
while (sDemoData.sQueue.u8WritePtr != sDemoData.sQueue.u8ReadPtr)
{
psHwIntData
= &sDemoData.sQueue.asHwIntData[sDemoData.sQueue.u8ReadPtr];
switch (psHwIntData->u32Device)
{
case E_AHI_DEVICE_SYSCTRL:
/* Check for DIO pin used by humidity/temperature sensor */
if (psHwIntData->u32ItemBitmap & HTS_DATA_DIO_BIT_MASK)
{
switch (sDemoData.sSystem.eState)
{
case E_STATE_READING_S1:
vReadSensor2();
break;
case E_STATE_READING_S2:
vReadSensor3();
break;
default:
break;
}
}
/* Check for wake timer */
if (psHwIntData->u32ItemBitmap & (1 << E_AHI_SYSCTRL_WK1))
{
/* Only restart sensor reading if not rejoining (if rejoining,
sensor reading will be restarted when that is complete) */
if (sDemoData.bRejoining == FALSE)
{
vStartReadSensors();
}
}
/* Check for buttons */
if (psHwIntData->u32ItemBitmap
& (BUTTON_ALL_MASK_RFD << BUTTON_BASE_BIT))
{
uint8 u8KeysDown
= (uint8)(psHwIntData->u32ItemBitmap >> BUTTON_BASE_BIT);
switch (u8KeysDown)
{
case BUTTON_0_MASK:
sDemoData.sControls.u8Switch = 0;
break;
case BUTTON_1_MASK:
sDemoData.sControls.u8Switch = 1;
break;
}
}
break;
default:
break;
}
sDemoData.sQueue.u8ReadPtr
= (sDemoData.sQueue.u8ReadPtr + 1) & HW_INT_Q_PTR_MASK;
}
}
/****************************************************************************
*
* NAME: JZA_vPeripheralEvent
*
* DESCRIPTION:
* Called when a hardware event causes an interrupt. This function is called
* from within the interrupt context so should be brief. In this case, the
* information is placed on a simple FIFO queue to be processed later.
*
* PARAMETERS: Name RW Usage
* u32Device R Peripheral generating interrupt
* u32ItemBitmap R Bitmap of interrupt sources within peripheral
*
****************************************************************************/
PUBLIC void JZA_vPeripheralEvent(uint32 u32Device, uint32 u32ItemBitmap)
{
tsHwIntData *psHwIntData;
uint8 u8WriteNextPtr;
/* Queue event for processing during appKeyOperationKey call */
u8WriteNextPtr = (sDemoData.sQueue.u8WritePtr + 1) & HW_INT_Q_PTR_MASK;
if (u8WriteNextPtr != sDemoData.sQueue.u8ReadPtr)
{
/* There is space on queue */
psHwIntData
= &sDemoData.sQueue.asHwIntData[sDemoData.sQueue.u8WritePtr];
psHwIntData->u32Device = u32Device;
psHwIntData->u32ItemBitmap = u32ItemBitmap;
sDemoData.sQueue.u8WritePtr = u8WriteNextPtr;
}
/* If no space on queue, interrupt is silently discarded */
}
/****************************************************************************
*
* NAME: JZA_vStackEvent
*
* DESCRIPTION:
* Called when a miscellaneous stack event occurs.
*
* PARAMETERS: Name RW Usage
* eEventId R Event enumeration
* puStackEvent R Event information
*
* RETURNS:
* NULL
*
****************************************************************************/
PUBLIC void JZA_vStackEvent(teJZS_EventIdentifier eEventId,
tuJZS_StackEvent *puStackEvent)
{
switch (eEventId)
{
case JZS_EVENT_APS_DATA_CONFIRM:
if (puStackEvent->sApsDataConfirmEvent.u8Status != 0)
{
if (sDemoData.bRejoining == FALSE)
{
sDemoData.bJoined = FALSE;
sDemoData.bRejoining = TRUE;
/* Try to re-join network: timer will send a frame again in a
second */
JZS_vRejoinNetwork();
}
}
else
{
if (sDemoData.bRejoining == FALSE)
{
/* Go to sleep: sleep itself will not be scheduled until BOS
has completed any other actions */
vSleep();
}
}
break;
case JZS_EVENT_NWK_JOINED_AS_ENDDEVICE:
vAddDesc();
sDemoData.bJoined = TRUE;
sDemoData.bRejoining = FALSE;
vStartReadSensors();
/* Note: can use puStackEvent->sNwkJoinedEvent.u16Addr to detect if
device address has changed */
break;
default:
break;
}
}
/****************************************************************************/
/*** Local Functions ***/
/****************************************************************************/
/****************************************************************************
*
* NAME: vInitDemoSystem
*
* DESCRIPTION:
* Initialises Zigbee stack and hardware. Final action is to start BOS, from
* which there is no return. Subsequent application actions occur in the
* functions defined above.
*
* RETURNS:
* No return from this function
*
****************************************************************************/
PRIVATE void vInitDemoSystem(bool_t bColdStart)
{
/* Initialise software elements */
vInitEndpoint();
#if 1
vAHI_UartEnable(E_AHI_UART_0);
vAHI_UartReset(E_AHI_UART_0, TRUE, TRUE);
vAHI_UartSetClockDivisor(E_AHI_UART_0, E_AHI_UART_RATE_38400);
vAHI_UartReset(E_AHI_UART_0, FALSE, FALSE);
#endif
/* Initialise Zigbee stack */
(void)JZS_u32InitSystem(bColdStart);
/* Set DIO for buttons and LEDs. Also, if waking up, set up the
BOS into the correct state */
if (bColdStart == TRUE)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -