/****************************************************************************
 *
 * NAME: vStopStartModeChangeTimer
 *
 * DESCRIPTION:
 * Stops and starts the commissioning timer with required ticks
 *
 * PARAMETERS:
 * u32Ticks     Ticks for timer start
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PRIVATE void vStopStartModeChangeTimer( uint32 u32Ticks )
{
    if( OS_eGetSWTimerStatus(App_ChangeModeTimer) != OS_E_SWTIMER_STOPPED )
    {
        OS_eStopSWTimer(App_ChangeModeTimer);
    }
    #ifdef SLEEP_ENABLE
        if( FALSE == bWatingToSleep())
        {
            OS_eStartSWTimer(App_ChangeModeTimer, u32Ticks, NULL );
        }
    #else
        OS_eStartSWTimer(App_ChangeModeTimer, u32Ticks, NULL );
    #endif
}
/****************************************************************************
 *
 * NAME: APP_ZCL_vInitialise
 *
 * DESCRIPTION:
 * Initialises ZCL related functions
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PUBLIC void APP_ZCL_vInitialise(void)
{
    teZCL_Status eZCL_Status;

    /* Initialise ZHA */
    eZCL_Status = eHA_Initialise(&APP_ZCL_cbGeneralCallback, apduZCL);
    if (eZCL_Status != E_ZCL_SUCCESS)
    {
        DBG_vPrintf(TRACE_ZCL, "\nAPP_ZCL: Error eHA_Initialise returned %d", eZCL_Status);
    }

    /* Register ZHA EndPoint */
    eZCL_Status = eApp_HA_RegisterEndpoint(&APP_ZCL_cbEndpointCallback);
    if (eZCL_Status != E_ZCL_SUCCESS)
    {
        DBG_vPrintf(TRACE_SENSOR_TASK, "\nAPP_ZCL: Error: eApp_HA_RegisterEndpoint:%d", eZCL_Status);
    }

    DBG_vPrintf(TRACE_SENSOR_TASK, "\nAPP_ZCL: Chan Mask %08x", ZPS_psAplAibGetAib()->apsChannelMask);
    DBG_vPrintf(TRACE_SENSOR_TASK, "\nAPP_ZCL: RxIdle TRUE");

    OS_eStartSWTimer(APP_TickTimer, ZCL_TICK_TIME, NULL);

    vAPP_ZCL_DeviceSpecific_Init();
}
/****************************************************************************
 *
 * NAME:		vStartNonSleepPreventingTimers
 *
 * DESCRIPTION: Start the timers that wont stop us in vAttemptToSleep
 *
 ****************************************************************************/
PRIVATE void vStartNonSleepPreventingTimers(void)
{
#ifndef DEEP_SLEEP_ENABLE
	if (OS_eGetSWTimerStatus(APP_TickTimer) != OS_E_SWTIMER_RUNNING)
		OS_eStartSWTimer(APP_TickTimer, ZCL_TICK_TIME, NULL);
#endif
}
Exemple #4
0
/****************************************************************************
 *
 * NAME: vResetATimer
 *
 * DESCRIPTION:
 * tool function for stop and then start a software timer
 *
 * PARAMETERS: Name         RW  Usage
 *             hSWTimer     R   handler to sw timer
 *             u32Ticks     R   ticks of cycle
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PUBLIC void vResetATimer(OS_thSWTimer hSWTimer, uint32 u32Ticks)
{
    if (OS_eGetSWTimerStatus(hSWTimer) != OS_E_SWTIMER_STOPPED)
    {
        OS_eStopSWTimer(hSWTimer);
    }
    OS_eStartSWTimer(hSWTimer, u32Ticks, NULL);
}
Exemple #5
0
/****************************************************************************
 *
 * NAME: CRD_vInit
 *
 * DESCRIPTION:
 * Initialises Zigbee stack, hardware and application.
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PRIVATE void CRD_vInit(void)
{
	/* Debug */
	DBG_vPrintf(CRD_TRACE, "\n%d CRD  < CRD_vInit()", NODE_sData.u32Timer);

	/* Initialise node */
	NODE_vInit();

	/* Initialise WUART */
	WUART_vInit();

	/* Start tick timer */
	OS_eStartSWTimer(CRD_TickTimer, TICK_TIME_MS(1), NULL);
}
Exemple #6
0
/****************************************************************************
 *
 * NAME: ups_init
 *
 * DESCRIPTION:
 * init user programming space
 *
 * PARAMETERS: Name         RW  Usage
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PUBLIC void ups_init(void)
{
    /* Init ringbuffer */
    UPS_vInitRingbuffer();

    /* init suli */
    suli_init();

    /* init arduino sketch with arduino-style setup function */
    arduino_setup();

    /* Activate Arduino-ful MCU */
    OS_eStartSWTimer(Arduino_LoopTimer, APP_TIME_MS(500), NULL);
}
/****************************************************************************
 *
 * NAME: APP_ZCL_vInitialise
 *
 * DESCRIPTION:
 * Initialises ZCL related functions
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PUBLIC void APP_ZCL_vInitialise(void)
{
    teZCL_Status eZCL_Status;

    /* Initialise ZHA */
    eZCL_Status = eHA_Initialise(&APP_ZCL_cbGeneralCallback, apduZCL);
    if (eZCL_Status != E_ZCL_SUCCESS)
    {
        DBG_vPrintf(TRACE_ZCL, "Error: eHA_Initialise returned %d\r\n", eZCL_Status);
    }

    /* Register ZHA EndPoint */
    eZCL_Status = eApp_HA_RegisterEndpoint(&APP_ZCL_cbEndpointCallback);
    if (eZCL_Status != E_ZCL_SUCCESS)
    {
            DBG_vPrintf(TRACE_SWITCH_TASK, "Error: eApp_HA_RegisterEndpoint:%d\r\n", eZCL_Status);
    }

    DBG_vPrintf(TRACE_SWITCH_TASK, "Chan Mask %08x\n", ZPS_psAplAibGetAib()->apsChannelMask);

    OS_eStartSWTimer(APP_TickTimer, ZCL_TICK_TIME, NULL);
}
/****************************************************************************
 *
 * NAME: vQButtonPress
 *
 * DESCRIPTION:
 * Stores delayed command that is stored
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PRIVATE void vQButtonPress( te_TransitionCode eTransitionCode)
{
    eTransitionButtonCode=eTransitionCode;
    /*Set up the button delay timer*/
    OS_eStartSWTimer(APP_tmrButtonDelayTimer,APP_TIME_MS(BUTTON_DELAY_TIME_IN_MS),NULL);
}
/****************************************************************************
 *
 * NAME: vHandleNetworkScreenEvent
 *
 * DESCRIPTION:
 * Handles stack events when the Controller is in its "network" display mode state
 *
 * PARAMETERS: Name         RW  Usage
 *             sStackEvent  R   Contains details of the stack event
 *
 * RETURNS:
 * Sequence number
 *
 ****************************************************************************/
PRIVATE void vHandleNetworkScreenEvent(ZPS_tsAfEvent sStackEvent, APP_tsEvent sAppEvent)
{
//	uint8 *u8Char;
//	string u8Char1;
//	uint8 *u8String;
    /* respond to button presses when in "network" display mode */
    if (APP_E_EVENT_BUTTON_DOWN == sAppEvent.eType)
    {
        if (APP_E_BUTTONS_BUTTON_1 == sAppEvent.sButton.u8Button)
        {
            DBG_vPrintf(TRACE_APP, "Starting join toggle timer\n");
            OS_eStopSWTimer(APP_tmrJoiningButton);
            OS_eStartSWTimer(APP_tmrJoiningButton, APP_TIME_MS(2000), NULL);
        }
    }

    if (APP_E_EVENT_BUTTON_UP == sAppEvent.eType)
    {
        if (APP_E_BUTTONS_BUTTON_1 == sAppEvent.sButton.u8Button)
        {
            if (OS_E_SWTIMER_RUNNING == OS_eGetSWTimerStatus(APP_tmrJoiningButton))
            {
                /*
                 * Button press was too short to trigger permit-join toggling
                 * therefore it was pressed in order to switch to the node
                 * display screen.
                 *
                 * Stop timer to prevent toggling from occurring.
                 */
                OS_eStopSWTimer(APP_tmrJoiningButton);

                /* If at least one sensor has joined, then it is valid to go
                 * to the node display screen
                 */
                if (0 < APP_u8ControllerNodeNumDataSensors())
                {
                    APP_vDisplaySetState(APP_E_DISPLAY_STATE_NODE);
                    APP_vDisplayUpdate();
                    s_sDevice.eState = E_NODE_SCREEN;
                }
            }
        }
        else if (APP_E_BUTTONS_BUTTON_2 == sAppEvent.sButton.u8Button)
        {
            /*
             * perform select temperature sensors action
             */
            APP_vDisplaySetSensor(APP_E_SENSOR_TEMP);
            APP_vDisplayUpdate();
            vSerial_QData();
        }
        else if (APP_E_BUTTONS_BUTTON_3 == sAppEvent.sButton.u8Button)
        {
            /* perform select humidity sensors action */
            APP_vDisplaySetSensor(APP_E_SENSOR_HTS);
            APP_vDisplayUpdate();
            vSerial_SensorData();
        }
        else if (APP_E_BUTTONS_BUTTON_4 == sAppEvent.sButton.u8Button)
        {
            /* perform select humidity sensors action */
            APP_vDisplaySetSensor(APP_E_SENSOR_ALS);
            APP_vDisplayUpdate();
            Rfid_Getprotocol();
        }
    }
    vCheckStackEvent(sStackEvent);
}