コード例 #1
0
ファイル: WSNDemo.c プロジェクト: amedhiou/pinoccio-ide
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;
  }
}
コード例 #2
0
void timeoutTimerHandler(SYS_Timer_t *timer)
{
	if (!NWK_Busy())
		{
			frame[0] = 0x06;
			frame[1] = 0xBB;
			frame[2] = 0xBB;
			frame[3] = 0xBB;
			frame[4] = 0xBB;

			nwkDataReq.dstAddr = 0x389C;
			nwkDataReq.dstEndpoint = 1;
			nwkDataReq.srcEndpoint = 1;
			nwkDataReq.size = sizeof(frame);
			nwkDataReq.data = frame;
			nwkDataReq.confirm = appDataConf;

			NWK_DataReq(&nwkDataReq);
		}
	startTimeoutTimer();
}
コード例 #3
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
}