Esempio n. 1
0
/*************************************************************************//**
*****************************************************************************/
static bool otaHandleStartResp(NWK_DataInd_t *ind)
{
  OtaStartRespCommand_t *resp = (OtaStartRespCommand_t *)ind->data;

  if (ind->size != sizeof(OtaStartRespCommand_t))
    return false;

  if (OTA_SERVER_STATE_WAIT_START_RESP != otaServer.state ||
      otaServer.sessionId != resp->sessionId)
    return true;

  otaServer.retries = OTA_MAX_RETRIES;
  SYS_TimerStop(&otaResponseTimer);

  if (OTA_SUCCESS_STATUS == resp->status)
  {
    otaServer.state = OTA_SERVER_STATE_READY;
    OTA_ServerNotification(OTA_CLIENT_READY_STATUS);
  }
  else
  {
    otaServer.state = OTA_SERVER_STATE_IDLE;
    OTA_ServerNotification((OTA_Status_t)resp->status);
  }

  return true;
}
Esempio n. 2
0
static void appDataConf(NWK_DataReq_t *req)
{
  LED_Off(LED_DATA);

  if (NWK_SUCCESS_STATUS == req->status)
  {
    if (!appNetworkStatus)
    {
      LED_On(LED_NETWORK);
      SYS_TimerStop(&appNetworkStatusTimer);
      appNetworkStatus = true;
    }
  }
  else
  {

    if (appNetworkStatus)
    {
      LED_Off(LED_NETWORK);
      SYS_TimerStart(&appNetworkStatusTimer);
      appNetworkStatus = false;
    }
  }

  appState = APP_STATE_SENDING_DONE;
}
Esempio n. 3
0
/*************************************************************************//**
*****************************************************************************/
static bool otaHandleBlockResp(NWK_DataInd_t *ind)
{
  OtaBlockRespCommand_t *resp = (OtaBlockRespCommand_t *)ind->data;

  if (ind->size != sizeof(OtaBlockRespCommand_t))
    return false;

  if (OTA_SERVER_STATE_WAIT_BLOCK_RESP != otaServer.state ||
      otaServer.sessionId != resp->sessionId)
    return true;

  otaServer.retries = OTA_MAX_RETRIES;
  SYS_TimerStop(&otaResponseTimer);

  if (OTA_SUCCESS_STATUS == resp->status)
  {
    otaServer.state = OTA_SERVER_STATE_WAIT_FRAME_SPACING;
    SYS_TimerStart(&otaFrameSpacingTimer);
  }
  else
  {
    otaServer.state = OTA_SERVER_STATE_IDLE;
    OTA_ServerNotification((OTA_Status_t)resp->status);
  }

  return true;
}
Esempio n. 4
0
/*************************************************************************//**
*****************************************************************************/
static void appCmdIdentifyDurationTimerHandler(SYS_Timer_t *timer)
{
	NWK_Unlock();
#if (LED_COUNT > 0)
	LED_Off(LED_IDENTIFY);
#endif
	SYS_TimerStop(&appCmdIdentifyPeriodTimer);
	(void)timer;
}
Esempio n. 5
0
/*************************************************************************//**
*****************************************************************************/
void OTA_ServerStartUpdrade(uint16_t addr, uint32_t size)
{
  SYS_TimerStop(&otaResponseTimer);
  SYS_TimerStop(&otaFrameSpacingTimer);

  otaServer.state = OTA_SERVER_STATE_START_REQ_SENT;
  otaServer.sessionId = rand();
  otaServer.client = addr;
  otaServer.size = size;
  otaServer.crc = 0;
  otaServer.retries = OTA_MAX_RETRIES;

  otaDataReq.dstAddr = addr;
  otaDataReq.size = sizeof(OtaStartReqCommand_t);
  otaDataReq.options = NWK_OPT_ACK_REQUEST;

  otaCommand.start.commandId = OTA_START_REQ_COMMAND_ID;
  otaCommand.start.sessionId = otaServer.sessionId;
  otaCommand.start.size = size;

  NWK_DataReq(&otaDataReq);
}
Esempio n. 6
0
/*************************************************************************//**
*****************************************************************************/
static bool appCmdHandle(uint8_t *data, uint8_t size)
{
	AppCmdHeader_t *header = (AppCmdHeader_t *)data;

	if (size < sizeof(AppCmdHeader_t)) {
		return false;
	}

	if (APP_COMMAND_ID_IDENTIFY == header->id) {
		AppCmdIdentify_t *req = (AppCmdIdentify_t *)data;

		if (sizeof(AppCmdIdentify_t) != size) {
			return false;
		}

		SYS_TimerStop(&appCmdIdentifyDurationTimer);
		SYS_TimerStop(&appCmdIdentifyPeriodTimer);

		appCmdIdentifyDurationTimer.interval = req->duration;
		appCmdIdentifyDurationTimer.mode = SYS_TIMER_INTERVAL_MODE;
		appCmdIdentifyDurationTimer.handler
			= appCmdIdentifyDurationTimerHandler;
		SYS_TimerStart(&appCmdIdentifyDurationTimer);

		appCmdIdentifyPeriodTimer.interval = req->period;
		appCmdIdentifyPeriodTimer.mode = SYS_TIMER_PERIODIC_MODE;
		appCmdIdentifyPeriodTimer.handler
			= appCmdIdentifyPeriodTimerHandler;
		SYS_TimerStart(&appCmdIdentifyPeriodTimer);
#if (LED_COUNT > 0)
		LED_On(LED_IDENTIFY);
#endif
		NWK_Lock();

		return true;
	}

	return false;
}
Esempio n. 7
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);
}
Esempio n. 8
0
void HalRgbLed::turnOff() {
  setColor(0, 0, 0);
  blinkTimer.mode = SYS_TIMER_INTERVAL_MODE;
  SYS_TimerStop(&blinkTimer);
}
Esempio n. 9
0
static void unitDataConf(NWK_DataReq_t *req)
{
	SYS_TimerStop(&NetworkStatusTimer);
	result = true;
}
Esempio n. 10
0
void PinoccioScout::stopPeripheralStateChangeEvents() {
  SYS_TimerStop(&peripheralStateChangeTimer);
}
Esempio n. 11
0
void PinoccioScout::stopAnalogStateChangeEvents() {
  SYS_TimerStop(&analogStateChangeTimer);
}
Esempio n. 12
0
void PinoccioScout::stopDigitalStateChangeEvents() {
  SYS_TimerStop(&digitalStateChangeTimer);
}