
/**************************************************************************//**
  \file blank.c
  
  \brief Zigbee Aplikace, odeslani dat ku koordinatorovi

  \author

  \internal
    History:    

******************************************************************************/

// hlavickove soubory Bitcloudu
#include <appTimer.h>
#include <zdo.h>
#include <adc.h>
// hlavickove soubory Aplikace
#include "blank.h"
#include "boardabstraction.h"

//******* DEKLARACE KONSTANT*********


// prodleva mezi pakety
#define PACKET_INTERVAL 2000





// deklarace callbacku pro hlavni casovac
void mainTimerFired(void);


// definice promenne pro stavovy automat aplikace
static AppState_t appState = APP_STATE_INITIAL;








// definice hlavniho casovace mainTimer
static HAL_AppTimer_t mainTimer = {
 .interval = PACKET_INTERVAL,
 .mode = TIMER_REPEAT_MODE,
 .callback = mainTimerFired,
};

//definice obsahu usart datoveho ramce

static UsartDataFrame_t usartDataFrame;






/*******************************************************************************
  Description: application task handler.

  Parameters: none.
  
  Returns: nothing.
*******************************************************************************/
void APL_TaskHandler(void)
{
	


switch(appState) 
 {	
	 case APP_STATE_INITIAL:
		InitHW();
		
		usartDataFrame.frameType=0x01;
		usartDataFrame.frameSource_addr=0x0022;
		usartDataFrame.frameLength=0x0A;
		usartDataFrame.frameSeq=0x0080;
		usartDataFrame.frameData=0x03E7;
		usartDataFrame.frameCRC=0x0378;
		
		HAL_StartAppTimer(&mainTimer);
	 break;


 }
}




// callback pro mainTimer
void mainTimerFired(void)
{
	
	
	static char str[20];
	snprintf(str, sizeof(str), "%#X\r\n", usartDataFrame);
	SendStrToConsole(str);	
	
		
			
}


	
	
  


/*******************************************************************************
  Description: just a stub.

  Parameters: are not used.
  
  Returns: nothing.
*******************************************************************************/
void ZDO_MgmtNwkUpdateNotf(ZDO_MgmtNwkUpdateNotf_t *nwkParams) 
{
  if ((ZDO_NETWORK_LEFT_STATUS == nwkParams->status) || (ZDO_NETWORK_LOST_STATUS == nwkParams->status))
  {
    SendStrToConsole("Connection Lost\r\n"); 
	appState = APP_STATE_NETWORK_OUT;
  }
}

/*******************************************************************************
  Description: just a stub.

  Parameters: none.
  
  Returns: nothing.
*******************************************************************************/
void ZDO_WakeUpInd(void) 
{
}

#ifdef _BINDING_

void ZDO_BindIndication(ZDO_BindInd_t *bindInd) 
{
  (void)bindInd;
}

void ZDO_UnbindIndication(ZDO_UnbindInd_t *unbindInd)
{
  (void)unbindInd;
}
#endif //_BINDING_

/**********************************************************************//**
  \brief Main - C program main start function

  \param none
  \return none
**************************************************************************/
int main(void)
{
  SYS_SysInit();

  for(;;)
  {
    SYS_RunTask();
  }
}

//eof blink.c
