Example #1
0
/*************************************************************************//**
*****************************************************************************/
static void APP_TaskHandler(void)
{

	const char* tx_data = "You Rock";
	
	if(!appDataReqBusy){
		if(!strcmp((const char*)rx_data, "this rocks"))
			LED_Toggle(LED0);
		for (uint16_t i = 0; i < sizeof("You Rock"); i++) {
			if (appUartBufferPtr == sizeof(appUartBuffer)) {
				appSendData();
			}

			if (appUartBufferPtr < sizeof(appUartBuffer)) {
				appUartBuffer[appUartBufferPtr++] = tx_data[i];
			}
		}
		appSendData();
	}
	//delay_ms(200);
	
		
	//SYS_TimerStop(&appTimer);
	//SYS_TimerStart(&appTimer);
}
Example #2
0
static void APP_TaskHandler(void)
{
  switch (appState)
  {
    case APP_STATE_INITIAL:
    {
      appInit();
    } break;

    case APP_STATE_SEND:
    {
      appSendData();
    } break;

    case APP_STATE_SENDING_DONE:
    {
#if APP_ENDDEVICE
      appState = APP_STATE_PREPARE_TO_SLEEP;
#else
      SYS_TimerStart(&appDataSendingTimer);
      appState = APP_STATE_WAIT_SEND_TIMER;
#endif
    } break;

    case APP_STATE_PREPARE_TO_SLEEP:
    {
      if (!NWK_Busy())
      {
        NWK_SleepReq();
        appState = APP_STATE_SLEEP;
      }
    } break;

    case APP_STATE_SLEEP:
    {
      ledsClose();

      PHY_SetRxState(false);

      HAL_Sleep(APP_SENDING_INTERVAL);
      appState = APP_STATE_WAKEUP;
    } break;

    case APP_STATE_WAKEUP:
    {
      NWK_WakeupReq();

      ledsInit();
      ledOn(LED_NETWORK);

      PHY_SetRxState(true);

      appState = APP_STATE_SEND;
    } break;

    default:
      break;
  }
}
Example #3
0
void HAL_UartBytesReceived(uint16_t bytes)
{
  for (uint16_t i = 0; i < bytes; i++)
  {
    uint8_t byte = HAL_UartReadByte();

    if (appUartBufferPtr == sizeof(appUartBuffer))
      appSendData();

    if (appUartBufferPtr < sizeof(appUartBuffer))
      appUartBuffer[appUartBufferPtr++] = byte;
  }
}
Example #4
0
void HAL_UartBytesReceived(uint16_t bytes){

	for (uint16_t i = 0; i < bytes; i++){
		uint8_t byte = uartGetc();

		if (appUartBufferPtr == sizeof(appUartBuffer))
		appSendData();

		if (appUartBufferPtr < sizeof(appUartBuffer))
		appUartBuffer[appUartBufferPtr++] = byte;
	}

	SYS_TimerStop(&appTimer);
	SYS_TimerStart(&appTimer);
}
Example #5
0
static void appTimerHandler(SYS_Timer_t *timer)
{
  char hex[] = "0123456789abcdef";
  
  if (APP_ADDR == 0) {
    appSendData();
    (void)timer;
  }
  if (APP_ADDR == 1) {
    appTemperature = HAL_MeasureTemperature();

    HAL_UartWriteByte('T');
    HAL_UartWriteByte('e');
    HAL_UartWriteByte('m');
    HAL_UartWriteByte('p');
    HAL_UartWriteByte(':');
    HAL_UartWriteByte(' ');
    HAL_UartWriteByte(hex[((int)appTemperature >> 4) & 0x0f]);
    HAL_UartWriteByte(hex[(int)appTemperature & 0x0f]);
    HAL_UartWriteByte('\r');
    HAL_UartWriteByte('\n');
  }
Example #6
0
static void appSendDataConf(NWK_DataReq_t *req)
{
  appDataReqBusy = false;
  appSendData();
  (void)req;
}
Example #7
0
/*************************************************************************//**
*****************************************************************************/
static void APP_TaskHandler(void)
{
  switch (appState)
  {
    case APP_STATE_INITIAL:
    {
      appInit();
    } break;

    case APP_STATE_SEND:
    {
      appSendData();
    } break;

    case APP_STATE_SENDING_DONE:
    {
#if APP_ENDDEVICE
      appState = APP_STATE_PREPARE_TO_SLEEP;
#else
      SYS_TimerStart(&appDataSendingTimer);
      appState = APP_STATE_WAIT_SEND_TIMER;
#endif
    } break;

    case APP_STATE_PREPARE_TO_SLEEP:
    {
      if (!NWK_Busy())
      {
        NWK_SleepReq();
        appState = APP_STATE_SLEEP;
      }
    } break;

    case APP_STATE_SLEEP:
    {

      sm_sleep(APP_SENDING_INTERVAL/1000);
	  appState = APP_STATE_WAKEUP;
    } break;

    case APP_STATE_WAKEUP:
    {
      NWK_WakeupReq();

      LED_On(LED_NETWORK);


      appState = APP_STATE_SEND;
    } break;

    default:
      break;
  }
  
#if APP_COORDINATOR
  if(sio2host_rx(rx_data,APP_RX_BUF_SIZE) > 0)
  {
  LED_Toggle(LED_BLINK);  
  }
#endif
}
Example #8
0
static void appTimerHandler(SYS_Timer_t *timer){
	appSendData();
	(void)timer;
}