本文整理汇总了C++中GAP_SetParamValue函数的典型用法代码示例。如果您正苦于以下问题:C++ GAP_SetParamValue函数的具体用法?C++ GAP_SetParamValue怎么用?C++ GAP_SetParamValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GAP_SetParamValue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OADManager_Init
/*********************************************************************
* @fn OADManager_Init
*
* @brief Initialization function for the OAD Manager App Task.
* This is called during initialization and should contain
* any application specific initialization (ie. hardware
* initialization/setup, table initialization, power up
* notification).
*
* @param task_id - the ID assigned by OSAL. This ID should be
* used to send messages and set timers.
*
* @return none
*/
void OADManager_Init( uint8 task_id )
{
oadManagerTaskId = task_id;
// Setup Central Profile
{
uint8 scanRes = DEFAULT_MAX_SCAN_RES;
GAPCentralRole_SetParameter ( GAPCENTRALROLE_MAX_SCAN_RES, sizeof( uint8 ), &scanRes );
}
// Setup GAP
GAP_SetParamValue( TGAP_GEN_DISC_SCAN, DEFAULT_SCAN_DURATION );
GAP_SetParamValue( TGAP_LIM_DISC_SCAN, DEFAULT_SCAN_DURATION );
GAP_SetParamValue( TGAP_REJECT_CONN_PARAMS, DEFAULT_OAD_REJECT_CONN_PARAMS );
GGS_SetParameter( GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, (uint8 *) oadManagerDeviceName );
// Initialize GATT Client
VOID GATT_InitClient();
// Register to receive incoming ATT Indications/Notifications
GATT_RegisterForInd( task_id );
#if (defined HAL_KEY) && (HAL_KEY == TRUE)
// Register for all key events - This app will handle all key events
RegisterForKeys( task_id );
#endif
#if (defined HAL_LED) && (HAL_LED == TRUE)
HalLedSet( (HAL_LED_1 | HAL_LED_2), HAL_LED_MODE_OFF );
#endif
// Setup a delayed profile startup
osal_set_event( task_id, START_DEVICE_EVT );
}
示例2: HeartRate_handleKeys
/*********************************************************************
* @fn HeartRate_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 HeartRate_handleKeys(uint8_t shift, uint8_t keys)
{
// Up key.
if (keys & KEY_UP)
{
// Set simulated measurement flag index.
if (++flagsIdx == HEARTRATE_FLAGS_IDX_MAX)
{
flagsIdx = 0;
}
}
// Left key.
if (keys & KEY_LEFT)
{
// If not in a connection, toggle advertising on and off.
if(gapProfileState != GAPROLE_CONNECTED)
{
// 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_FAST_ADV_DURATION);
// Toggle GAP advertisement status.
// Set flag if advertising was cancelled.
if (HeartRate_toggleAdvertising() == FALSE)
{
advCancelled = TRUE;
}
}
}
}
示例3: simpleTopology_init
/*********************************************************************
* @fn simpleTopology_init
*
* @brief Called during initialization and contains application
* specific initialization (ie. hardware initialization/setup,
* table initialization, power up notification, etc), and
* profile initialization/setup.
*
* @param None.
*
* @return None.
*/
static void simpleTopology_init(void)
{
// ******************************************************************
// N0 STACK API CALLS CAN OCCUR BEFORE THIS CALL TO ICall_registerApp
// ******************************************************************
// Register the current thread as an ICall dispatcher application
// so that the application can send and receive messages.
ICall_registerApp(&selfEntity, &sem);
// Create an RTOS queue for message from profile to be sent to app.
appMsgQueue = Util_constructQueue(&appMsg);
Util_constructClock(&scanClock, SensorTagMultiRoleTest_scanStartHandler,
SCAN_EVENT_PERIOD, SCAN_EVENT_PERIOD, TRUE, SCAN_EVENT);
// Setup the GAP
{
/*-------------------PERIPHERAL-------------------*/
uint16_t advInt = DEFAULT_ADVERTISING_INTERVAL;
GAP_SetParamValue(TGAP_LIM_DISC_ADV_INT_MIN, advInt);
GAP_SetParamValue(TGAP_LIM_DISC_ADV_INT_MAX, advInt);
GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MIN, advInt);
GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MAX, advInt);
GAP_SetParamValue(TGAP_LIM_ADV_TIMEOUT, ADV_DURATION);
/*-------------------CENTRAL-------------------*/
GAP_SetParamValue(TGAP_GEN_DISC_SCAN, DEFAULT_SCAN_DURATION);
GAP_SetParamValue(TGAP_GEN_DISC_SCAN_INT, DEFAULT_SCAN_INT);
GAP_SetParamValue(TGAP_GEN_DISC_SCAN_WIND, DEFAULT_SCAN_WIND);
GAP_SetParamValue(TGAP_LIM_DISC_SCAN_INT, DEFAULT_SCAN_INT);
GAP_SetParamValue(TGAP_LIM_DISC_SCAN_WIND, DEFAULT_SCAN_WIND);
}
// Setup the GAP Role Profile
{
/*--------PERIPHERAL-------------*/
// For all hardware platforms, device starts advertising upon initialization
uint8_t initialAdvertEnable = FALSE;
// By setting this to zero, the device will go into the waiting state after
// being discoverable for 30.72 second, and will not being advertising again
// until the enabler is set back to TRUE
uint16_t advertOffTime = 0;
GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t),
&initialAdvertEnable, NULL);
GAPRole_SetParameter(GAPROLE_ADVERT_OFF_TIME, sizeof(uint16_t),
&advertOffTime, NULL);
GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advertData), advertData, NULL);
// Register with GAP for HCI/Host messages
GAP_RegisterForMsgs(selfEntity);
}
VOID GAPRole_StartDevice(&simpleTopology_gapRoleCBs);
}
示例4: SimpleBLECentral_Init
/*********************************************************************
* @fn SimpleBLECentral_Init
*
* @brief Initialization function for the Simple BLE Central App Task.
* This is called during initialization and should contain
* any application specific initialization (ie. hardware
* initialization/setup, table initialization, power up
* notification).
*
* @param task_id - the ID assigned by OSAL. This ID should be
* used to send messages and set timers.
*
* @return none
*/
void SimpleBLECentral_Init( uint8 task_id )
{
simpleBLETaskId = task_id;
// 串口初始化
NPI_InitTransport(uart_NpiSerialCallback);
//NPI_WriteTransport("SimpleBLECentral_Init\r\n", 23);
Get_IMEI();
//halSleep(100);
//Get_Test();
// Setup Central Profile
{
uint8 scanRes = DEFAULT_MAX_SCAN_RES;
GAPCentralRole_SetParameter ( GAPCENTRALROLE_MAX_SCAN_RES, sizeof( uint8 ), &scanRes );
}
// Setup GAP
GAP_SetParamValue( TGAP_GEN_DISC_SCAN, DEFAULT_SCAN_DURATION );
GAP_SetParamValue( TGAP_LIM_DISC_SCAN, DEFAULT_SCAN_DURATION );
GGS_SetParameter( GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, (uint8 *) simpleBLEDeviceName );
// Setup the GAP Bond Manager
{
uint32 passkey = DEFAULT_PASSCODE;
uint8 pairMode = DEFAULT_PAIRING_MODE;
uint8 mitm = DEFAULT_MITM_MODE;
uint8 ioCap = DEFAULT_IO_CAPABILITIES;
uint8 bonding = DEFAULT_BONDING_MODE;
GAPBondMgr_SetParameter( GAPBOND_DEFAULT_PASSCODE, sizeof( uint32 ), &passkey );
GAPBondMgr_SetParameter( GAPBOND_PAIRING_MODE, sizeof( uint8 ), &pairMode );
GAPBondMgr_SetParameter( GAPBOND_MITM_PROTECTION, sizeof( uint8 ), &mitm );
GAPBondMgr_SetParameter( GAPBOND_IO_CAPABILITIES, sizeof( uint8 ), &ioCap );
GAPBondMgr_SetParameter( GAPBOND_BONDING_ENABLED, sizeof( uint8 ), &bonding );
}
// Initialize GATT Client
VOID GATT_InitClient();
// Register to receive incoming ATT Indications/Notifications
GATT_RegisterForInd( simpleBLETaskId );
// Initialize GATT attributes
GGS_AddService( GATT_ALL_SERVICES ); // GAP
GATTServApp_AddService( GATT_ALL_SERVICES ); // GATT attributes
// Register for all key events - This app will handle all key events
RegisterForKeys( simpleBLETaskId );
// makes sure LEDs are off
HalLedSet( (HAL_LED_1 | HAL_LED_2), HAL_LED_MODE_OFF );
// Setup a delayed profile startup
osal_set_event( simpleBLETaskId, START_DEVICE_EVT );
}
示例5: hidDevInitialAdvertising
/*********************************************************************
* @fn hidDevInitialAdvertising
*
* @brief Start advertising for initial connection
*
* @return None.
*/
static void hidDevInitialAdvertising( void )
{
uint8 param;
VOID GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MIN, HID_INITIAL_ADV_INT_MIN );
VOID GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MAX, HID_INITIAL_ADV_INT_MAX );
VOID GAP_SetParamValue( TGAP_LIM_ADV_TIMEOUT, HID_INITIAL_ADV_TIMEOUT );
// Setup adverstising filter policy first
param = GAP_FILTER_POLICY_ALL;
VOID GAPRole_SetParameter( GAPROLE_ADV_FILTER_POLICY, sizeof( uint8 ), ¶m );
param = TRUE;
VOID GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), ¶m );
}
示例6: heartRate_HandleKeys
/*********************************************************************
* @fn heartRate_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 heartRate_HandleKeys( uint8 shift, uint8 keys )
{
if ( keys & HAL_KEY_SW_1 )
{
// set simulated measurement flag index
if (++heartRateFlagsIdx == FLAGS_IDX_MAX)
{
heartRateFlagsIdx = 0;
}
}
if ( keys & HAL_KEY_SW_2 )
{
// 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_FAST_ADV_DURATION );
// toggle GAP advertisement status
GAPRole_GetParameter( GAPROLE_ADVERT_ENABLED, &status );
status = !status;
GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &status );
// Set state variable
if (status == FALSE)
{
heartRateAdvCancelled = TRUE;
}
}
// if in a connection toggle some the battery state bits for test purposes
else
{
uint8 state;
Batt_GetParameter( BATT_PARAM_STATE, &state );
state ^= BATT_FLAGS_CR_CRIT;
Batt_SetParameter( BATT_PARAM_STATE, sizeof( uint8 ), &state );
}
}
}
示例7: Application_StartAdvertise
uint8 Application_StartAdvertise(uint16 duration, uint16 interval)
{
if( gapProfileState != GAPROLE_CONNECTED )
{
uint8 astatus;
// toggle GAP advertisement status
GAPRole_GetParameter( GAPROLE_ADVERT_ENABLED, &astatus );
if (astatus == FALSE)
{
//Set fast advertising interval for user-initiated connections
GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MIN, interval );
GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MAX, interval );
GAP_SetParamValue( TGAP_LIM_ADV_TIMEOUT, duration );
astatus = TRUE;
GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &astatus );
return SUCCESS;
}
}
return FAILURE;
}
示例8: BlueBasic_Init
/*********************************************************************
* @fn BlueBasic_Init
*
* @brief Initialization function for the Blue Basic App Task.
* This is called during initialization and should contain
* any application specific initialization (ie. hardware
* initialization/setup, table initialization, power up
* notificaiton ... ).
*
* @param task_id - the ID assigned by OSAL. This ID should be
* used to send messages and set timers.
*
* @return none
*/
void BlueBasic_Init( uint8 task_id )
{
blueBasic_TaskID = task_id;
#ifdef ENABLE_BLE_CONSOLE
GAPRole_SetParameter( GAPROLE_ADVERT_DATA, 0, sizeof(consoleAdvert), (void*)consoleAdvert );
#endif
// Set advertising interval
GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MIN, DEFAULT_ADVERTISING_INTERVAL );
GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MAX, DEFAULT_ADVERTISING_INTERVAL );
GAP_SetParamValue( TGAP_GEN_DISC_ADV_INT_MIN, DEFAULT_ADVERTISING_INTERVAL );
GAP_SetParamValue( TGAP_GEN_DISC_ADV_INT_MAX, DEFAULT_ADVERTISING_INTERVAL );
// Initialize GATT attributes
GGS_AddService( GATT_ALL_SERVICES ); // GAP
GATTServApp_AddService( GATT_ALL_SERVICES ); // GATT attributes
#ifdef ENABLE_FAKE_OAD_PROFILE
GATTServApp_RegisterService(oadProfile, GATT_NUM_ATTRS(oadProfile), NULL);
#endif
DevInfo_AddService(); // Device Information Service
#if defined FEATURE_OAD
VOID OADTarget_AddService(); // OAD Profile
#endif
// Enable clock divide on halt
// This reduces active current while radio is active and CC254x MCU
// is halted
#ifdef ENABLE_BLE_CONSOLE
// See: http://e2e.ti.com/support/wireless_connectivity/f/538/p/169944/668822.aspx#664740
HCI_EXT_ClkDivOnHaltCmd(HCI_EXT_ENABLE_CLK_DIVIDE_ON_HALT);
#endif
// Overlap enabled
HCI_EXT_OverlappedProcessingCmd(HCI_EXT_ENABLE_OVERLAPPED_PROCESSING);
// Setup a delayed profile startup
osal_set_event( blueBasic_TaskID, BLUEBASIC_START_DEVICE_EVT );
}
示例9: SimpleBLEObserver_Init
/*********************************************************************
* @fn SimpleBLEObserver_Init
*
* @brief Initialization function for the Simple BLE Observer App Task.
* This is called during initialization and should contain
* any application specific initialization (ie. hardware
* initialization/setup, table initialization, power up
* notification).
*
* @param task_id - the ID assigned by OSAL. This ID should be
* used to send messages and set timers.
*
* @return none
*/
void SimpleBLEObserver_Init( uint8 task_id )
{
simpleBLETaskId = task_id;
// Setup Observer Profile
{
uint8 scanRes = DEFAULT_MAX_SCAN_RES;
GAPObserverRole_SetParameter ( GAPOBSERVERROLE_MAX_SCAN_RES, sizeof( uint8 ), &scanRes );
}
// Setup GAP
GAP_SetParamValue( TGAP_GEN_DISC_SCAN, DEFAULT_SCAN_DURATION );
GAP_SetParamValue( TGAP_LIM_DISC_SCAN, DEFAULT_SCAN_DURATION );
// Register for all key events - This app will handle all key events
RegisterForKeys( simpleBLETaskId );
// makes sure LEDs are off
HalLedSet( (HAL_LED_1 | HAL_LED_2), HAL_LED_MODE_OFF );
// Setup a delayed profile startup
osal_set_event( simpleBLETaskId, START_DEVICE_EVT );
}
示例10: SwitchCentral_Init
void SwitchCentral_Init( void ){
uint8 scanRes = MAX_SCAN_RES;
GAPCentralRole_SetParameter ( GAPCENTRALROLE_MAX_SCAN_RES, sizeof( uint8 ), &scanRes );
GAP_SetParamValue( TGAP_GEN_DISC_SCAN, SCAN_DURATION );
GAP_SetParamValue( TGAP_LIM_DISC_SCAN, SCAN_DURATION );
//static varibles initiation
send_record=0;
HandleRangeStart = 0;
HandleRangeEnd = 0;
simpleBLEScanRes=0;
// for(uint8 i=0; i<MAX_SCAN_RES; ++i)
// osal_memcpy( simpleBLEDevList[i].addr, 0, B_ADDR_LEN );
}
示例11: SNP_setGapParam
/**
* SNP_setGapParam
*
*/
uint8_t SNP_setGapParam(snpSetGapParamReq_t *pReq)
{
uint8_t status;
if((pReq->paramId != TGAP_AUTH_TASK_ID) &&
(pReq->paramId < TGAP_PARAMID_MAX))
{
status = GAP_SetParamValue(pReq->paramId, pReq->value);
}
else
{
status = SNP_INVALID_PARAMS;
}
return status;
}
示例12: GAPBondMgr_Init
/*********************************************************************
* @brief Task Initialization function.
*
* Internal function defined in gapperiphbondmgr.h.
*/
void GAPBondMgr_Init( uint8 task_id )
{
gapBondRec_t bondRec; // Work space for Bond Record
gapBondMgr_TaskID = task_id; // Save task ID
// Initialize the NV needed for bonding
if ( osal_snv_read( mainRecordNvID(0), sizeof ( gapBondRec_t ), &bondRec ) != SUCCESS )
{
// Can't read the first entry, assume that NV doesn't exist and erase all
// Bond NV entries (initialize)
VOID gapBondMgrEraseAllBondings();
}
// Take over the processing of Authentication messages
VOID GAP_SetParamValue( TGAP_AUTH_TASK_ID, gapBondMgr_TaskID );
// Check the total number of bonds
gapBondSetupPrivFlag();
}
示例13: GAPRole_SetParameter
//.........这里部分代码省略.........
if ( (gapRole_RSSIReadRate) && (gapRole_state == GAPROLE_CONNECTED) )
{
// Start the RSSI Reads
VOID osal_start_timerEx( gapRole_TaskID, RSSI_READ_EVT, gapRole_RSSIReadRate );
}
}
else
{
ret = bleInvalidRange;
}
break;
case GAPROLE_PARAM_UPDATE_ENABLE:
if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= TRUE) )
{
gapRole_ParamUpdateEnable = *((uint8*)pValue);
}
else
{
ret = bleInvalidRange;
}
break;
case GAPROLE_MIN_CONN_INTERVAL:
{
uint16 newInterval = *((uint16*)pValue);
if ( len == sizeof ( uint16 ) &&
( newInterval >= MIN_CONN_INTERVAL ) &&
( newInterval <= MAX_CONN_INTERVAL ) )
{
gapRole_MinConnInterval = newInterval;
}
else
{
ret = bleInvalidRange;
}
}
break;
case GAPROLE_MAX_CONN_INTERVAL:
{
uint16 newInterval = *((uint16*)pValue);
if ( len == sizeof ( uint16 ) &&
( newInterval >= MIN_CONN_INTERVAL) &&
( newInterval <= MAX_CONN_INTERVAL) )
{
gapRole_MaxConnInterval = newInterval;
}
else
{
ret = bleInvalidRange;
}
}
break;
case GAPROLE_SLAVE_LATENCY:
{
uint16 latency = *((uint16*)pValue);
if ( len == sizeof ( uint16 ) && (latency < MAX_SLAVE_LATENCY) )
{
gapRole_SlaveLatency = latency;
}
else
{
ret = bleInvalidRange;
}
}
break;
case GAPROLE_TIMEOUT_MULTIPLIER:
{
uint16 newTimeout = *((uint16*)pValue);
if ( len == sizeof ( uint16 )
&& (newTimeout >= MIN_TIMEOUT_MULTIPLIER) && (newTimeout <= MAX_TIMEOUT_MULTIPLIER) )
{
gapRole_TimeoutMultiplier = newTimeout;
}
else
{
ret = bleInvalidRange;
}
}
break;
default:
// The param value isn't part of this profile, try the GAP.
if ( (param < TGAP_PARAMID_MAX) && (len == sizeof ( uint16 )) )
{
ret = GAP_SetParamValue( param, *((uint16*)pValue) );
}
else
{
ret = INVALIDPARAMETER;
}
break;
}
return ( ret );
}
示例14: simpleTopology_init
/*********************************************************************
* @fn simpleTopology_init
*
* @brief Called during initialization and contains application
* specific initialization (ie. hardware initialization/setup,
* table initialization, power up notification, etc), and
* profile initialization/setup.
*
* @param None.
*
* @return None.
*/
static void simpleTopology_init(void)
{
// ******************************************************************
// N0 STACK API CALLS CAN OCCUR BEFORE THIS CALL TO ICall_registerApp
// ******************************************************************
// Register the current thread as an ICall dispatcher application
// so that the application can send and receive messages.
ICall_registerApp(&selfEntity, &sem);
// Create an RTOS queue for message from profile to be sent to app.
appMsgQueue = Util_constructQueue(&appMsg);
// Setup discovery delay as a one-shot timer
Util_constructClock(&startDiscClock, simpleTopology_startDiscHandler,
DEFAULT_SVC_DISCOVERY_DELAY, 0, false, 0);
//init keys and LCD
Board_initKeys(simpleTopology_keyChangeHandler);
Board_openLCD();
// Setup the GAP
{
/*-------------------PERIPHERAL-------------------*/
uint16_t advInt = DEFAULT_ADVERTISING_INTERVAL;
GAP_SetParamValue(TGAP_CONN_PAUSE_PERIPHERAL, DEFAULT_CONN_PAUSE_PERIPHERAL);
GAP_SetParamValue(TGAP_LIM_DISC_ADV_INT_MIN, advInt);
GAP_SetParamValue(TGAP_LIM_DISC_ADV_INT_MAX, advInt);
GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MIN, advInt);
GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MAX, advInt);
/*-------------------CENTRAL-------------------*/
GAP_SetParamValue(TGAP_GEN_DISC_SCAN, DEFAULT_SCAN_DURATION);
GAP_SetParamValue(TGAP_CONN_SCAN_INT, DEFAULT_SCAN_INT);
GAP_SetParamValue(TGAP_CONN_SCAN_WIND, DEFAULT_SCAN_WIND);
GAP_SetParamValue(TGAP_CONN_HIGH_SCAN_INT, DEFAULT_SCAN_INT);
GAP_SetParamValue(TGAP_CONN_HIGH_SCAN_WIND, DEFAULT_SCAN_WIND);
GAP_SetParamValue(TGAP_GEN_DISC_SCAN_INT, DEFAULT_SCAN_INT);
GAP_SetParamValue(TGAP_GEN_DISC_SCAN_WIND, DEFAULT_SCAN_WIND);
GAP_SetParamValue(TGAP_LIM_DISC_SCAN_INT, DEFAULT_SCAN_INT);
GAP_SetParamValue(TGAP_LIM_DISC_SCAN_WIND, DEFAULT_SCAN_WIND);
GAP_SetParamValue(TGAP_CONN_EST_SCAN_INT, DEFAULT_SCAN_INT);
GAP_SetParamValue(TGAP_CONN_EST_SCAN_WIND, DEFAULT_SCAN_WIND);
GAP_SetParamValue(TGAP_CONN_EST_INT_MIN, DEFAULT_CONN_INT);
GAP_SetParamValue(TGAP_CONN_EST_INT_MAX, DEFAULT_CONN_INT);
GAP_SetParamValue(TGAP_CONN_EST_SUPERV_TIMEOUT, DEFAULT_CONN_TIMEOUT);
GAP_SetParamValue(TGAP_CONN_EST_LATENCY, DEFAULT_CONN_LATENCY);
}
// Setup the GAP Role Profile
{
/*--------PERIPHERAL-------------*/
// For all hardware platforms, device starts advertising upon initialization
uint8_t initialAdvertEnable = TRUE;
// By setting this to zero, the device will go into the waiting state after
// being discoverable for 30.72 second, and will not being advertising again
// until the enabler is set back to TRUE
uint16_t advertOffTime = 0;
uint16_t desiredMinInterval = DEFAULT_DESIRED_MIN_CONN_INTERVAL;
uint16_t desiredMaxInterval = DEFAULT_DESIRED_MAX_CONN_INTERVAL;
uint16_t desiredSlaveLatency = DEFAULT_DESIRED_SLAVE_LATENCY;
uint16_t desiredConnTimeout = DEFAULT_DESIRED_CONN_TIMEOUT;
GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t),
&initialAdvertEnable, NULL);
GAPRole_SetParameter(GAPROLE_ADVERT_OFF_TIME, sizeof(uint16_t),
&advertOffTime, NULL);
GAPRole_SetParameter(GAPROLE_SCAN_RSP_DATA, sizeof(scanRspData),
scanRspData, NULL);
GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advertData), advertData, NULL);
GAPRole_SetParameter(GAPROLE_MIN_CONN_INTERVAL, sizeof(uint16_t),
&desiredMinInterval, NULL);
GAPRole_SetParameter(GAPROLE_MAX_CONN_INTERVAL, sizeof(uint16_t),
&desiredMaxInterval, NULL);
GAPRole_SetParameter(GAPROLE_SLAVE_LATENCY, sizeof(uint16_t),
&desiredSlaveLatency, NULL);
GAPRole_SetParameter(GAPROLE_TIMEOUT_MULTIPLIER, sizeof(uint16_t),
&desiredConnTimeout, NULL);
/*--------------CENTRAL-----------------*/
uint8_t scanRes = DEFAULT_MAX_SCAN_RES;
GAPRole_SetParameter(GAPROLE_MAX_SCAN_RES, sizeof(uint8_t),
&scanRes, NULL);
// Register with GAP for HCI/Host messages
GAP_RegisterForMsgs(selfEntity);
}
//GATT
{
/*---------------------SERVER------------------------*/
//.........这里部分代码省略.........
示例15: Biscuit_Init
/*********************************************************************
* @fn SimpleBLEPeripheral_Init
*
* @brief Initialization function for the Simple BLE Peripheral App Task.
* This is called during initialization and should contain
* any application specific initialization (ie. hardware
* initialization/setup, table initialization, power up
* notificaiton ... ).
*
* @param task_id - the ID assigned by OSAL. This ID should be
* used to send messages and set timers.
*
* @return none
*/
void Biscuit_Init( uint8 task_id )
{
biscuit_TaskID = task_id;
// Setup the GAP
VOID GAP_SetParamValue( TGAP_CONN_PAUSE_PERIPHERAL, DEFAULT_CONN_PAUSE_PERIPHERAL );
// Setup the GAP Peripheral Role Profile
{
// Device starts advertising upon initialization
uint8 initial_advertising_enable = TRUE;
// By setting this to zero, the device will go into the waiting state after
// being discoverable for 30.72 second, and will not being advertising again
// until the enabler is set back to TRUE
uint16 gapRole_AdvertOffTime = 0;
uint8 enable_update_request = DEFAULT_ENABLE_UPDATE_REQUEST;
uint16 desired_min_interval = DEFAULT_DESIRED_MIN_CONN_INTERVAL;
uint16 desired_max_interval = DEFAULT_DESIRED_MAX_CONN_INTERVAL;
uint16 desired_slave_latency = DEFAULT_DESIRED_SLAVE_LATENCY;
uint16 desired_conn_timeout = DEFAULT_DESIRED_CONN_TIMEOUT;
// Set the GAP Role Parameters
GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &initial_advertising_enable );
GAPRole_SetParameter( GAPROLE_ADVERT_OFF_TIME, sizeof( uint16 ), &gapRole_AdvertOffTime );
GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( advertData ), advertData );
GAPRole_SetParameter( GAPROLE_SCAN_RSP_DATA, sizeof ( scanRspData ), scanRspData );
GAPRole_SetParameter( GAPROLE_PARAM_UPDATE_ENABLE, sizeof( uint8 ), &enable_update_request );
GAPRole_SetParameter( GAPROLE_MIN_CONN_INTERVAL, sizeof( uint16 ), &desired_min_interval );
GAPRole_SetParameter( GAPROLE_MAX_CONN_INTERVAL, sizeof( uint16 ), &desired_max_interval );
GAPRole_SetParameter( GAPROLE_SLAVE_LATENCY, sizeof( uint16 ), &desired_slave_latency );
GAPRole_SetParameter( GAPROLE_TIMEOUT_MULTIPLIER, sizeof( uint16 ), &desired_conn_timeout );
}
// Set the GAP Characteristics
GGS_SetParameter( GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, attDeviceName );
// Set advertising interval
{
uint16 advInt = DEFAULT_ADVERTISING_INTERVAL;
GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MIN, advInt );
GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MAX, advInt );
GAP_SetParamValue( TGAP_GEN_DISC_ADV_INT_MIN, advInt );
GAP_SetParamValue( TGAP_GEN_DISC_ADV_INT_MAX, advInt );
}
// Setup the GAP Bond Manager
{
uint32 passkey = 0; // passkey "000000"
uint8 pairMode = GAPBOND_PAIRING_MODE_WAIT_FOR_REQ;
uint8 mitm = TRUE;
uint8 ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY;
uint8 bonding = TRUE;
GAPBondMgr_SetParameter( GAPBOND_DEFAULT_PASSCODE, sizeof ( uint32 ), &passkey );
GAPBondMgr_SetParameter( GAPBOND_PAIRING_MODE, sizeof ( uint8 ), &pairMode );
GAPBondMgr_SetParameter( GAPBOND_MITM_PROTECTION, sizeof ( uint8 ), &mitm );
GAPBondMgr_SetParameter( GAPBOND_IO_CAPABILITIES, sizeof ( uint8 ), &ioCap );
GAPBondMgr_SetParameter( GAPBOND_BONDING_ENABLED, sizeof ( uint8 ), &bonding );
}
// Initialize GATT attributes
GGS_AddService( GATT_ALL_SERVICES ); // GAP
GATTServApp_AddService( GATT_ALL_SERVICES ); // GATT attributes
//DevInfo_AddService(); // Device Information Service
TXRX_AddService( GATT_ALL_SERVICES ); // Simple GATT Profile
#if defined FEATURE_OAD
VOID OADTarget_AddService(); // OAD Profile
#endif
#if defined( CC2540_MINIDK )
// Register for all key events - This app will handle all key events
RegisterForKeys( biscuit_TaskID );
// makes sure LEDs are off
HalLedSet( (HAL_LED_1 | HAL_LED_2), HAL_LED_MODE_OFF );
// For keyfob board set GPIO pins into a power-optimized state
// Note that there is still some leakage current from the buzzer,
// accelerometer, LEDs, and buttons on the PCB.
P0SEL = 0; // Configure Port 0 as GPIO
//.........这里部分代码省略.........