本文整理汇总了C++中HI_UINT16函数的典型用法代码示例。如果您正苦于以下问题:C++ HI_UINT16函数的具体用法?C++ HI_UINT16怎么用?C++ HI_UINT16使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HI_UINT16函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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, ¤tConnectHandle);
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, ¶m[2]);
//reset the GATT state for this connection handle
SNP_resetGATT(*((uint16_t*) ¶m[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, ¤tConnectHandle);
{
uint8_t param[15];
GAPRole_GetParameter(GAPROLE_CONNHANDLE, ¶m[0]);
GAPRole_GetParameter(GAPROLE_CONN_INTERVAL, ¶m[2]);
GAPRole_GetParameter(GAPROLE_CONN_LATENCY, ¶m[4]);
GAPRole_GetParameter(GAPROLE_CONN_TIMEOUT, ¶m[6]);
GAPRole_GetParameter(GAPROLE_BD_ADDR_TYPE, ¶m[8]);
memcpy(¶m[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, ¶m[2]);
//reset the GATT state for this connection handle
SNP_resetGATT(*((uint16_t*)¶m[0]));
//Connection Ended
SNP_eventToHost_send(SNP_CONN_TERM_EVT, NULL, sizeof(param), param);
//.........这里部分代码省略.........
示例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;
}
示例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;
//.........这里部分代码省略.........
示例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;
}
//.........这里部分代码省略.........
示例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
示例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
示例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 );
}
示例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
示例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
示例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, ¬ify_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, ¤t_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);
}
}
//.........这里部分代码省略.........
示例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();
}
}
示例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 );
}
}
}
}
示例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,
示例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
示例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,