• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ HI_UINT16函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: SNP_processStateChangeEvt

/*********************************************************************
 * @fn      SNP_processStateChangeEvt
 *
 * @brief   Process a pending GAP Role state change event.
 *
 * @param   newState - new state
 *
 * @return  None.
 */
void SNP_processStateChangeEvt(gaprole_States_t newState)
{
  static bool firstConnFlag = false;
  static gaprole_States_t currentState = GAPROLE_STARTED;
  static uint16_t currentConnectHandle;
  
 
  switch (newState)
  {
    case GAPROLE_STARTED:
      GAPRole_GetParameter(GAPROLE_CONNHANDLE, &currentConnectHandle);
      break;

    case GAPROLE_ADVERTISING:
      break;

    case GAPROLE_ADVERTISING_NONCONN:
    /* After a connection is dropped a device will continue
     * sending non-connectable advertisements and shall sending this change of 
     * state to the application.  These are then disabled here so that sending 
     * connectable advertisements can resume.
     */
      {
        if(firstConnFlag)
        {
          // We were in a connection.
          uint8_t param[3];

          param[0] = LO_UINT16(currentConnectHandle);
          param[1] = HI_UINT16(currentConnectHandle);
          GAPRole_GetParameter(GAPROLE_CONN_TERM_REASON, &param[2]);

          //reset the GATT state for this connection handle
          SNP_resetGATT(*((uint16_t*) &param[0])); 
          //Connection Ended
          SNP_eventToHost_send(SNP_CONN_TERM_EVT, NULL, sizeof(param), param);
        }
        // Reset flag for next connection.
        firstConnFlag = false;
      }
      break;
    case GAPROLE_CONNECTED:
      if(firstConnFlag == false)
      {
        uint8_t peerAddress[B_ADDR_LEN];

        GAPRole_GetParameter(GAPROLE_CONN_BD_ADDR, peerAddress);
        GAPRole_GetParameter(GAPROLE_CONNHANDLE, &currentConnectHandle);
        {
          uint8_t param[15];
          GAPRole_GetParameter(GAPROLE_CONNHANDLE, &param[0]);
          GAPRole_GetParameter(GAPROLE_CONN_INTERVAL, &param[2]);
          GAPRole_GetParameter(GAPROLE_CONN_LATENCY, &param[4]);
          GAPRole_GetParameter(GAPROLE_CONN_TIMEOUT, &param[6]);
          GAPRole_GetParameter(GAPROLE_BD_ADDR_TYPE, &param[8]);
          memcpy(&param[9], peerAddress, 6);
          //Advertisement Ended due to the connection
          SNP_eventToHost_send(SNP_CONN_EST_EVT, 
                                NULL, sizeof(param), param);
        }

        // if 4.1 feature are enable on the controller, 
        // then the adv needs to be forced to 
        // be non-connectable, since peripheral.c does not support multiple 
        // connection.
        // Only turn advertising on for this state when we first connect
        // otherwise, when we go from connected_advertising back to this 
        // state we will be turning advertising back on.
        firstConnFlag = true;                   
      }
      break;

    case GAPROLE_CONNECTED_ADV:
      break;

    case GAPROLE_WAITING:
      {
        if(firstConnFlag)
        {
          // We were in a connection.
          uint8_t param[3];
          
          param[0] = LO_UINT16(currentConnectHandle);
          param[1] = HI_UINT16(currentConnectHandle);
          GAPRole_GetParameter(GAPROLE_CONN_TERM_REASON, &param[2]);

          //reset the GATT state for this connection handle
          SNP_resetGATT(*((uint16_t*)&param[0])); 
          //Connection Ended
          SNP_eventToHost_send(SNP_CONN_TERM_EVT, NULL, sizeof(param), param);
         
//.........这里部分代码省略.........
开发者ID:victor-zheng,项目名称:BLE,代码行数:101,代码来源:simpleNP_GAP.c


示例2: Time_configNext

/*********************************************************************
 * @fn      Time_configNext()
 *
 * @brief   Perform the characteristic configuration read or
 *          write procedure.
 *
 * @param   state - Configuration state.
 *
 * @return  New configuration state.
 */
uint8_t Time_configNext(uint8_t state)
{
  bool read;

  // Find next non-zero cached handle of interest
  while (state < TIME_CONFIG_MAX &&
          Time_handleCache[Time_configList[state]] == 0)
  {
    state++;
  }

  // Return if reached end of list
  if (state >= TIME_CONFIG_MAX)
  {
    return TIME_CONFIG_CMPL;
  }

  // Determine what to do with characteristic
  switch (Time_configList[state])
  {
    // Read these characteristics
    case HDL_CURR_TIME_CT_TIME_START:
      read = TRUE;
      break;

    // Set notification for these characteristics
    case HDL_CURR_TIME_CT_TIME_CCCD:
      read = FALSE;
      break;

    default:
      return state;
  }

  if(Time_configDone==TRUE)
  {
    return state;
  }
  
  // Do a GATT read or write
  if (read)
  {
    attReadReq_t  readReq;
      
    readReq.handle = Time_handleCache[Time_configList[state]];
    
    // Send the read request
    GATT_ReadCharValue(Time_connHandle, &readReq, ICall_getEntityId());
    
    // Only reading time right now
    Time_configDone = TRUE;
  }
  else
  {
    attWriteReq_t writeReq;
    
    writeReq.pValue = GATT_bm_alloc(Time_connHandle, ATT_WRITE_REQ, 2, NULL);
    if (writeReq.pValue != NULL)
    {
      writeReq.len = 2;
      writeReq.pValue[0] = LO_UINT16(GATT_CLIENT_CFG_NOTIFY);
      writeReq.pValue[1] = HI_UINT16(GATT_CLIENT_CFG_NOTIFY);
      writeReq.sig = 0;
      writeReq.cmd = 0;

      writeReq.handle = Time_handleCache[Time_configList[state]];
      
      // Send the read request
      if (GATT_WriteCharValue(Time_connHandle, &writeReq, 
                              ICall_getEntityId()) != SUCCESS)
      {
        GATT_bm_free((gattMsg_t *)&writeReq, ATT_WRITE_REQ);
      }
    }
  }

  return state;
}
开发者ID:dgiovanelli,项目名称:climb.stfirmware_BLEstack2.2,代码行数:88,代码来源:time_config.c


示例3: GlucoseDevInfoDisc

/*********************************************************************
 * @fn      GlucoseDevInfoDisc
 *
 * @brief   Current glucose service and characteristic discovery. 
 *
 * @param   state - Discovery state.
 * @param   pMsg - GATT message.
 *
 * @return  New discovery state.
 */
static uint8_t GlucoseDevInfoDisc(uint8_t state, gattMsgEvent_t *pMsg)
{
  uint8_t newState = state;
  
  switch (state)
  {
    case DISC_DEVINFO_START:  
      {
        uint8_t uuid[ATT_BT_UUID_SIZE] = { LO_UINT16(DEVINFO_SERV_UUID),
                                           HI_UINT16(DEVINFO_SERV_UUID) };

        // Initialize service discovery variables
        glucoseSvcStartHdl = glucoseSvcEndHdl = 0;
        glucoseEndHdlIdx = 0;
        
        // Discover service by UUID
        GATT_DiscPrimaryServiceByUUID(glucCollConnHandle, uuid,
                                      ATT_BT_UUID_SIZE, glucCollTaskId);      

        newState = DISC_DEVINFO_SVC;
      } 
      break;

    case DISC_DEVINFO_SVC:
      // Service found, store handles
      if (pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP &&
          pMsg->msg.findByTypeValueRsp.numInfo > 0)
      {
        glucoseSvcStartHdl = 
          ATT_ATTR_HANDLE(pMsg->msg.findByTypeValueRsp.pHandlesInfo, 0);
        glucoseSvcEndHdl = 
          ATT_GRP_END_HANDLE(pMsg->msg.findByTypeValueRsp.pHandlesInfo, 0);
      }
      
      // If procedure complete
      if ((pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP  && 
           pMsg->hdr.status == bleProcedureComplete) ||
          (pMsg->method == ATT_ERROR_RSP))
      {
        // If service found
        if (glucoseSvcStartHdl != 0)
        {
          // Discover all characteristics
          GATT_DiscAllChars(glucCollConnHandle, glucoseSvcStartHdl,
                            glucoseSvcEndHdl, glucCollTaskId);
          
          newState = DISC_DEVINFO_CHAR;
        }
        else
        {
          // Service not found
          newState = DISC_FAILED;
        }
      }    
      break;

    case DISC_DEVINFO_CHAR:
      {
        uint8_t   i;
        uint8_t   *p;
        uint16_t  handle;
        uint16_t  uuid;
        
        // Characteristics found
        if (pMsg->method == ATT_READ_BY_TYPE_RSP &&
            pMsg->msg.readByTypeRsp.numPairs > 0 && 
            pMsg->msg.readByTypeRsp.len == CHAR_DESC_HDL_UUID16_LEN)
        {
          // For each characteristic declaration
          p = pMsg->msg.readByTypeRsp.pDataList;
          
          for (i = pMsg->msg.readByTypeRsp.numPairs; i > 0; i--)
          {
            // Parse characteristic declaration
            handle = BUILD_UINT16(p[3], p[4]);
            uuid = BUILD_UINT16(p[5], p[6]);
                   
            // If UUID is of interest, store handle
            switch (uuid)
            {
              case MANUFACTURER_NAME_UUID:
                glucoseHdlCache[HDL_DEVINFO_MANUFACTURER_NAME] = handle;
                break;                
                
              case SYSTEM_ID_UUID:
                glucoseHdlCache[HDL_DEVINFO_SYSTEM_ID] = handle;
                break;
                
              case MODEL_NUMBER_UUID:
                glucoseHdlCache[HDL_DEVINFO_MODEL_NUM] = handle;
//.........这里部分代码省略.........
开发者ID:victor-zheng,项目名称:BLE,代码行数:101,代码来源:glucose_discovery.c


示例4: glucoseCtlPntWriteFilter

uint8 glucoseCtlPntWriteFilter(uint8 opcode, uint8 oper, uint8 filterType,
                               void* param1, void* param2)
{
  attWriteReq_t writeReq;
  uint8 status;

  writeReq.pValue = GATT_bm_alloc( glucCollConnHandle, ATT_WRITE_REQ,
                                   GLUCOSE_CTL_PNT_FILTER_LEN, NULL );
  if (writeReq.pValue != NULL)
  {
    UTCTimeStruct *time1, *time2;
    uint16 *seqNum1, *seqNum2;
    
    uint8 *p = writeReq.pValue;
    
    *p++ = opcode;
    *p++ = oper;

    // The operator will tells us whether to include the filters or not
    // Note day and month are converted to date time struct values
    switch(oper)
    {
      case CTL_PNT_OPER_LESS_EQUAL:
      case CTL_PNT_OPER_GREATER_EQUAL:
        *p++ = filterType;
        
        if (filterType == CTL_PNT_FILTER_SEQNUM)
        {
          seqNum1 = param1;
          *p++ = LO_UINT16(*seqNum1);
          *p++ = HI_UINT16(*seqNum1);
        }
        else
        {
          time1 = param1;
          *p++ = LO_UINT16(time1->year);
          *p++ = HI_UINT16(time1->year);
          *p++ = (time1->month + 1);
          *p++ = (time1->day + 1);
          *p++ = time1->hour;
          *p++ = time1->minutes;
          *p++ = time1->seconds;
        }
        break;
        
      case CTL_PNT_OPER_RANGE:
        *p++ = filterType;
        
        if (filterType == CTL_PNT_FILTER_SEQNUM)
        {
          seqNum1 = param1;
          seqNum2 = param2;
          *p++ = LO_UINT16(*seqNum1);
          *p++ = HI_UINT16(*seqNum1);
          *p++ = LO_UINT16(*seqNum2);
          *p++ = HI_UINT16(*seqNum2);      
        }
        else
        {
          time1 = param1;
          time2 = param2;
          *p++ = LO_UINT16(time1->year);
          *p++ = HI_UINT16(time1->year);
          *p++ = (time1->month + 1);
          *p++ = (time1->day + 1);
          *p++ = time1->hour;
          *p++ = time1->minutes;
          *p++ = time1->seconds;
          
          *p++ = LO_UINT16(time2->year);
          *p++ = HI_UINT16(time2->year);
          *p++ = (time2->month + 1);
          *p++ = (time2->day + 1);
          *p++ = time2->hour;
          *p++ = time2->minutes;
          *p++ = time2->seconds;
        }
        break;
        
      default:
        break;
    }
    
    writeReq.len = (p - writeReq.pValue);
    writeReq.sig = 0;
    writeReq.cmd = 0;
    
    writeReq.handle = glucoseHdlCache[HDL_GLUCOSE_CTL_PNT_START];
    
    // Send the write request
    status = GATT_WriteCharValue( glucCollConnHandle, &writeReq, glucCollTaskId );
    if (status != SUCCESS)
    {
      GATT_bm_free( (gattMsg_t *)&writeReq, ATT_WRITE_REQ );
    }
  }
  else
  {
    status = bleMemAllocError;
  }
//.........这里部分代码省略.........
开发者ID:zilzu,项目名称:BLE-CC254x-1.4.2.2,代码行数:101,代码来源:glucose_ctlpnt.c


示例5: LO_UINT16

#define PP_DEFAULT_PATH_LOSS              0x7F

#define SERVAPP_NUM_ATTR_SUPPORTED        5

/*********************************************************************
 * TYPEDEFS
 */

/*********************************************************************
 * GLOBAL VARIABLES
 */

// Link Loss Service UUID
CONST uint8 linkLossServUUID[ATT_BT_UUID_SIZE] =
{ 
  LO_UINT16( LINK_LOSS_SERV_UUID ), HI_UINT16( LINK_LOSS_SERV_UUID )
};

// Immediate Alert Service UUID
CONST uint8 imAlertServUUID[ATT_BT_UUID_SIZE] =
{ 
  LO_UINT16( IMMEDIATE_ALERT_SERV_UUID ), HI_UINT16( IMMEDIATE_ALERT_SERV_UUID )
};

// Tx Power Level Service UUID
CONST uint8 txPwrLevelServUUID[ATT_BT_UUID_SIZE] =
{ 
  LO_UINT16( TX_PWR_LEVEL_SERV_UUID ), HI_UINT16( TX_PWR_LEVEL_SERV_UUID )
};

// Alert Level Attribute UUID
开发者ID:Shakeebbk,项目名称:BLETICC2540,代码行数:31,代码来源:proxreporter.c


示例6: LO_UINT16

 * CONSTANTS
 */

#define SERVAPP_NUM_ATTR_SUPPORTED        18

/*********************************************************************
 * TYPEDEFS
 */

/*********************************************************************
 * GLOBAL VARIABLES
 */
// Simple GATT Profile Service UUID: 0xFFF0
CONST uint8 simpleProfileServUUID[ATT_BT_UUID_SIZE] =
{ 
  LO_UINT16(SIMPLEPROFILE_SERV_UUID), HI_UINT16(SIMPLEPROFILE_SERV_UUID)
};

// Characteristic 1 UUID: 0xFFF1
CONST uint8 simpleProfilechar1UUID[ATT_BT_UUID_SIZE] =
{ 
  LO_UINT16(SIMPLEPROFILE_CHAR1_UUID), HI_UINT16(SIMPLEPROFILE_CHAR1_UUID)
};

// Characteristic 2 UUID: 0xFFF2
CONST uint8 simpleProfilechar2UUID[ATT_BT_UUID_SIZE] =
{ 
  LO_UINT16(SIMPLEPROFILE_CHAR2_UUID), HI_UINT16(SIMPLEPROFILE_CHAR2_UUID)
};

// Characteristic 3 UUID: 0xFFF3
开发者ID:WayneTung,项目名称:TI-CC254x-BLE,代码行数:31,代码来源:simpleGATTprofile.c


示例7: glucoseCtlPntWriteFilter

uint8 glucoseCtlPntWriteFilter(uint8 opcode, uint8 oper, uint8 filterType,
                               void* param1, void* param2)
{
  attWriteReq_t writeReq;
  UTCTimeStruct *time1, *time2;
  uint16 *seqNum1, *seqNum2;
  
  uint8 *p = writeReq.value;
  
  *p++ = opcode;
  *p++ = oper;

  // The operator will tells us whether to include the filters or not
  // Note day and month are converted to date time struct values
  switch(oper)
  {
  case CTL_PNT_OPER_LESS_EQUAL:
  case CTL_PNT_OPER_GREATER_EQUAL:
    *p++ = filterType;
    if (filterType == CTL_PNT_FILTER_SEQNUM)
    {
      seqNum1 = param1;
      *p++ = LO_UINT16(*seqNum1);
      *p++ = HI_UINT16(*seqNum1);
    }
    else
    {
      time1 = param1;
      *p++ = LO_UINT16(time1->year);
      *p++ = HI_UINT16(time1->year);
      *p++ = (time1->month + 1);
      *p++ = (time1->day + 1);
      *p++ = time1->hour;
      *p++ = time1->minutes;
      *p++ = time1->seconds;
    }
    break;
  case CTL_PNT_OPER_RANGE:
    *p++ = filterType;
    if (filterType == CTL_PNT_FILTER_SEQNUM)
    {
      seqNum1 = param1;
      seqNum2 = param2;
      *p++ = LO_UINT16(*seqNum1);
      *p++ = HI_UINT16(*seqNum1);
      *p++ = LO_UINT16(*seqNum2);
      *p++ = HI_UINT16(*seqNum2);      
    }
    else
    {
      time1 = param1;
      time2 = param2;
      *p++ = LO_UINT16(time1->year);
      *p++ = HI_UINT16(time1->year);
      *p++ = (time1->month + 1);
      *p++ = (time1->day + 1);
      *p++ = time1->hour;
      *p++ = time1->minutes;
      *p++ = time1->seconds;
      
      *p++ = LO_UINT16(time2->year);
      *p++ = HI_UINT16(time2->year);
      *p++ = (time2->month + 1);
      *p++ = (time2->day + 1);
      *p++ = time2->hour;
      *p++ = time2->minutes;
      *p++ = time2->seconds;
    }
    break;
  default:
    break;
  }
  
  writeReq.len = (p - writeReq.value);
  writeReq.sig = 0;
  writeReq.cmd = 0;
  
  writeReq.handle = glucoseHdlCache[HDL_GLUCOSE_CTL_PNT_START];
  return GATT_WriteCharValue( glucCollConnHandle, &writeReq, glucCollTaskId );
}
开发者ID:Mecabot,项目名称:BLE-CC254x-1.4.0,代码行数:80,代码来源:glucose_ctlpnt.c


示例8: LO_UINT16

    'm',
    'e',
    't',
    'e',
    'r',
    'S',
    'e',
    'n',
    's',
    'o',
    'r',
    // connection interval range
    0x05,   // length of this data
    GAP_ADTYPE_SLAVE_CONN_INTERVAL_RANGE,
    LO_UINT16( DEFAULT_DESIRED_MIN_CONN_INTERVAL ),   // 100ms
    HI_UINT16( DEFAULT_DESIRED_MIN_CONN_INTERVAL ),
    LO_UINT16( DEFAULT_DESIRED_MAX_CONN_INTERVAL ),   // 1s
    HI_UINT16( DEFAULT_DESIRED_MAX_CONN_INTERVAL ),

    // Tx power level
    GAP_ADTYPE_POWER_LEVEL,
    0       // 0dBm
};

// Advertisement data
static uint8 advertData[] =
{
    // Flags; this sets the device to use limited discoverable
    // mode (advertises for 30 seconds at a time) instead of general
    // discoverable mode (advertises indefinitely)
    0x02,   // length of this data
开发者ID:venkatarajasekhar,项目名称:CC2540,代码行数:31,代码来源:thermometer.c


示例9: LO_UINT16

/*********************************************************************
 * CONSTANTS
 */

/*********************************************************************
 * TYPEDEFS
 */

/*********************************************************************
 * GLOBAL VARIABLES
 */
// Lights GATT Profile Service UUID: 0xFFB0
CONST uint8 lightsProfileServUUID[ATT_BT_UUID_SIZE] =
{ 
  LO_UINT16(LIGHTSPROFILE_SERV_UUID), HI_UINT16(LIGHTSPROFILE_SERV_UUID)
};

// Characteristic Red UUID: 0xFFB1
CONST uint8 lightsProfileRedUUID[ATT_BT_UUID_SIZE] =
{ 
  LO_UINT16(LIGHTSPROFILE_RED_UUID), HI_UINT16(LIGHTSPROFILE_RED_UUID)
};

// Characteristic Green UUID: 0xFFB2
CONST uint8 lightsProfileGreenUUID[ATT_BT_UUID_SIZE] =
{ 
  LO_UINT16(LIGHTSPROFILE_GREEN_UUID), HI_UINT16(LIGHTSPROFILE_GREEN_UUID)
};

// Characteristic Blue UUID: 0xFFB3
开发者ID:PolymorphicLabs,项目名称:PML-Firmware,代码行数:30,代码来源:lightservice.c


示例10: thermometer_HandleKeys

/*********************************************************************
 * @fn      thermometer_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 thermometer_HandleKeys( uint8 shift, uint8 keys )
{

    bStatus_t status;
    uint8 notify_interval;

    if ( keys & HAL_KEY_SW_1 )
    {
        // set simulated measurement flag index
        thermometerFlagsIdx+=1;

        if (thermometerFlagsIdx == FLAGS_IDX_MAX)
        {
            thermometerFlagsIdx = 0;
        }
    }


    //read stored interval value
    Thermometer_GetParameter( THERMOMETER_INTERVAL, &notify_interval );

    if(notify_interval == 0)
    {
        thMeasTimerRunning = FALSE;
    }

    if ( keys & HAL_KEY_SW_2 )
    {
        // if device is not in a connection, pressing the right key should toggle
        // advertising on and off. If timer is running, then will adv when meas is ready
        if((gapProfileState != GAPROLE_CONNECTED) &&  (thMeasTimerRunning == FALSE))
        {
            uint8 current_adv_enabled_status;
            uint8 new_adv_enabled_status;

            //Find the current GAP advertisement status
            GAPRole_GetParameter( GAPROLE_ADVERT_ENABLED, &current_adv_enabled_status );

            if ( current_adv_enabled_status == FALSE )
            {
                new_adv_enabled_status = TRUE;
            }
            else
            {
                new_adv_enabled_status = FALSE;
            }

            //change the GAP advertisement status to opposite of current status
            GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &new_adv_enabled_status );
        }
        else //timer is running, so allow simulated changes
        {
            //change temperature, remove single precision
            if((thermometerCelcius) < 0X000175)
            {
                thermometerCelcius +=1;
            }
            else
            {
                uint16 thInterval = 30;

                thermometerCelcius = 0X000173;

                //Simulate interval change
                Thermometer_SetParameter( THERMOMETER_INTERVAL, THERMOMETER_INTERVAL_LEN,
                                          &thInterval );
                if(temperatureIntervalConfig == true)
                {
                    attHandleValueInd_t intervalInd;

                    intervalInd.pValue = GATT_bm_alloc( gapConnHandle, ATT_HANDLE_VALUE_IND,
                                                        THERMOMETER_INTERVAL_LEN, NULL );
                    if ( intervalInd.pValue != NULL )
                    {
                        intervalInd.len = THERMOMETER_INTERVAL_LEN;
                        intervalInd.pValue[0] = LO_UINT16(thInterval);
                        intervalInd.pValue[1] = HI_UINT16(thInterval);
                        intervalInd.handle = THERMOMETER_INTERVAL_VALUE_POS;

                        status = Thermometer_IntervalIndicate( gapConnHandle, &intervalInd,
                                                               thermometerTaskId );
                        // we can fail if there was pending meas or not connected
                        if (status != SUCCESS)
                        {
                            //queue indication
                            thermometerStoreIndications(&intervalInd);
                        }
                    }
//.........这里部分代码省略.........
开发者ID:killets,项目名称:ThermometerBLE,代码行数:101,代码来源:thermometer.c


示例11: thermometerMeasIndicate

/*********************************************************************
 * @fn      thermometerMeasIndicate
 *
 * @brief   Prepare and send a thermometer measurement indication
 *
 * @return  none
 */
static void thermometerMeasIndicate(void)
{
    // Thermometer measurement value stored in this structure.
    attHandleValueInd_t thermometerMeas;

    thermometerMeas.pValue = GATT_bm_alloc(gapConnHandle,
                                           ATT_HANDLE_VALUE_IND,
                                           THERMOMETER_MEAS_LEN, NULL);
    if (thermometerMeas.pValue != NULL)
    {
        // att value notification structure
        uint8 *p = thermometerMeas.pValue;

        // temperature
        uint32 temperature;

        //flags
        uint8 flags = thermometerFlags[thermometerFlagsIdx];

        // flags 1 byte long
        *p++ = flags;

        if(flags & THERMOMETER_FLAGS_FARENHEIT)
        {
            temperature =  (thermometerCelcius *9/5) +320;
        }
        else
        {
            temperature = thermometerCelcius;
        }

        temperature = 0xFF000000 | temperature;

        //osal_buffer_uint32
        p = osal_buffer_uint32( p, temperature );

        //timestamp
        if (flags & THERMOMETER_FLAGS_TIMESTAMP)
        {
            UTCTimeStruct time;

            // Get time structure from OSAL
            osal_ConvertUTCTime( &time, osal_getClock() );

            *p++ = LO_UINT16(time.year);
            *p++ = HI_UINT16(time.year);
            *p++ = time.month;
            *p++ = time.day;
            *p++ = time.hour;
            *p++ = time.minutes;
            *p++ = time.seconds;
        }

        if(flags & THERMOMETER_FLAGS_TYPE)
        {
            uint8 site;
            Thermometer_GetParameter( THERMOMETER_TYPE, &site );
            *p++ =  site;
        }

        thermometerMeas.len = (uint8) (p - thermometerMeas.pValue);
        thermometerMeas.handle = THERMOMETER_TEMP_VALUE_POS;

        // Queue indication.
        thermometerStoreIndications( &thermometerMeas);

        //advertise measurement is ready
        thermometer_Advertise();
    }
}
开发者ID:killets,项目名称:ThermometerBLE,代码行数:77,代码来源:thermometer.c


示例12: thermometerImeasNotify

/*********************************************************************
 * @fn      thermometerMeasNotify
 *
 * @brief   Prepare and send a thermometer measurement notification
 *
 * @return  none
 */
static void thermometerImeasNotify(void)
{
    if (temperatureIMeasCharConfig == true)
    {
        attHandleValueNoti_t thermometerIMeas;

        thermometerIMeas.pValue = GATT_bm_alloc( gapConnHandle,
                                  ATT_HANDLE_VALUE_NOTI,
                                  THERMOMETER_IMEAS_LEN, NULL );
        if ( thermometerIMeas.pValue != NULL )
        {
            // att value notification structure
            uint8 *p = thermometerIMeas.pValue;

            // temperature
            uint32 temperature;

            //flags
            uint8 flags = thermometerFlags[thermometerFlagsIdx];

            // flags 1 byte long
            *p++ = flags;

            if(flags & THERMOMETER_FLAGS_FARENHEIT)
            {
                temperature =  (thermometerCelcius *9/5) +320;
            }
            else
            {
                temperature = thermometerCelcius;
            }

            temperature = 0xFF000000 | temperature;

            //osal_buffer_uint32
            p = osal_buffer_uint32( p, temperature );

            //timestamp
            if (flags & THERMOMETER_FLAGS_TIMESTAMP)
            {
                UTCTimeStruct time;

                // Get time structure from OSAL
                osal_ConvertUTCTime( &time, osal_getClock() );

                *p++ = LO_UINT16(time.year);
                *p++ = HI_UINT16(time.year);
                *p++ = time.month;
                *p++ = time.day;
                *p++ = time.hour;
                *p++ = time.minutes;
                *p++ = time.seconds;
            }

            if(flags & THERMOMETER_FLAGS_TYPE)
            {
                uint8 site;
                Thermometer_GetParameter( THERMOMETER_TYPE, &site );
                *p++ =  site;
            }

            thermometerIMeas.len = (uint8) (p - thermometerIMeas.pValue);

            if ( Thermometer_IMeasNotify( gapConnHandle, &thermometerIMeas) != SUCCESS )
            {
                GATT_bm_free( (gattMsg_t *)&thermometerIMeas, ATT_HANDLE_VALUE_NOTI );
            }
        }
    }
}
开发者ID:killets,项目名称:ThermometerBLE,代码行数:77,代码来源:thermometer.c


示例13: LO_UINT16

  's',
  'u',
  'r',
  'e',
  ' ',
  'S',
  'e',
  'n',
  's',
  'o',
  'r',  
    // connection interval range
  0x05,   // length of this data
  GAP_ADTYPE_SLAVE_CONN_INTERVAL_RANGE,
  LO_UINT16( DEFAULT_DESIRED_MIN_CONN_INTERVAL ),   // 100ms
  HI_UINT16( DEFAULT_DESIRED_MIN_CONN_INTERVAL ),  
  LO_UINT16( DEFAULT_DESIRED_MAX_CONN_INTERVAL ),   // 1s
  HI_UINT16( DEFAULT_DESIRED_MAX_CONN_INTERVAL ),  
  0x02,   // length of this data
  GAP_ADTYPE_POWER_LEVEL, //TX Power Level
  0       // 0dBm  
};

// Advertisement data
static uint8 advertData[] = 
{ 
  // Flags; this sets the device to use limited discoverable
  // mode (advertises for 30 seconds at a time) instead of general
  // discoverable mode (advertises indefinitely)
  0x02,   // length of this data
  GAP_ADTYPE_FLAGS,
开发者ID:HorseMa,项目名称:BLE-CC254x-1.4.0,代码行数:31,代码来源:bloodPressure.c


示例14: LO_UINT16

/*********************************************************************
 * CONSTANTS
 */

/*********************************************************************
 * TYPEDEFS
 */

/*********************************************************************
 * GLOBAL VARIABLES
 */
// Device information service
CONST uint8 devInfoServUUID[ATT_BT_UUID_SIZE] =
{
  LO_UINT16(DEVINFO_SERV_UUID), HI_UINT16(DEVINFO_SERV_UUID)
};

// System ID
CONST uint8 devInfoSystemIdUUID[ATT_BT_UUID_SIZE] =
{
  LO_UINT16(SYSTEM_ID_UUID), HI_UINT16(SYSTEM_ID_UUID)
};

// Model Number String
CONST uint8 devInfoModelNumberUUID[ATT_BT_UUID_SIZE] =
{
  LO_UINT16(MODEL_NUMBER_UUID), HI_UINT16(MODEL_NUMBER_UUID)
};

// Serial Number String
开发者ID:ClarePhang,项目名称:BLE_cc2650,代码行数:30,代码来源:devinfoservice.c


示例15: LO_UINT16

  's',
  'o',
  'r',
};

static uint8 advertData[] =
{
  // flags
  0x02,
  GAP_ADTYPE_FLAGS,
  GAP_ADTYPE_FLAGS_GENERAL | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,
  // service UUIDs
  0x03,
  GAP_ADTYPE_16BIT_MORE,
  LO_UINT16(RSC_SERV_UUID),
  HI_UINT16(RSC_SERV_UUID),
};

// Device name attribute value
static uint8 attDeviceName[GAP_DEVICE_NAME_LEN] = "RSC Sensor";

// GAP connection handle
static uint16 gapConnHandle;

// Running measurement value stored in this structure
static attHandleValueNoti_t sensorMeas;

// Flags for simulated measurements
static const uint8 sensorFlags[FLAGS_IDX_MAX] =
{
  RSC_FLAGS_ALL,
开发者ID:HorseMa,项目名称:BLE-CC254x-1.4.0,代码行数:31,代码来源:runningSensor.c


示例16: 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


示例17: sensorMeasNotify

/*********************************************************************
 * @fn      sensorMeasNotify
 *
 * @brief   Prepare and send a RSC measurement notification
 *
 * @return  none
 */
static void sensorMeasNotify(void)
{
  static uint16 centimeters = 0;
  uint8 *p = sensorMeas.value;
  uint8 flags = sensorFlags[sensorFlagsIdx];

  switch( motion )
  {
    case STANDING_STILL:
      instSpeed = instCadence = instStrideLength =  STANDING_STILL;
      // 0 for walking bit
      flags = flags & 0xFB; //0b1111 1011
      break;

    case WALKING_MOTION:
      instStrideLength = STRIDE_LENGTH_WALKING;
      instCadence = WALKING_CADENCE;
      instSpeed = WALKING_SPEED;
      // 0 for walking bit
      flags = flags & 0xFB;
      break;

    case RUNNING_MOTION:
      instStrideLength = STRIDE_LENGTH_RUNNING;
      instCadence = RUNNING_CADENCE;
      instSpeed = RUNNING_SPEED;
      // set in 1 for walking bit.
      flags = flags | 0x04;
      break;

    default: // Do nothing
      break;
  }

  // Add distance
  centimeters += (uint16)DISTANCE_TRAVELED( instSpeed );

  // If traveled at least a meter
  if ( centimeters >= 100 )
  {
    // add distance, truncated to meters
    totalDistance += (centimeters / 100);
    // and continue to store the remaining centimeters
    centimeters %= 100;
  }

  // Build RSC measurement structure from simulated values
  // Flags simulate the isPresent bits.
  *p++ = flags;

  //Included regardless of flags.
  *p++ = LO_UINT16( instSpeed );
  *p++ = HI_UINT16( instSpeed );
  *p++ = instCadence;

  if (flags & RSC_FLAGS_STRIDE)
  {
    *p++ = LO_UINT16( instStrideLength );
    *p++ = HI_UINT16( instStrideLength );
  }

  if (flags & RSC_FLAGS_DIST)
  {
    *p++ = BREAK_UINT32(totalDistance, 0);
    *p++ = BREAK_UINT32(totalDistance, 1);
    *p++ = BREAK_UINT32(totalDistance, 2);
    *p++ = BREAK_UINT32(totalDistance, 3);
  }

  // Get length
  sensorMeas.len = (uint8) (p - sensorMeas.value);

  // Send to service to send the notification
  Running_MeasNotify( gapConnHandle, &sensorMeas );
}
开发者ID:HorseMa,项目名称:BLE-CC254x-1.4.0,代码行数:82,代码来源:runningSensor.c


示例18: LO_UINT16

/*********************************************************************
 * TYPEDEFS
 */

/*********************************************************************
 * GLOBAL VARIABLES
 */

/**
 * GATT Service
 */

// Immediate Alert Service UUID: 0xFF10
CONST uint8 imAlertServUUID[ATT_BT_UUID_SIZE] =
{ 
  LO_UINT16(IM_ALERT_SERV_UUID), HI_UINT16(IM_ALERT_SERV_UUID)
};

/**
 * GATT Characteristic Types
 */

// Alert Level UUID: 0xFF11
CONST uint8 imAlertLevelUUID[ATT_BT_UUID_SIZE] =
{ 
  LO_UINT16(IM_ALERT_LEVEL_UUID), HI_UINT16(IM_ALERT_LEVEL_UUID)
};

/*********************************************************************
 * GLOBAL FUNCTIONS
 */
开发者ID:victor-zheng,项目名称:BLE,代码行数:31,代码来源:imAlert_uuid.c


示例19: LO_UINT16

  0x50,   // 'P'
  0x65,   // 'e'
  0x72,   // 'r'
  0x69,   // 'i'
  0x70,   // 'p'
  0x68,   // 'h'
  0x65,   // 'e'
  0x72,   // 'r'
  0x61,   // 'a'
  0x6c,   // 'l'

  // connection interval range
  0x05,   // length of this data
  GAP_ADTYPE_SLAVE_CONN_INTERVAL_RANGE,
  LO_UINT16( DEFAULT_DESIRED_MIN_CONN_INTERVAL ),   // 100ms
  HI_UINT16( DEFAULT_DESIRED_MIN_CONN_INTERVAL ),
  LO_UINT16( DEFAULT_DESIRED_MAX_CONN_INTERVAL ),   // 1s
  HI_UINT16( DEFAULT_DESIRED_MAX_CONN_INTERVAL ),

  // Tx power level
  0x02,   // length of this data
  GAP_ADTYPE_POWER_LEVEL,
  0       // 0dBm
};

// GAP - Advertisement data (max size = 31 bytes, though this is
// best kept short to conserve power while advertisting)
static uint8 advertData[] =
{
  // Flags; this sets the device to use limited discoverable
  // mode (advertises for 30 seconds at a time) instead of general
开发者ID:HoobeeTechnology,项目名称:Hoobee,代码行数:31,代码来源:simpleBLEPeripheral.c


示例20: LO_UINT16

  NULL                       // Authorization callback function pointer
};









// reverse uuid

CONST uint8 BXServUUID[ATT_BT_UUID_SIZE] =
{ 
  LO_UINT16(BX_SERV_UUID), HI_UINT16(BX_SERV_UUID)
};


CONST uint8 BXchar1UUID[ATT_BT_UUID_SIZE] =
{ 
  LO_UINT16(BX_CHAR1_UUID), HI_UINT16(BX_CHAR1_UUID)
};

CONST uint8 BXchar2UUID[ATT_BT_UUID_SIZE] =
{ 
  LO_UINT16(BX_CHAR2_UUID), HI_UINT16(BX_CHAR2_UUID)
};


开发者ID:backman-git,项目名称:EcoSim-sample-project,代码行数:28,代码来源:BXprof.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ HK函数代码示例发布时间:2022-05-30
下一篇:
C++ HIWORD函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap