当前位置: 首页>>代码示例>>C++>>正文


C++ osal_stop_timerEx函数代码示例

本文整理汇总了C++中osal_stop_timerEx函数的典型用法代码示例。如果您正苦于以下问题:C++ osal_stop_timerEx函数的具体用法?C++ osal_stop_timerEx怎么用?C++ osal_stop_timerEx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了osal_stop_timerEx函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ther_display_event_report

static void ther_display_event_report(unsigned char event, uint16 arg)
{
	struct ther_info *ti = &ther_info;

	switch (event) {
	case OLED_EVENT_DISPLAY_ON:
		/* change temp measure to 1 sec */
//		change_measure_timer(ti, TEMP_MEASURE_MIN_INTERVAL);
		ti->display_picture = arg;

		if (ti->display_picture == OLED_PICTURE1) {
			if (ti->batt_percentage < LOW_BATT_WARNING_THRESHOLD) {
				ti->batt_in_dispaly = TRUE;
				osal_start_timerEx(ti->task_id, TH_LOW_BATT_BLINK_EVT, LOW_BATT_BLINK_INTERVAL);
			}
		}
		break;

	case OLED_EVENT_TIME_TO_END:
		osal_stop_timerEx(ti->task_id, TH_LOW_BATT_BLINK_EVT);

//		change_measure_timer(ti, TEMP_MEASURE_INTERVAL);
		if (ti->display_picture == OLED_PICTURE_WELCOME) {
			struct display_param param;

			/*
			 * show first picture after welcome
			 */
			encap_picture_param(ti, &param);
			oled_show_picture(OLED_PICTURE1, DISPLAY_TIME, &param);

		} else {
			ti->display_picture = OLED_PICTURE_NONE;
		}
		break;

	}
}
开发者ID:yzkqfll,项目名称:ibaby,代码行数:38,代码来源:thermometer.c

示例2: MT_SysOsalStopTimer

/***************************************************************************************************
 * @fn      MT_SysOsalStopTimer
 *
 * @brief
 *
 * @param   uint8 pData - pointer to the data
 *
 * @return  None
 ***************************************************************************************************/
void MT_SysOsalStopTimer(uint8 *pBuf)
{
  uint16 eventId;
  uint8 retValue = ZFailure;
  uint8 cmdId;

  /* parse header */
  cmdId = pBuf[MT_RPC_POS_CMD1];
  pBuf += MT_RPC_FRAME_HDR_SZ;

  if (*pBuf <= 3)
  {
    eventId = (uint16) MT_SysOsalEventId[*pBuf];
    retValue = osal_stop_timerEx(MT_TaskID, eventId);
  }
  else
  {
    retValue = ZInvalidParameter;
  }

  /* Build and send back the response */
  MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_SYS), cmdId, 1, &retValue );
}
开发者ID:DIYzzuzpb,项目名称:ZStack-CC2530-2.5.1-GPRS_GateWay,代码行数:32,代码来源:MT_SYS.c

示例3: zb_AllowBind

/******************************************************************************
 * @fn          zb_AllowBind
 *
 * @brief       The zb_AllowBind function puts the device into the
 *              Allow Binding Mode for a given period of time.  A peer device
 *              can establish a binding to a device in the Allow Binding Mode
 *              by calling zb_BindDevice with a destination address of NULL
 *
 * @param       timeout - The number of seconds to remain in the allow binding
 *                        mode.  Valid values range from 1 through 65.
 *                        If 0, the Allow Bind mode will be set false without TO
 *                        If greater than 64, the Allow Bind mode will be true
 *
 * @return      ZB_SUCCESS if the device entered the allow bind mode, else
 *              an error code.
 */
void zb_AllowBind ( uint8 timeout )
{

  osal_stop_timerEx(sapi_TaskID, ZB_ALLOW_BIND_TIMER);

  if ( timeout == 0 )
  {
    afSetMatch(sapi_epDesc.simpleDesc->EndPoint, FALSE);
  }
  else
  {
    afSetMatch(sapi_epDesc.simpleDesc->EndPoint, TRUE);
    if ( timeout != 0xFF )
    {
      if ( timeout > 64 )
      {
        timeout = 64;
      }
      osal_start_timerEx(sapi_TaskID, ZB_ALLOW_BIND_TIMER, timeout*1000);
    }
  }
  return;
}
开发者ID:DIYzzuzpb,项目名称:ZStack-CC2530-2.5.1-GPRS_GateWay,代码行数:39,代码来源:sapi.c

示例4: ParkWay_ProcessZDOMsgs

//This function process the ZDO events to bind
static void ParkWay_ProcessZDOMsgs( zdoIncomingMsg_t *inMsg )
{
  switch ( inMsg->clusterID )
  {
    case End_Device_Bind_rsp:
      if ( ZDO_ParseBindRsp( inMsg ) == ZSuccess )
      {
        // Light LED
        //HalLedSet ( HAL_LED_2, HAL_LED_MODE_FLASH );
      }
      break;

    case Match_Desc_rsp:
      {
        ZDO_ActiveEndpointRsp_t *pRsp = ZDO_ParseEPListRsp( inMsg );
        if ( pRsp )
        {
          if ( pRsp->status == ZSuccess && pRsp->cnt )
          {
            ParkWay_DstAddr.addrMode = (afAddrMode_t)Addr16Bit;
            ParkWay_DstAddr.addr.shortAddr = pRsp->nwkAddr;
            // Take the first endpoint, Can be changed to search through endpoints
            ParkWay_DstAddr.endPoint = pRsp->epList[0];

            // Light LED
            //HalLedSet( HAL_LED_2, HAL_LED_MODE_ON );

            //This stop the peer from send request do the coordinator
            //HalLedSet ( HAL_LED_1, HAL_LED_MODE_OFF);
            osal_stop_timerEx( ParkWay_TaskID,POLLING_OF_DEV_EVT);
          }
          osal_mem_free( pRsp );
        }
      }
      break;
  }
}
开发者ID:aignacio,项目名称:Smartbee-Network-,代码行数:38,代码来源:PW_EndDevice.c

示例5: ther_system_power_off_pre

static void ther_system_power_off_pre(struct ther_info *ti)
{
	/* test */
	osal_stop_timerEx(ti->task_id, TH_TEST_EVT);

	/*
	 * stop auto power off
	 */
	osal_stop_timerEx(ti->task_id, TH_AUTO_POWER_OFF_EVT);

	/*
	 * batt measure
	 */
	osal_stop_timerEx(ti->task_id, TH_BATT_EVT);
	osal_stop_timerEx(ti->task_id, TH_LOW_BATT_WARNING_EVT);

	/*
	 * stop temp timer
	 */
	osal_stop_timerEx(ti->task_id, TH_TEMP_MEASURE_EVT);
	osal_stop_timerEx(ti->task_id, TH_HIS_TEMP_RESTORE_EVT);
	osal_stop_timerEx(ti->task_id, TH_HIGH_TEMP_WARNING_EVT);

	/*
	 * play power off music
	 */
	ther_buzzer_stop_music();
	ther_buzzer_start_music(BUZZER_MUSIC_SYS_POWER_OFF);

	/*
	 * oled says goodbye
	 */
	oled_show_picture(OLED_PICTURE_GOODBYE, DISPLAY_GOODBYE_TIME, NULL);

	osal_start_timerEx(ti->task_id, TH_POWER_OFF_EVT, SYSTEM_POWER_OFF_TIME);

	ther_device_exit_pre(ti);
}
开发者ID:yzkqfll,项目名称:ibaby,代码行数:38,代码来源:thermometer.c

示例6: SerialApp_ProcessMSGCmd

/*********************************************************************
 * @fn      SerialApp_ProcessMSGCmd
 *
 * @brief   Data message processor callback. This function processes
 *          any incoming data - probably from other devices. Based
 *          on the cluster ID, perform the intended action.
 *
 * @param   pkt - pointer to the incoming message packet
 *
 * @return  TRUE if the 'pkt' parameter is being used and will be freed later,
 *          FALSE otherwise.
 */
void SerialApp_ProcessMSGCmd( afIncomingMSGPacket_t *pkt )
{
  uint8 stat;
  uint8 seqnb;
  uint8 delay;

  switch ( pkt->clusterId )
  {
  // A message with a serial data block to be transmitted on the serial port.
  case SERIALAPP_CLUSTERID1:
    seqnb = pkt->cmd.Data[0];

    // Keep message if not a repeat packet
    if ( (seqnb > SerialApp_SeqRx) ||                    // Normal
        ((seqnb < 0x80 ) && ( SerialApp_SeqRx > 0x80)) ) // Wrap-around
    {
      // Transmit the data on the serial port.
      if ( HalUARTWrite( SERIAL_APP_PORT, pkt->cmd.Data+1,
                                         (pkt->cmd.DataLength-1) ) )
      {
        // Save for next incoming message
        SerialApp_SeqRx = seqnb;

        stat = OTA_SUCCESS;
      }
      else
      {
        stat = OTA_SER_BUSY;
      }
    }
    else
    {
      stat = OTA_DUP_MSG;
    }

    // Select approproiate OTA flow-control delay.
    delay = (stat == OTA_SER_BUSY) ? SERIALAPP_NAK_DELAY : SERIALAPP_ACK_DELAY;

    // Build & send OTA response message.
    rspBuf[0] = stat;
    rspBuf[1] = seqnb;
    rspBuf[2] = LO_UINT16( delay );
    rspBuf[3] = HI_UINT16( delay );
    stat = AF_DataRequest( &(pkt->srcAddr), (endPointDesc_t*)&SerialApp_epDesc,
                            SERIALAPP_CLUSTERID2, SERIAL_APP_RSP_CNT , rspBuf,
                           &SerialApp_MsgID, 0, AF_DEFAULT_RADIUS );

    if ( stat != afStatus_SUCCESS )
    {
      osal_start_timerEx( SerialApp_TaskID, SERIALAPP_RSP_RTRY_EVT,
                                            SERIALAPP_RSP_RTRY_TIMEOUT );

      // Store the address for the timeout retry.
      osal_memcpy(&SerialApp_RspDstAddr, &(pkt->srcAddr), sizeof( afAddrType_t ));
    }
    HalLedSet(HAL_LED_2,HAL_LED_MODE_ON);
    break;

  // A response to a received serial data block.
  case SERIALAPP_CLUSTERID2:
    if ( (pkt->cmd.Data[1] == SerialApp_SeqTx) &&
        ((pkt->cmd.Data[0] == OTA_SUCCESS) ||
         (pkt->cmd.Data[0] == OTA_DUP_MSG)) )
    {
      // Remove timeout waiting for response from other device.
      osal_stop_timerEx( SerialApp_TaskID, SERIALAPP_MSG_RTRY_EVT );
      FREE_OTABUF();
      HalLedSet(HAL_LED_2,HAL_LED_MODE_ON);
    }
    else
    {
      delay = BUILD_UINT16( pkt->cmd.Data[2], pkt->cmd.Data[3] );
      // Re-start timeout according to delay sent from other device.
      osal_start_timerEx( SerialApp_TaskID, SERIALAPP_MSG_RTRY_EVT, delay );
    }
    break;
#ifndef   ZDO_COORDINATOR
  case SERIALAPP_CLUSTERID_CMD:
    CommandToBox(pkt->cmd.Data[1]);
    break;
#endif
  default:
      break;
  }
}
开发者ID:kricnam,项目名称:blackboxreader,代码行数:97,代码来源:SerialApp.c

示例7: glucCollCentralEventCB


//.........这里部分代码省略.........
        if ( DEFAULT_DEV_DISC_BY_SVC_UUID == TRUE )
        {
          if ( glucCollFindSvcUuid( GLUCOSE_SERV_UUID,
                                     pEvent->deviceInfo.pEvtData,
                                     pEvent->deviceInfo.dataLen ) )
          {
            glucCollAddDeviceInfo( pEvent->deviceInfo.addr, pEvent->deviceInfo.addrType );
          }
        }
      }
      break;
      
    case GAP_DEVICE_DISCOVERY_EVENT:
      {
        // discovery complete
        glucCollScanning = FALSE;

        // if not filtering device discovery results based on service UUID
        if ( DEFAULT_DEV_DISC_BY_SVC_UUID == FALSE )
        {
          // Copy results
          glucCollScanRes = pEvent->discCmpl.numDevs;
          osal_memcpy( glucCollDevList, pEvent->discCmpl.pDevList,
                       (sizeof( gapDevRec_t ) * pEvent->discCmpl.numDevs) );
        }
        
        LCD_WRITE_STRING_VALUE( "Devices Found", glucCollScanRes,
                                10, HAL_LCD_LINE_1 );
        if ( glucCollScanRes > 0 )
        {
          LCD_WRITE_STRING( "<- To Select", HAL_LCD_LINE_2 );
        }

        // initialize scan index to last device
        glucCollScanIdx = glucCollScanRes;

      }
      break;

    case GAP_LINK_ESTABLISHED_EVENT:
      {
        if ( pEvent->gap.hdr.status == SUCCESS )
        {          
          glucCollState = BLE_STATE_CONNECTED;
          glucCollConnHandle = pEvent->linkCmpl.connectionHandle;
          
          
          // If service discovery not performed initiate service discovery
          if ( glucCollCharHdls == false)
          {
            osal_start_timerEx( glucCollTaskId, START_DISCOVERY_EVT, DEFAULT_SVC_DISCOVERY_DELAY );
          }
                    
          LCD_WRITE_STRING( "Connected", HAL_LCD_LINE_1 );
          LCD_WRITE_STRING( bdAddr2Str( pEvent->linkCmpl.devAddr ), HAL_LCD_LINE_2 );   
        }
        else
        {
          glucCollState = BLE_STATE_IDLE;
          glucCollConnHandle = GAP_CONNHANDLE_INIT;
          glucCollDiscState = DISC_IDLE;
          
          LCD_WRITE_STRING( "Connect Failed", HAL_LCD_LINE_1 );
          LCD_WRITE_STRING_VALUE( "Reason:", pEvent->gap.hdr.status, 10, HAL_LCD_LINE_2 );
          LCD_WRITE_STRING( "", HAL_LCD_LINE_3 );
        }
      }
      break;

    case GAP_LINK_TERMINATED_EVENT:
      {
        glucCollState = BLE_STATE_IDLE;
        glucCollConnHandle = GAP_CONNHANDLE_INIT;
        glucCollDiscState = DISC_IDLE;
        glucCollPairingStarted = false;
        glucCollDiscPostponed = false;
        glucCollClearPending = false;

        // stop procedure timer
        osal_stop_timerEx( glucCollTaskId, PROCEDURE_TIMEOUT_EVT );  

        LCD_WRITE_STRING( "Disconnected", HAL_LCD_LINE_1 );
        LCD_WRITE_STRING_VALUE( "Reason:", pEvent->linkTerminate.reason,
                                10, HAL_LCD_LINE_2 );
        LCD_WRITE_STRING( "", HAL_LCD_LINE_3 );        
      }
      break;

    case GAP_LINK_PARAM_UPDATE_EVENT:
      {
        LCD_WRITE_STRING( "Param Update", HAL_LCD_LINE_1 );
        LCD_WRITE_STRING( "", HAL_LCD_LINE_2 );
        LCD_WRITE_STRING( "", HAL_LCD_LINE_3 );
      }
      break;
      
    default:
      break;
  }
}
开发者ID:zekezang,项目名称:BLE-CC254x-1.3,代码行数:101,代码来源:glucoseCollector.c

示例8: gapRole_ProcessGAPMsg


//.........这里部分代码省略.........
            
            osal_start_timerEx( gapRole_TaskID, START_CONN_UPDATE_EVT, timeout*1000 );
          }

          // Notify the Bond Manager to the connection
          VOID GAPBondMgr_LinkEst( pPkt->devAddrType, pPkt->devAddr, pPkt->connectionHandle, GAP_PROFILE_PERIPHERAL );
        }
        else if ( pPkt->hdr.status == bleGAPConnNotAcceptable )
        {
          // Set enabler to FALSE; device will become discoverable again when
          // this value gets set to TRUE
          gapRole_AdvEnabled = FALSE;

          // Go to WAITING state, and then start advertising
          gapRole_state = GAPROLE_WAITING;
        }
        else
        {
          gapRole_state = GAPROLE_ERROR;
        }
        notify = TRUE;
      }
      break;

    case GAP_LINK_TERMINATED_EVENT:
      {
        gapTerminateLinkEvent_t *pPkt = (gapTerminateLinkEvent_t *)pMsg;

        GAPBondMgr_ProcessGAPMsg( (gapEventHdr_t *)pMsg );
        osal_memset( gapRole_ConnectedDevAddr, 0, B_ADDR_LEN );

        // Erase connection information
        gapRole_ConnInterval = 0;
        gapRole_ConnSlaveLatency = 0;
        gapRole_ConnTimeout = 0;

        // Cancel all connection parameter update timers (if any active)
        VOID osal_stop_timerEx( gapRole_TaskID, START_CONN_UPDATE_EVT );
        VOID osal_stop_timerEx( gapRole_TaskID, CONN_PARAM_TIMEOUT_EVT );
          
        // Go to WAITING state, and then start advertising
        if( pPkt->reason == LL_SUPERVISION_TIMEOUT_TERM )
        {
          gapRole_state = GAPROLE_WAITING_AFTER_TIMEOUT;
        }
        else
        {
          gapRole_state = GAPROLE_WAITING;
        }

        notify = TRUE;

        VOID osal_set_event( gapRole_TaskID, START_ADVERTISING_EVT );

        gapRole_ConnectionHandle = INVALID_CONNHANDLE;
      }
      break;

    case GAP_LINK_PARAM_UPDATE_EVENT:
      {
        gapLinkUpdateEvent_t *pPkt = (gapLinkUpdateEvent_t *)pMsg;

        // Cancel connection param update timeout timer (if active)
        VOID osal_stop_timerEx( gapRole_TaskID, CONN_PARAM_TIMEOUT_EVT );
        
        if ( pPkt->hdr.status == SUCCESS )
        {
          // Store new connection parameters
          gapRole_ConnInterval = pPkt->connInterval;
          gapRole_ConnSlaveLatency = pPkt->connLatency;
          gapRole_ConnTimeout = pPkt->connTimeout;
          
          // Make sure there's no pending connection update procedure
          if ( osal_get_timeoutEx( gapRole_TaskID, START_CONN_UPDATE_EVT ) == 0 )
          {
            // Notify the application with the new connection parameters
            if ( pGapRoles_ParamUpdateCB != NULL )
            {
              (*pGapRoles_ParamUpdateCB)( gapRole_ConnInterval, 
                                          gapRole_ConnSlaveLatency, 
                                          gapRole_ConnTimeout );
            }
          }
        }
      }
      break;

    default:
      break;
  }

  if ( notify == TRUE )
  {
    // Notify the application with the new state change
    if ( pGapRoles_AppCGs && pGapRoles_AppCGs->pfnStateChange )
    {
      pGapRoles_AppCGs->pfnStateChange( gapRole_state );
    }
  }
}
开发者ID:bluewish,项目名称:ble_dev,代码行数:101,代码来源:peripheral.c

示例9: SerialApp_ProcessEvent


//.........这里部分代码省略.........
          break;
  
        case AF_INCOMING_MSG_CMD:
          SerialApp_ProcessMSGCmd( MSGpkt );
          break;
  
        case ZDO_STATE_CHANGE:
          if (SerialApp_DstAddr.addrMode == afAddrNotPresent)
             ReqMatchDesc();
          break;
        default:
          break;
      }

      osal_msg_deallocate( (uint8 *)MSGpkt );  // Release the memory.
    }

    // Return unprocessed events
    return ( events ^ SYS_EVENT_MSG );
  }

  if ( events & SERIALAPP_MSG_SEND_EVT )
  {
    SerialApp_SendData( otaBuf, otaLen );

    return ( events ^ SERIALAPP_MSG_SEND_EVT );
  }

  if ( events & SERIALAPP_MSG_RTRY_EVT )
  {
    if ( --rtryCnt )
    {
      AF_DataRequest( &SerialApp_DstAddr,
                      (endPointDesc_t *)&SerialApp_epDesc,
                       SERIALAPP_CLUSTERID1, otaLen, otaBuf,
                      &SerialApp_MsgID, 0, AF_DEFAULT_RADIUS );
      osal_start_timerEx( SerialApp_TaskID, SERIALAPP_MSG_RTRY_EVT,
                                            SERIALAPP_MSG_RTRY_TIMEOUT );
    }
    else
    {
      FREE_OTABUF();
    }

    return ( events ^ SERIALAPP_MSG_RTRY_EVT );
  }

  if ( events & SERIALAPP_RSP_RTRY_EVT )
  {
    afStatus_t stat = AF_DataRequest( &SerialApp_RspDstAddr,
                                      (endPointDesc_t *)&SerialApp_epDesc,
                                       SERIALAPP_CLUSTERID2,
                                       SERIAL_APP_RSP_CNT, rspBuf,
                                      &SerialApp_MsgID, 0, AF_DEFAULT_RADIUS );

    if ( stat != afStatus_SUCCESS )
    {
      osal_start_timerEx( SerialApp_TaskID, SERIALAPP_RSP_RTRY_EVT,
                                            SERIALAPP_RSP_RTRY_TIMEOUT );
    }

    return ( events ^ SERIALAPP_RSP_RTRY_EVT );
  }

#if SERIAL_APP_LOOPBACK
  if ( events & SERIALAPP_TX_RTRY_EVT )
  {
    if ( rxLen )
    {
      if ( !HalUARTWrite( SERIAL_APP_PORT, rxBuf, rxLen ) )
      {
        osal_start_timerEx( SerialApp_TaskID, SERIALAPP_TX_RTRY_EVT,
                                              SERIALAPP_TX_RTRY_TIMEOUT );
      }
      else
      {
        rxLen = 0;
      }
    }

    return ( events ^ SERIALAPP_TX_RTRY_EVT );
  }
#endif
  
  if (events & SERIALAPP_MSG_AUTOMATCH)
  {
    if (SerialApp_DstAddr.addrMode == afAddrNotPresent)
    {
        ReqMatchDesc();
        osal_start_timerEx(SerialApp_TaskID,SERIALAPP_MSG_AUTOMATCH,4000);
    }
    else
    {
        osal_stop_timerEx(SerialApp_TaskID,SERIALAPP_MSG_AUTOMATCH);
    }
    return (events ^ SERIALAPP_MSG_AUTOMATCH);
  }

  return ( 0 );  // Discard unknown events.
}
开发者ID:kricnam,项目名称:blackboxreader,代码行数:101,代码来源:SerialApp.c

示例10: SensorCB

/*********************************************************************
 * @fn      SensorCB
 *
 * @brief   Callback function for CSC service.
 *
 * @param   event - service event
 * @param   pNewCummVal - pointer to new wheel revolution data
 *                        if specified by event.  NULL otherwise.
 * @return  none
 */
static void SensorCB( uint8 event, uint32 *pNewCummVal )
{
  switch ( event )
  {
    case CSC_CMD_SET_CUMM_VAL:
      // Cancel neglect timer
      if ( USING_NEGLECT_TIMEOUT )
      {
        osal_stop_timerEx( sensor_TaskID, CSC_NEGLECT_TIMEOUT_EVT );
      }

      cummWheelRevs = *pNewCummVal;

      // Start neglect timer
      if ( USING_NEGLECT_TIMEOUT )
      {
        osal_start_timerEx( sensor_TaskID, CSC_NEGLECT_TIMEOUT_EVT, NEGLECT_TIMEOUT_DELAY );
      }
      break;

    case CSC_CMD_UPDATE_SENS_LOC:
      // Cancel neglect timer
      if ( USING_NEGLECT_TIMEOUT )
      {
        osal_stop_timerEx( sensor_TaskID, CSC_NEGLECT_TIMEOUT_EVT );
      }

      // Get updated sensor location
      Cycling_GetParameter( CSC_SENS_LOC, &sensorLocation );

      // Start neglect timer
      if ( USING_NEGLECT_TIMEOUT )
      {
        osal_start_timerEx( sensor_TaskID, CSC_NEGLECT_TIMEOUT_EVT, NEGLECT_TIMEOUT_DELAY );
      }
      break;

    case CSC_MEAS_NOTI_ENABLED:
      // Cancel neglect timer
      if ( USING_NEGLECT_TIMEOUT )
      {
        osal_stop_timerEx( sensor_TaskID, CSC_NEGLECT_TIMEOUT_EVT );
      }

      // If connected start periodic measurement
      if (gapProfileState == GAPROLE_CONNECTED)
      {
        osal_start_timerEx( sensor_TaskID, CSC_PERIODIC_EVT, DEFAULT_CSC_PERIOD );
      }
      break;

    case CSC_MEAS_NOTI_DISABLED:
      // Stop periodic measurement
      osal_stop_timerEx( sensor_TaskID, CSC_PERIODIC_EVT );

      // Start neglect timer
      if ( USING_NEGLECT_TIMEOUT )
      {
        osal_start_timerEx( sensor_TaskID, CSC_NEGLECT_TIMEOUT_EVT, NEGLECT_TIMEOUT_DELAY );
      }
      break;

    case CSC_READ_ATTR:
    case CSC_WRITE_ATTR:
      if ( USING_NEGLECT_TIMEOUT )
      {
        // Cancel neglect timer
        osal_stop_timerEx( sensor_TaskID, CSC_NEGLECT_TIMEOUT_EVT );

        // Start neglect timer
        osal_start_timerEx( sensor_TaskID, CSC_NEGLECT_TIMEOUT_EVT, NEGLECT_TIMEOUT_DELAY );
      }
      break;

    default:
      break;
  }
}
开发者ID:linan0827,项目名称:ble_csc,代码行数:88,代码来源:LCSC_Sensor.c

示例11: simpleBLECentralEventCB

/*********************************************************************************************
 * @fn      simpleBLECentralEventCB
 *
 * @brief   Central event callback function.
 *
 * @param   pEvent - pointer to event structure
 *
 * @return  none
 **********************************************************************************************/
static void simpleBLECentralEventCB( gapCentralRoleEvent_t *pEvent ){
  switch ( pEvent->gap.opcode ){
                case GAP_DEVICE_INIT_DONE_EVENT:{  
       			    //LCDPrintText("Central Initialized",0,PRINT_STRING);
                            osal_memcpy(mac_buffer[0],pEvent->initDone.devAddr, MAC_LEN);        		               
                            HalLcdWriteString(bdAddr2Str( mac_buffer[0]), HAL_LCD_LINE_1); 
			    
                            
                            uint32 random_scan_duration =500;//to avoid normal scan be discarded by the timer,so its lasting-time should be short
                            GAP_SetParamValue( TGAP_GEN_DISC_SCAN, random_scan_duration );        //random scan duration
                            //LCDPrintText("discovering",0,PRINT_STRING);
                            
                            uint32 timeout_value = 200;				// timeout_value - in milliseconds.
                            osal_start_timerEx(MasterSlaveSwitchTaskID, PERIOD_DETECH_EVT, timeout_value);
                            

                            
                            uint8 return_status;
                            if(return_status = GAPCentralRole_StartDiscovery(DISCOVERY_MODE, ACTIVE_SCAN, DISCOVERY_WHITE_LIST ))
                                 	LCDPrintText("discovery error:",return_status,PRINT_VALUE); 
			    break;
                }
      	
      
                case GAP_DEVICE_INFO_EVENT:{						//find a new device 				     			
				// filtering device discovery results based on service UUID
                            //LCDPrintText("find new device",0,PRINT_STRING);   
                            if(simpleBLEScanRes >= MAX_SCAN_RES){
                                            GAPCentralRole_CancelDiscovery();
                                            break;
                            }
                            
                            if ( simpleBLEFindSvcUuid(WANTED_SERVICE_UUID, pEvent->deviceInfo.pEvtData, pEvent->deviceInfo.dataLen) ){
         				simpleBLEAddDeviceInfo( pEvent->deviceInfo.addr, pEvent->deviceInfo.addrType );
                                   //GAPCentralRole_CancelDiscovery();     //stop discoverying                                    
                            }			
			    break;
                }
      		           
   	 	case GAP_DEVICE_DISCOVERY_EVENT:{   			//discaovery has completed 
                           osal_stop_timerEx(MasterSlaveSwitchTaskID,PERIOD_DETECH_EVT);
                            //LCDPrintText("disca completed ",0,PRINT_STRING);    
        		    if ( simpleBLEScanRes > 0 ){
	          			// connect to current device in scan result                                                                             
                                        uint8 random_select = random_num%simpleBLEScanRes;
                                        //LCDPrintText("random_select ",random_select,PRINT_STRING); 
					CurrentConnectionInfo.MacType= simpleBLEDevList[random_select].addrType;
	     		 		CurrentConnectionInfo.MacAddr= simpleBLEDevList[random_select].addr; 
          				uint8 return_status;
                                        if(return_status = GAPCentralRole_EstablishLink( LINK_HIGH_DUTY_CYCLE, LINK_WHITE_LIST, CurrentConnectionInfo.MacType, CurrentConnectionInfo.MacAddr)){
                                                  LCDPrintText("Link Error",return_status,PRINT_VALUE); 
                                                  osal_set_event(MasterSlaveSwitchTaskID, MSS_CHANGE_ROLE_EVT);
                                        } 
			    }

                            else{
					//LCDPrintText("no device found",0,PRINT_STRING);                                        
                                       	osal_set_event(MasterSlaveSwitchTaskID, MSS_CHANGE_ROLE_EVT);     //switch to periperal                                        
                            }


			    break;
      		}
      
    		case GAP_LINK_ESTABLISHED_EVENT:{
      	 		    if ( pEvent->gap.hdr.status == SUCCESS ){ 
                                        
					//LCDPrintText("Connected",0,PRINT_STRING);     				
          				CurrentConnectionInfo.Handle= pEvent->linkCmpl.connectionHandle;  
                                        
                                        if(CharHandleSearchFlag == 1)
         				      simpleBLECentralStartDiscovery(); 
                                        else{
                                              ClientWriteValue();                                              
                                              CharSendingFlag =1;
                                              //LCDPrintText("NO NEED TO",0,PRINT_STRING);  
                                        }
      	 		    }
       			
       			    else{				                                        
                                        LCDPrintText("Connect Failed ",pEvent->gap.hdr.status,PRINT_VALUE);
                                            osal_set_event(MasterSlaveSwitchTaskID, MSS_CHANGE_ROLE_EVT);
       			    	}

			    break;
      		}
      

    		case GAP_LINK_TERMINATED_EVENT:{       
                                        osal_set_event(MasterSlaveSwitchTaskID, MSS_CHANGE_ROLE_EVT);
      			    break;
//.........这里部分代码省略.........
开发者ID:androdenpark,项目名称:Ti-Wireless-Chip-Demo,代码行数:101,代码来源:auto_switch_central.c

示例12: SensorCB

/*********************************************************************
 * @fn      SensorCB
 *
 * @brief   Callback function for RSC service.
 *
 * @param   event - service event
 * @param   pNewCummVal - pointer to new total distanace data
 *                        if specified by event.  NULL otherwise.
 *
 * @return  SUCCESS if operation successful. FAILURE, otherwise.
 */
static bStatus_t SensorCB(uint8 event, uint32 *pNewCummVal)
{
  bStatus_t status = SUCCESS;

  switch ( event )
  {
    case RSC_CMD_SET_CUMM_VAL:
      // Cancel neglect timer
      if ( USING_NEGLECT_TIMEOUT )
      {
        osal_stop_timerEx( sensor_TaskID, RSC_NEGLECT_TIMEOUT_EVT );
      }

      // Update total distance
      totalDistance = *pNewCummVal;

      // Start neglect timer
      if ( USING_NEGLECT_TIMEOUT )
      {
        osal_start_timerEx( sensor_TaskID, RSC_NEGLECT_TIMEOUT_EVT, NEGLECT_TIMEOUT_DELAY );
      }
      break;

    case RSC_CMD_START_SENS_CALIB:
      if ( sensorFlags[sensorFlagsIdx] != RSC_FLAGS_AT_REST )
      {
        // Induce a calibration error for conformance testing
        status = FAILURE;
      }
      break;

    case RSC_CMD_UPDATE_SENS_LOC:
      // Cancel neglect timer
      if ( USING_NEGLECT_TIMEOUT )
      {
        osal_stop_timerEx( sensor_TaskID, RSC_NEGLECT_TIMEOUT_EVT );
      }

      // Get updated sensor location
      Running_GetParameter( RSC_SENS_LOC, &sensorLocation );

      // Start neglect timer
      if ( USING_NEGLECT_TIMEOUT )
      {
        osal_start_timerEx( sensor_TaskID, RSC_NEGLECT_TIMEOUT_EVT, NEGLECT_TIMEOUT_DELAY );
      }
      break;

    case RSC_MEAS_NOTI_ENABLED:
      // Cancel neglect timer
      if ( USING_NEGLECT_TIMEOUT )
      {
        osal_stop_timerEx( sensor_TaskID, RSC_NEGLECT_TIMEOUT_EVT );
      }

      // if connected start periodic measurement
      if (gapProfileState == GAPROLE_CONNECTED)
      {
        osal_start_timerEx( sensor_TaskID, RSC_PERIODIC_EVT, DEFAULT_RSC_PERIOD );
      }
      break;

    case RSC_MEAS_NOTI_DISABLED:
      // stop periodic measurement
      osal_stop_timerEx( sensor_TaskID, RSC_PERIODIC_EVT );

      // Start neglect timer
      if ( USING_NEGLECT_TIMEOUT )
      {
        osal_start_timerEx( sensor_TaskID, RSC_NEGLECT_TIMEOUT_EVT, NEGLECT_TIMEOUT_DELAY );
      }
      break;

    case RSC_READ_ATTR:
    case RSC_WRITE_ATTR:
      if ( USING_NEGLECT_TIMEOUT )
      {
        // Cancel neglect timer
        osal_stop_timerEx( sensor_TaskID, RSC_NEGLECT_TIMEOUT_EVT );

        // Start neglect timer
        osal_start_timerEx( sensor_TaskID, RSC_NEGLECT_TIMEOUT_EVT, NEGLECT_TIMEOUT_DELAY );
      }
      break;

    default:
      break;
  }

//.........这里部分代码省略.........
开发者ID:HorseMa,项目名称:BLE-CC254x-1.4.0,代码行数:101,代码来源:runningSensor.c

示例13: sensor_HandleKeys

/*********************************************************************
 * @fn      sensor_HandleKeys
 *
 * @brief   Handles all key events for this device.
 *
 * @param   shift - true if in shift/alt.
 * @param   keys - bit field for key events. Valid entries:
 *                 HAL_KEY_SW_2
 *                 HAL_KEY_SW_1
 *
 * @return  none
 */
static void sensor_HandleKeys( uint8 shift, uint8 keys )
{
  if ( keys == ( HAL_KEY_SW_1 | HAL_KEY_SW_2 ) )
  {
    // Reset in progress has started
    resetInProgress = TRUE;

    // Set OSAL timer for reset
    osal_start_timerEx( sensor_TaskID, RSC_RESET_EVT, RSC_RESET_DELAY );
  }
  else if ( keys & HAL_KEY_SW_1 )
  {
    if ( resetInProgress == TRUE )
    {
      // Cancel the reset
      resetInProgress = FALSE;
      osal_stop_timerEx ( sensor_TaskID, RSC_RESET_EVT );
    }

    // set simulated measurement flag index
    if (++sensorFlagsIdx == FLAGS_IDX_MAX)
    {
      sensorFlagsIdx = 0;
    }
  }
  else if ( keys & HAL_KEY_SW_2 )
  {
    if ( resetInProgress == TRUE )
    {
      // Cancel the reset
      resetInProgress = FALSE;
      osal_stop_timerEx ( sensor_TaskID, RSC_RESET_EVT );
    }

    // if not in a connection, toggle advertising on and off
    if ( gapProfileState != GAPROLE_CONNECTED )
    {
      uint8 status;

      // Set fast advertising interval for user-initiated connections
      GAP_SetParamValue( TGAP_GEN_DISC_ADV_INT_MIN, DEFAULT_FAST_ADV_INTERVAL );
      GAP_SetParamValue( TGAP_GEN_DISC_ADV_INT_MAX, DEFAULT_FAST_ADV_INTERVAL );
      GAP_SetParamValue( TGAP_GEN_DISC_ADV_MIN, DEFAULT_WHITE_LIST_ADV_DURATION );

      // toggle GAP advertisement status
      GAPRole_GetParameter( GAPROLE_ADVERT_ENABLED, &status );
      status = !status;

      // If not already using white list, begin to do so.
      // Only do so if about to begin advertising
      if ( USING_WHITE_LIST && status == TRUE )
      {
        uint8 bondCount = 0;

        GAPBondMgr_GetParameter( GAPBOND_BOND_COUNT, &bondCount );

        if ((sensorUsingWhiteList == FALSE) && (bondCount > 0) )
        {
          uint8 value = GAP_FILTER_POLICY_WHITE;

          GAPRole_SetParameter(GAPROLE_ADV_FILTER_POLICY, sizeof( uint8 ), &value);

          sensorUsingWhiteList = TRUE;
        }
      }

      GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &status );

      // Set state variable
      if (status == FALSE)
      {
        sensorAdvCancelled = TRUE;
      }
    }
    else if ( gapProfileState == GAPROLE_CONNECTED )
    {
      // If connected, change rate of motion
      if( (++motionIdx) == MOTION_IDX_MAX )
      {
        motionIdx = 0;
      }

      motion = motionCycle[motionIdx];
    }
  }
  // end of key press
  else if ( keys == 0x00 )
  {
//.........这里部分代码省略.........
开发者ID:HorseMa,项目名称:BLE-CC254x-1.4.0,代码行数:101,代码来源:runningSensor.c

示例14: ther_handle_ps_event

static void ther_handle_ps_event(unsigned char event, unsigned char *data, unsigned char *len)
{
	struct ther_info *ti = &ther_info;
	UTCTimeStruct utc;
	uint16 high_temp_threshold;

	switch (event) {
	case THER_PS_GET_WARNING_ENABLED:
		*data = ti->warning_enabled;
		*len = 1;
		print(LOG_DBG, MODULE "get warning enabled: %d\n", *data);
		break;

	case THER_PS_SET_WARNING_ENABLED:
		ti->warning_enabled = *data;
		print(LOG_DBG, MODULE "set warning enabled: %d\n", *data);
		break;

	case THER_PS_CLEAR_WARNING:
		print(LOG_DBG, MODULE "clear warning: %d\n", *data);
		ther_clear_high_temp_warning(ti);
		break;

	case THER_PS_GET_HIGH_WARN_TEMP:
		memcpy(data, &ti->high_temp_threshold, sizeof(ti->high_temp_threshold));
		*len = sizeof(ti->high_temp_threshold);
		print(LOG_DBG, MODULE "get high temp: %d\n", *(unsigned short *)data);
		break;

	case THER_PS_SET_HIGH_WARN_TEMP:
		memcpy(&high_temp_threshold, data, sizeof(high_temp_threshold));

		if (storage_write_high_temp_threshold(high_temp_threshold)) {
			print(LOG_DBG, MODULE "set high temp: %d\n", high_temp_threshold);
			ti->high_temp_threshold = high_temp_threshold;
			ti->next_warning_threshold = ti->high_temp_threshold;
		} else {
			print(LOG_DBG, MODULE "set high temp: %d failed\n", high_temp_threshold);
		}

		break;

	case THER_PS_GET_TIME:
		osal_ConvertUTCTime(&utc, osal_getClock());

		memcpy(data, &utc, sizeof(utc));
		*len = sizeof(utc);
		print(LOG_DBG, MODULE "get time: %d-%02d-%02d %02d:%02d:%02d\n",
				utc.year, utc.month, utc.day, utc.hour, utc.minutes, utc.seconds);
		break;

	case THER_PS_SET_TIME:
		memcpy(&utc, data, sizeof(utc));
		osal_setClock(osal_ConvertUTCSecs(&utc));
		print(LOG_DBG, MODULE "set time: %d-%02d-%02d %02d:%02d:%02d\n",
				utc.year, utc.month, utc.day, utc.hour, utc.minutes, utc.seconds);

		ti->start_sec = osal_ConvertUTCSecs(&utc);
		break;

	case THER_PS_GET_DEBUG:
		{
			ti->mode = CAL_MODE;
			/*
			 * stop temp measurement
			 */
			osal_stop_timerEx(ti->task_id, TH_TEMP_MEASURE_EVT);
			ther_temp_power_on();
			ti->temp_measure_stage = TEMP_STAGE_SETUP;

			/*
			 * stop batt measurement
			 */
			osal_stop_timerEx(ti->task_id, TH_BATT_EVT);
		}
		*(unsigned short *)data = ther_get_hw_adc(HAL_ADC_CHANNEL_0, FROM_CUSTOM);
		*len = 2;
		break;

	case THER_PS_SET_DEBUG:
		break;

	default:
		*len = 0;
		break;
	}
}
开发者ID:yzkqfll,项目名称:ibaby,代码行数:87,代码来源:thermometer.c

示例15: zcl_ProcessEZMode

/*********************************************************************
 * @fn      zcl_ProcessEZMode
 *
 * @brief   Called when EZ-Mode changes state. See EZMODE_STATE_xxxx in zcl_ezmode.h
 *
 * @param   none
 *
 * @return  status
 */
static void zcl_ProcessEZMode( void )
{
  zAddrType_t dstAddr;
  afAddrType_t afDstAddr;
  zclEZMode_CBData_t cbData;

  dstAddr.addr.shortAddr = 0xfffc;        // all routers (for PermitJoin) devices
  dstAddr.addrMode = AddrBroadcast;

  afDstAddr.addr.shortAddr = 0xffff;      // all devices (for IdentifyQuery)
  afDstAddr.addrMode = afAddrBroadcast;
  afDstAddr.endPoint = 0xff;

  switch(zclEZModeState)
  {
    // openers will broadcast permit joining
    case EZMODE_STATE_OPENER:
      zclEZModeOpener = 1;

      // enable joining both locally and over-the-air
      NLME_PermitJoiningRequest( (byte)(EZMODE_TIME / 1000)  );
      ZDP_MgmtPermitJoinReq( &dstAddr, (byte)(EZMODE_TIME / 1000), TRUE, FALSE);

      // then go to identifying state
      zcl_SetEZModeState(EZMODE_STATE_IDENTIFYING);
    break;

    // joiners will try to join the network, and if success will go to identifying state
    case EZMODE_STATE_JOINER:
      zclEZModeOpener = 0;
      ZDOInitDevice(0);   // see ZDO_STATE_CHANGE in zclSampleSw_event_loop()
    break;

    // go into identify state
    case EZMODE_STATE_IDENTIFYING:

      // tell app to go into identify mode
      if ( zclEZModeRegisterData.pfnNotifyCB )
      {
        (*zclEZModeRegisterData.pfnNotifyCB)( zclEZModeState, NULL );
      }

      // initiators start looking for other nodes in identify mode
      if ( zclEZModeInvokeData.initiator )
      {
        zcl_SetEZModeState ( EZMODE_STATE_WAITING_IDENTIFYQUERYRSP );
      }
    break;

    // timeout out with no query response, send another
    case EZMODE_STATE_WAITING_IDENTIFYQUERYRSP:
      // ZStatus_t zclGeneral_SendIdentifyQuery( uint8 srcEP, afAddrType_t *dstAddr, uint8 disableDefaultRsp, uint8 seqNum );
      // NOTE: Ensure that Identify Cluster is enabled to use this function for EZ-Mode
      zclGeneral_SendIdentifyQuery( zclEZModeInvokeData.endpoint, &afDstAddr, TRUE, (*zclEZModeRegisterData.pZclSeqNum)++ );

      // wait some time before sending out the next IdentifyQuery, will stop when we get a response
      osal_start_timerEx( *zclEZModeRegisterData.pTaskID, zclEZModeRegisterData.processEvt, EZMODE_IDQUERYTIME );
      break;

    // waiting for simple descriptor response
    case EZMODE_STATE_WAITING_MATCHDESCRSP:
    break;

    // if waiting on autoclose, then we're done. Go to success.
    case EZMODE_STATE_AUTOCLOSE:

      // special case: if 2 initators, we only fail if no match from either side
      if( zclEZModeInvokeData.initiator && !zclEZModeMatched )
      {
        zcl_SetEZModeError ( EZMODE_ERR_NOMATCH );
      }

      // if user specified callback, call on AutoClose
      if ( zclEZModeRegisterData.pfnNotifyCB )
      {
        cbData.sAutoClose.err = zclEZModeErr;
        (*zclEZModeRegisterData.pfnNotifyCB)( zclEZModeState, &cbData );
      }

      // no longer will timeout, since cannot fail
      osal_stop_timerEx( *zclEZModeRegisterData.pTaskID, zclEZModeRegisterData.timeoutEvt );

      // wait a little to turn off identify mode, to give time for the other side to discover
      // in case of complex devices (both target/initiator)
      osal_start_timerEx( *zclEZModeRegisterData.pTaskID, zclEZModeRegisterData.processEvt, EZMODE_AUTOCLOSETIME );

      // go to finish state after autoclose. Don't use zcl_SetEZModeState() because we don't want it to happen immediately
      zclEZModeState = EZMODE_STATE_FINISH;
    break;

    case EZMODE_STATE_FINISH:
//.........这里部分代码省略.........
开发者ID:Daan1992,项目名称:WSN-Lab,代码行数:101,代码来源:zcl_ezmode.c


注:本文中的osal_stop_timerEx函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。