您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ GAP_SetParamValue函数代码示例

51自学网 2021-06-01 20:49:19
  C++
这篇教程C++ GAP_SetParamValue函数代码示例写得很实用,希望能帮到您。

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

在下文中一共展示了GAP_SetParamValue函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 );}
开发者ID:Mecabot,项目名称:BLE-CC254x-1.4.0,代码行数:48,


示例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;      }    }  }}
开发者ID:victor-zheng,项目名称:BLE,代码行数:44,


示例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);}
开发者ID:chr1s77,项目名称:OldRUThSensorTag,代码行数:68,


示例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 );}
开发者ID:tanxjian,项目名称:BLE-CC254x-1.3.2,代码行数:70,


示例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 ), &param );  param = TRUE;  VOID GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &param );}
开发者ID:AlfredHunter,项目名称:Oidpen,代码行数:22,


示例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 );    }      }}
开发者ID:JensenSung,项目名称:shred444,代码行数:58,


示例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;}
开发者ID:WayneTung,项目名称:TI-CC254x-BLE,代码行数:21,


示例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 );}
开发者ID:JBtje,项目名称:BlueBasic,代码行数:53,


示例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 );}
开发者ID:AubrCool,项目名称:BLE,代码行数:37,


示例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 );}
开发者ID:androdenpark,项目名称:Ti-Wireless-Chip-Demo,代码行数:23,


示例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;}
开发者ID:victor-zheng,项目名称:BLE,代码行数:19,


示例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();}
开发者ID:ClarePhang,项目名称:ALL_SmartBatterySwitch_CC2640,代码行数:24,


示例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 );}
开发者ID:ClarePhang,项目名称:ALL_SmartBatterySwitch_CC2640,代码行数:101,


示例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------------------------*///.........这里部分代码省略.........
开发者ID:pederrand,项目名称:ble-sdk-210-extra,代码行数:101,


示例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//.........这里部分代码省略.........
开发者ID:Bleezworld,项目名称:Biscuit,代码行数:101,


示例16: SimpleBLEBroadcaster_init

/********************************************************************* * @fn      SimpleBLEBroadcaster_init * * @brief   Initialization function for the Simple BLE Broadcaster App *          Task. This is called during initialization and should contain *          any application specific initialization (ie. hardware *          initialization/setup, table initialization, power up *          notification ...). * * @param   none * * @return  none */static void SimpleBLEBroadcaster_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);      // Hard code the DB Address till CC2650 board gets its own IEEE address  //uint8 bdAddress[B_ADDR_LEN] = { 0x33, 0x33, 0x33, 0x33, 0x33, 0x33 };  //HCI_EXT_SetBDADDRCmd(bdAddress);    // Create an RTOS queue for message from profile to be sent to app.  appMsgQueue = Util_constructQueue(&appMsg);  #ifdef TI_DRIVERS_LCD_INCLUDED  //Enable the 3V3 Domain and open LCD  Board_openLCD();#endif //TI_DRIVERS_LCD_INCLUDED    // Setup the GAP Broadcaster Role Profile  {    // For all hardware platforms, device starts advertising upon initialization    uint8_t 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_t gapRole_AdvertOffTime = 0;      #ifndef BEACON_FEATURE    uint8_t advType = GAP_ADTYPE_ADV_SCAN_IND; // use scannable undirected adv#else    uint8_t advType = GAP_ADTYPE_ADV_NONCONN_IND; // use non-connectable adv#endif // !BEACON_FEATURE        // Set the GAP Role Parameters    GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t),                          &initial_advertising_enable);    GAPRole_SetParameter(GAPROLE_ADVERT_OFF_TIME, sizeof(uint16_t),                          &gapRole_AdvertOffTime);        GAPRole_SetParameter(GAPROLE_SCAN_RSP_DATA, sizeof (scanRspData),                          scanRspData);    GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advertData), advertData);    GAPRole_SetParameter(GAPROLE_ADV_EVENT_TYPE, sizeof(uint8_t), &advType);  }  // Set advertising interval  {    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);  }    // Start the Device  VOID GAPRole_StartDevice(&simpleBLEBroadcaster_BroadcasterCBs);    LCD_WRITE_STRING("BLE Broadcaster", LCD_PAGE0);}
开发者ID:victor-zheng,项目名称:BLE,代码行数:78,


示例17: HidEmuKbd_Init

/********************************************************************* * @fn      HidEmuKbd_Init * * @brief   Initialization function for the HidEmuKbd 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 HidEmuKbd_Init( uint8 task_id ){  hidEmuKbdTaskId = task_id;  // Setup the GAP  VOID GAP_SetParamValue( TGAP_CONN_PAUSE_PERIPHERAL, DEFAULT_CONN_PAUSE_PERIPHERAL );    // Setup the GAP Peripheral Role Profile  {    uint8 initial_advertising_enable = 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 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( advData ), advData );    GAPRole_SetParameter( GAPROLE_SCAN_RSP_DATA, sizeof ( scanData ), scanData );    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, (void *) attDeviceName );  // 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 );  }  // Setup Battery Characteristic Values  {    uint8 critical = DEFAULT_BATT_CRITICAL_LEVEL;    Batt_SetParameter( BATT_PARAM_CRITICAL_LEVEL, sizeof (uint8), &critical );  }  // Set up HID keyboard service  HidKbd_AddService( );  // Register for HID Dev callback  HidDev_Register( &hidEmuKbdCfg, &hidEmuKbdHidCBs );  // Register for all key events - This app will handle all key events  RegisterForKeys( hidEmuKbdTaskId );#if defined( CC2540_MINIDK )  // 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  P1SEL = 0; // Configure Port 1 as GPIO  P2SEL = 0; // Configure Port 2 as GPIO  P0DIR = 0xFC; // Port 0 pins P0.0 and P0.1 as input (buttons),                // all others (P0.2-P0.7) as output  P1DIR = 0xFF; // All port 1 pins (P1.0-P1.7) as output  P2DIR = 0x1F; // All port 1 pins (P2.0-P2.4) as output  P0 = 0x03; // All pins on port 0 to low except for P0.0 and P0.1 (buttons)//.........这里部分代码省略.........
开发者ID:bluewish,项目名称:ble_dev,代码行数:101,


示例18: 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,


示例19: SimpleBLEBroadcaster_Init

/********************************************************************* * @fn      SimpleBLEBroadcaster_Init * * @brief   Initialization function for the Simple BLE Broadcaster 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 SimpleBLEBroadcaster_Init( uint8 task_id ){  simpleBLEBroadcaster_TaskID = task_id;  // Setup the GAP Broadcaster Role Profile  {    #if defined( CC2540_MINIDK )         // For the CC2540DK-MINI keyfob, device doesn't start advertising until button is pressed      uint8 initial_advertising_enable = FALSE;    #else      // For other hardware platforms, device starts advertising upon initialization      uint8 initial_advertising_enable = TRUE;    #endif    // 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 advType = GAP_ADTYPE_ADV_NONCONN_IND;   // use non-connectable advertisements    uint8 advType = GAP_ADTYPE_ADV_SCAN_IND; // use scannable unidirected advertisements    // 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_SCAN_RSP_DATA, sizeof ( scanRspData ), scanRspData );    GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( advertData ), advertData );    GAPRole_SetParameter( GAPROLE_ADV_EVENT_TYPE, sizeof( uint8 ), &advType );  }  // 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 );  }  #if defined( CC2540_MINIDK )   // Register for all key events - This app will handle all key events  RegisterForKeys( simpleBLEBroadcaster_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  P1SEL = 0; // Configure Port 1 as GPIO  P2SEL = 0; // Configure Port 2 as GPIO  P0DIR = 0xFC; // Port 0 pins P0.0 and P0.1 as input (buttons),                // all others (P0.2-P0.7) as output  P1DIR = 0xFF; // All port 1 pins (P1.0-P1.7) as output  P2DIR = 0x1F; // All port 1 pins (P2.0-P2.4) as output    P0 = 0x03; // All pins on port 0 to low except for P0.0 and P0.1 (buttons)  P1 = 0;   // All pins on port 1 to low  P2 = 0;   // All pins on port 2 to low    #endif // #if defined( CC2540_MINIDK )#if (defined HAL_LCD) && (HAL_LCD == TRUE)    HalLcdWriteString( "BLE Broadcaster", HAL_LCD_LINE_1 );  #endif // (defined HAL_LCD) && (HAL_LCD == TRUE)      // Setup a delayed profile startup  osal_set_event( simpleBLEBroadcaster_TaskID, SBP_START_DEVICE_EVT );}
开发者ID:billy-wang,项目名称:IOT,代码行数:92,


示例20: glucCollCentral_Init

/********************************************************************* * @fn      glucCollCentral_Init * * @brief   Initialization function for the Glucose Collector App Task. *          This is called during initialization and should contain *          any application specific initialization (ie. hardware *          initialization/setup, table initialization, power up *          notification). * * * @return  none */static void glucCollCentral_Init(){	// ******************************************************************  // 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);  // Set device's Sleep Clock Accuracy  //HCI_EXT_SetSCACmd(40);    // Save the taskId  glucCollTaskId = selfEntity;  // Create an RTOS queue for message from profile to be sent to app.  appMsgQueue = Util_constructQueue(&appMsg);  Board_openLCD();  // Create clock objects for discovery and procedure timeout  Util_constructClock(&discoveryClock, glucCollCentral_clockHandler,                      DEFAULT_SVC_DISCOVERY_DELAY, 0, false,                       GLUCOLL_START_DISCOVERY_EVT);  Util_constructClock(&procTimeoutClock, glucCollCentral_clockHandler,                      GLUCOSE_PROCEDURE_TIMEOUT, 0, false,                       GLUCOLL_PROCEDURE_TIMEOUT_EVT);  // Setup Central Profile  {    uint8_t scanRes = DEFAULT_MAX_SCAN_RES;        GAPCentralRole_SetParameter (GAPCENTRALROLE_MAX_SCAN_RES, sizeof(uint8_t),                                  &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_t *)glucCollDeviceName);  // Setup the GAP Bond Manager  {    uint32_t passkey = DEFAULT_PASSCODE;    uint8_t pairMode = DEFAULT_PAIRING_MODE;    uint8_t mitm = DEFAULT_MITM_MODE;    uint8_t ioCap = DEFAULT_IO_CAPABILITIES;    uint8_t bonding = DEFAULT_BONDING_MODE;        GAPBondMgr_SetParameter(GAPBOND_DEFAULT_PASSCODE, sizeof(uint32_t), &passkey);    GAPBondMgr_SetParameter(GAPBOND_PAIRING_MODE, sizeof(uint8_t), &pairMode);    GAPBondMgr_SetParameter(GAPBOND_MITM_PROTECTION, sizeof(uint8_t), &mitm);    GAPBondMgr_SetParameter(GAPBOND_IO_CAPABILITIES, sizeof(uint8_t), &ioCap);    GAPBondMgr_SetParameter(GAPBOND_BONDING_ENABLED, sizeof(uint8_t), &bonding);  }    // Initialize GATT Client  VOID GATT_InitClient();  // Register to receive incoming ATT Indications/Notifications  GATT_RegisterForInd(glucCollTaskId);  // 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  Board_initKeys(glucCollCentral_keyChangeHandler);  // Register with bond manager after starting device  GAPBondMgr_Register((gapBondCBs_t *)&glucCollBondCB);    // Start the Device  VOID GAPCentralRole_StartDevice((gapCentralRoleCB_t *)&glucCollRoleCB);}
开发者ID:ClarePhang,项目名称:ALL_SmartBatterySwitch_CC2640,代码行数:89,


示例21: Hidapp_Init

/******************************************************************************* * * @fn      hidappInit * * @brief   This is the Sample Application task initialization called by OSAL. * * @param   taskId - task ID assigned after it was added in the OSAL task queue * * @return  none */void Hidapp_Init( uint8 taskId ){  // save task ID assigned by OSAL  hidappTaskId = taskId;  // Setup Central Profile  {    uint8 scanRes = DEFAULT_MAX_SCAN_RES;    VOID GAPCentralRole_SetParameter( GAPCENTRALROLE_MAX_SCAN_RES, sizeof( uint8 ), &scanRes );  }  // Setup GAP  {    VOID GAP_SetParamValue( TGAP_GEN_DISC_SCAN, DEFAULT_SCAN_DURATION );    VOID GAP_SetParamValue( TGAP_LIM_DISC_SCAN, DEFAULT_SCAN_DURATION );    // Set scanning interval, 48 = 30ms    VOID GAP_SetParamValue( TGAP_LIM_DISC_SCAN_INT, 48 );    // Set scannng window, 48 = 30ms    VOID GAP_SetParamValue( TGAP_LIM_DISC_SCAN_WIND, 48 );  }  // Setup the GAP Bond Manager  {    uint32 passkey = DEFAULT_PASSCODE;    uint8 pairMode = GAPBOND_PAIRING_MODE_WAIT_FOR_REQ;    uint8 mitm = DEFAULT_MITM_MODE;    uint8 ioCap = DEFAULT_IO_CAPABILITIES;    uint8 bonding = DEFAULT_BONDING_MODE;    uint8 autoSync = TRUE;    uint8 bondFailAction = GAPBOND_FAIL_TERMINATE_ERASE_BONDS;    VOID GAPBondMgr_SetParameter( GAPBOND_DEFAULT_PASSCODE, sizeof( uint32 ), &passkey );    VOID GAPBondMgr_SetParameter( GAPBOND_PAIRING_MODE, sizeof( uint8 ), &pairMode );    VOID GAPBondMgr_SetParameter( GAPBOND_MITM_PROTECTION, sizeof( uint8 ), &mitm );    VOID GAPBondMgr_SetParameter( GAPBOND_IO_CAPABILITIES, sizeof( uint8 ), &ioCap );    VOID GAPBondMgr_SetParameter( GAPBOND_BONDING_ENABLED, sizeof( uint8 ), &bonding );    VOID GAPBondMgr_SetParameter( GAPBOND_AUTO_SYNC_WL, sizeof( uint8 ), &autoSync );    VOID GAPBondMgr_SetParameter( GAPBOND_BOND_FAIL_ACTION, sizeof( uint8 ), &bondFailAction );  }  // USB suspend entry/exit hook function setup  pFnSuspendEnterHook = hidappSuspendEnter;  pFnSuspendExitHook = hidappSuspendExit;  // Initialize GATT Client  VOID GATT_InitClient();  // Register to receive notifications  GATT_RegisterForInd( hidappTaskId );  // Set connection parameters:  {    uint16 connectionInterval = APP_CONN_INTERVAL;    uint16 slaveLatency = APP_SLAVE_LATENCY;    uint16 timeout = APP_CONN_TIMEOUT;    VOID GAP_SetParamValue( TGAP_CONN_EST_INT_MIN, connectionInterval );    VOID GAP_SetParamValue( TGAP_CONN_EST_INT_MAX, connectionInterval );    VOID GAP_SetParamValue( TGAP_CONN_EST_LATENCY, slaveLatency );    VOID GAP_SetParamValue( TGAP_CONN_EST_SUPERV_TIMEOUT, timeout );  }  // Register callbacks with the GAP Bond Manager.  GAPBondMgr_Register( &gapBondCBs );  //HalKeyConfig(HAL_KEY_INTERRUPT_ENABLE, hidappHandleKeys);  RegisterForKeys( hidappTaskId );  // set up continued initialization from within OSAL task loop  VOID osal_start_timerEx( taskId, HIDAPP_EVT_START, 100 );  // Clear remote data  hidappEraseHandles();  VOID HCI_EXT_HaltDuringRfCmd( HCI_EXT_HALT_DURING_RF_DISABLE );}
开发者ID:AubrCool,项目名称:BLE,代码行数:88,


示例22: SensorTag_Init

/********************************************************************* * @fn      SensorTag_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 SensorTag_Init( uint8 task_id ){  sensorTag_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 = 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 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_SCAN_RSP_DATA, sizeof ( scanRspData ), scanRspData );    GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( advertData ), advertData );    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, sizeof(attDeviceName), 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 );  }  // Add services  GGS_AddService( GATT_ALL_SERVICES );            // GAP  GATTServApp_AddService( GATT_ALL_SERVICES );    // GATT attributes  DevInfo_AddService();                           // Device Information Service  IRTemp_AddService (GATT_ALL_SERVICES );         // IR Temperature Service  Accel_AddService (GATT_ALL_SERVICES );          // Accelerometer Service  Humidity_AddService (GATT_ALL_SERVICES );       // Humidity Service  Magnetometer_AddService( GATT_ALL_SERVICES );   // Magnetometer Service  Barometer_AddService( GATT_ALL_SERVICES );      // Barometer Service  Gyro_AddService( GATT_ALL_SERVICES );           // Gyro Service  SK_AddService( GATT_ALL_SERVICES );             // Simple Keys Profile  Test_AddService( GATT_ALL_SERVICES );           // Test Profile  CcService_AddService( GATT_ALL_SERVICES );      // Connection Control Service#if defined FEATURE_OAD  VOID OADTarget_AddService();                    // OAD Profile#endif  // Setup the Seensor Profile Characteristic Values  resetCharacteristicValues();//.........这里部分代码省略.........
开发者ID:Mecabot,项目名称:BLE-CC254x-1.4.0,代码行数:101,


示例23: SNP_startAdv

/** *  SNP_startAdv * */uint8_t SNP_startAdv(snpStartAdvReq_t *pReq){  uint8_t status = SNP_SUCCESS;  uint8_t value;  VOID GAPRole_StartDevice(&SNP_gapRoleCBs);    // Duration of the advertisement  // In order to simplify design, set the timeout and interval for both  // limited and general mode. The mode is define by the Adflags advertisement   // token.   // User can still set them individually by using the 'setGapParam' command.  if(pReq->timeout)  {    // Save the timeout in second for the limited mode.    uint16_t temp = pReq->timeout/1000;      status |= GAPRole_SetParameter(TGAP_LIM_ADV_TIMEOUT, sizeof(uint16_t),                                    &temp);    status |= GAPRole_SetParameter(TGAP_GEN_DISC_ADV_MIN, sizeof(uint16_t),                                    &pReq->timeout);  }  // Set advertising interval  if(pReq->interval)  {    status |= GAP_SetParamValue(TGAP_LIM_DISC_ADV_INT_MIN, pReq->interval);    status |= GAP_SetParamValue(TGAP_LIM_DISC_ADV_INT_MAX, pReq->interval);    status |= GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MIN, pReq->interval);    status |= GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MAX, pReq->interval);  }  //Set Advertise Type  status |= GAPRole_SetParameter(GAPROLE_ADV_EVENT_TYPE, sizeof(uint8_t),                                 &pReq->type);    if(status)  {    //Error management    return SNP_OUT_OF_RESOURCES ;  }      //Store behavior of the advertisement.  advBehavior = (pReq->behavior) & 0x3;  advReqAdvType = pReq->type;   //Enable Advertising.  if(GAP_ADTYPE_ADV_NONCONN_IND == pReq->type)  {    uint8_t start = TRUE;    GAPRole_GetParameter(GAPROLE_STATE, &value);    if(value == GAPROLE_CONNECTED)    {      if(advPtrTable[SNP_ADV_DATA_CONN_IDX].length)      {        // SNP was using adv data for connected mode, switch to use adv         // Data for non-connected mode        GAPRole_SetParameter(GAPROLE_ADVERT_DATA,                              advPtrTable[SNP_ADV_DATA_NON_CONN_IDX].length,                             advPtrTable[SNP_ADV_DATA_NON_CONN_IDX].pData);      }    }    status = GAPRole_SetParameter(GAPROLE_ADV_NONCONN_ENABLED, sizeof(uint8_t),                         &start);  }  else  {    uint8_t start = TRUE;    GAPRole_GetParameter(GAPROLE_STATE, &value);    if(value == GAPROLE_CONNECTED)    {      return SNP_CMD_REJECTED;    }    status = GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t),                         &start);  }  return status;}
开发者ID:victor-zheng,项目名称:BLE,代码行数:79,


示例24: SNP_initGAP

/********************************************************************* * @fn      SNP_initGAP * * @brief   Initial parameter needed for using SPNP GATT functionality * * @return  None. */void SNP_initGAP(void){  // Setup the GAP  GAP_SetParamValue(TGAP_CONN_PAUSE_PERIPHERAL, DEFAULT_CONN_PAUSE_PERIPHERAL);  // Setup the GAP Peripheral Role Profile  {    // 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;    uint8_t enableUpdateRequest = DEFAULT_ENABLE_UPDATE_REQUEST;    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;    // Set the GAP Role Parameters    GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t),                         &initialAdvertEnable);    GAPRole_SetParameter(GAPROLE_ADVERT_OFF_TIME, sizeof(uint16_t),                         &advertOffTime);    GAPRole_SetParameter(GAPROLE_SCAN_RSP_DATA, sizeof(scanRspData),                         scanRspData);        GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advertData),                         advertData);        GAPRole_SetParameter(GAPROLE_PARAM_UPDATE_ENABLE, sizeof(uint8_t),                         &enableUpdateRequest);    GAPRole_SetParameter(GAPROLE_MIN_CONN_INTERVAL, sizeof(uint16_t),                         &desiredMinInterval);    GAPRole_SetParameter(GAPROLE_MAX_CONN_INTERVAL, sizeof(uint16_t),                         &desiredMaxInterval);    GAPRole_SetParameter(GAPROLE_SLAVE_LATENCY, sizeof(uint16_t),                         &desiredSlaveLatency);    GAPRole_SetParameter(GAPROLE_TIMEOUT_MULTIPLIER, sizeof(uint16_t),                         &desiredConnTimeout);  }  // Initialize the Advertising data store table with a valid entry   // for the non-connectable mode.  {    uint8_t *pDataPtr;    advPtrTable[SNP_ADV_DATA_NON_CONN_IDX].pData = pDataPtr = ICall_malloc(sizeof(advertData));    if(pDataPtr)    {      advPtrTable[SNP_ADV_DATA_NON_CONN_IDX].length = sizeof(advertData);      memcpy(pDataPtr, advertData, sizeof(advertData));    }    else    {      exceptionHandler();    }  }      // Set advertising interval  {    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);  }    GAPRole_RegisterAppCBs(&paramUpdateCB);}
开发者ID:victor-zheng,项目名称:BLE,代码行数:83,


示例25: GAPBondMgr_SetParameter

//.........这里部分代码省略.........      else      {        ret = bleInvalidRange;      }      break;          case GAPBOND_BONDING_ENABLED:      if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= TRUE) )      {        gapBond_Bonding = *((uint8*)pValue);      }      else      {        ret = bleInvalidRange;      }      break;          case GAPBOND_KEY_DIST_LIST:      if ( len == sizeof ( uint8 ) )      {        gapBond_KeyDistList = *((uint8*)pValue);      }      else      {        ret = bleInvalidRange;      }      break;          case GAPBOND_DEFAULT_PASSCODE:      if ( (len == sizeof ( uint32 ))           && (*((uint32*)pValue) <= GAP_PASSCODE_MAX) )      {        gapBond_Passcode = *((uint32*)pValue);      }      else      {        ret = bleInvalidRange;      }      break;          case GAPBOND_ERASE_ALLBONDS:      if ( len == 0 )      {        VOID gapBondMgrEraseAllBondings();      }      else      {        ret = bleInvalidRange;      }      break;          case GAPBOND_AUTO_FAIL_PAIRING:      if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= TRUE) )      {        gapBond_AutoFail = *((uint8*)pValue);      }      else      {        ret = bleInvalidRange;      }      break;          case GAPBOND_AUTO_FAIL_REASON:      if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= SMP_PAIRING_FAILED_REPEATED_ATTEMPTS) )      {        gapBond_AutoFailReason = *((uint8*)pValue);      }      else      {        ret = bleInvalidRange;      }      break;          case GAPBOND_KEYSIZE:      if ( (len == sizeof ( uint8 ))           && ((*((uint8*)pValue) >= MIN_ENC_KEYSIZE) && (*((uint8*)pValue) <= MAX_ENC_KEYSIZE)) )      {        gapBond_KeySize = *((uint8*)pValue);      }      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 );}
开发者ID:ClarePhang,项目名称:ALL_SmartBatterySwitch_CC2640,代码行数:101,


示例26: SensorGapStateCB

/********************************************************************* * @fn      SensorGapStateCB * * @brief   Notification from the profile of a state change. * * @param   newState - new state * * @return  none */static void SensorGapStateCB( gaprole_States_t newState ){  // if connected  if (newState == GAPROLE_CONNECTED)  {    // get connection handle    GAPRole_GetParameter(GAPROLE_CONNHANDLE, &gapConnHandle);    // Set timer to update connection parameters    // 5 seconds should allow enough time for Service Discovery by the collector to finish    osal_start_timerEx( sensor_TaskID, RSC_CONN_PARAM_UPDATE_EVT, SVC_DISC_DELAY);  }  // if disconnected  else if (gapProfileState == GAPROLE_CONNECTED &&           newState != GAPROLE_CONNECTED)  {    uint8 advState = TRUE;    uint8 bondCount = 0;    // stop periodic measurement    osal_stop_timerEx( sensor_TaskID, RSC_PERIODIC_EVT );    // reset client characteristic configuration descriptors    Running_HandleConnStatusCB( gapConnHandle, LINKDB_STATUS_UPDATE_REMOVED );    //Batt_HandleConnStatusCB( gapConnHandle, LINKDB_STATUS_UPDATE_REMOVED );    // If not already using white list, begin to do so.    GAPBondMgr_GetParameter( GAPBOND_BOND_COUNT, &bondCount );    if(USING_WHITE_LIST && sensorUsingWhiteList == FALSE && bondCount > 0 )    {      uint8 value = GAP_FILTER_POLICY_WHITE;      GAPRole_SetParameter(GAPROLE_ADV_FILTER_POLICY, sizeof( uint8 ), &value);      sensorUsingWhiteList = TRUE;    }    if ( newState == GAPROLE_WAITING_AFTER_TIMEOUT )    {      // link loss timeout-- use fast advertising      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 );    }    else    {      // Else use slow advertising      GAP_SetParamValue( TGAP_GEN_DISC_ADV_INT_MIN, DEFAULT_SLOW_ADV_INTERVAL );      GAP_SetParamValue( TGAP_GEN_DISC_ADV_INT_MAX, DEFAULT_SLOW_ADV_INTERVAL );      GAP_SetParamValue( TGAP_GEN_DISC_ADV_MIN, DEFAULT_WHITE_LIST_ADV_DURATION );    }    // Enable advertising    GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &advState );  }  // if advertising stopped  else if ( gapProfileState == GAPROLE_ADVERTISING &&            newState == GAPROLE_WAITING )  {    uint8 whiteListUsed = FALSE;    // if white list is in use, disable to allow general access    if ( sensorUsingWhiteList == TRUE )    {      uint8 value = GAP_FILTER_POLICY_ALL;      GAPRole_SetParameter(GAPROLE_ADV_FILTER_POLICY, sizeof( uint8), &value);      whiteListUsed = TRUE;      sensorUsingWhiteList = FALSE;    }    // if advertising stopped by user    if ( sensorAdvCancelled )    {      sensorAdvCancelled = FALSE;    }    // if fast advertising interrupted to cancel white list    else if ( ( (!USING_WHITE_LIST) || whiteListUsed) &&              (GAP_GetParamValue( TGAP_GEN_DISC_ADV_INT_MIN ) == DEFAULT_FAST_ADV_INTERVAL ) )    {      uint8 advState = TRUE;      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 );      GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &advState );    }    // if fast advertising switch to slow or if was already slow but using white list.//.........这里部分代码省略.........
开发者ID:HorseMa,项目名称:BLE-CC254x-1.4.0,代码行数:101,


示例27: GAPRole_SetParameter

//.........这里部分代码省略.........        ret = bleInvalidRange;      }      break;    case GAPROLE_ADVERT_DATA:      if ( len <= B_MAX_ADV_LEN )      {        VOID osal_memset( gapRole_AdvertData, 0, B_MAX_ADV_LEN );        VOID osal_memcpy( gapRole_AdvertData, pValue, len );        gapRole_AdvertDataLen = len;      }      else      {        ret = bleInvalidRange;      }      break;    case GAPROLE_SCAN_RSP_DATA:      if ( len <= B_MAX_ADV_LEN )      {        VOID osal_memset( gapRole_ScanRspData, 0, B_MAX_ADV_LEN );        VOID osal_memcpy( gapRole_ScanRspData, pValue, len );        gapRole_ScanRspDataLen = len;      }      else      {        ret = bleInvalidRange;      }      break;    case GAPROLE_ADV_EVENT_TYPE:      if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= GAP_ADTYPE_ADV_LDC_DIRECT_IND) )      {        gapRole_AdvEventType = *((uint8*)pValue);      }      else      {        ret = bleInvalidRange;      }      break;    case GAPROLE_ADV_DIRECT_TYPE:      if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= ADDRTYPE_PRIVATE_RESOLVE) )      {        gapRole_AdvDirectType = *((uint8*)pValue);      }      else      {        ret = bleInvalidRange;      }      break;    case GAPROLE_ADV_DIRECT_ADDR:      if ( len == B_ADDR_LEN )      {        VOID osal_memcpy( gapRole_AdvDirectAddr, pValue, B_ADDR_LEN ) ;      }      else      {        ret = bleInvalidRange;      }      break;    case GAPROLE_ADV_CHANNEL_MAP:      if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= 0x07) )      {        gapRole_AdvChanMap = *((uint8*)pValue);      }      else      {        ret = bleInvalidRange;      }      break;    case GAPROLE_ADV_FILTER_POLICY:      if ( (len == sizeof ( uint8 )) && (*((uint8*)pValue) <= GAP_FILTER_POLICY_WHITE) )      {        gapRole_AdvFilterPolicy = *((uint8*)pValue);      }      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 );}
开发者ID:AlfredHunter,项目名称:Oidpen,代码行数:101,


示例28: SimpleBLEPeripheral_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 SimpleBLEPeripheral_Init( uint8 task_id ){  HCI_EXT_SetTxPowerCmd(LL_EXT_TX_POWER_MINUS_6_DBM);  simpleBLEPeripheral_TaskID = task_id;  if(osal_snv_read(0xfe,1,&gMP)!=NV_OPER_FAILED){	advertData[29]=gMP;  }  // Setup the GAP  VOID GAP_SetParamValue( TGAP_CONN_PAUSE_PERIPHERAL, DEFAULT_CONN_PAUSE_PERIPHERAL );//连接间隙    // Setup the GAP Peripheral Role Profile  {    #if defined( CC2540_MINIDK )      // For the CC2540DK-MINI keyfob, device doesn't start advertising until button is pressed      uint8 initial_advertising_enable = FALSE;    #else      // For other hardware platforms, device starts advertising upon initialization      uint8 initial_advertising_enable = TRUE;    #endif    // 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;    uint16 desired_rssi_rate=DEFAULT_DESIRED_REEI_RATE;    // 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_SCAN_RSP_DATA, sizeof ( scanRspData ), scanRspData );    GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( advertData ), advertData );        GAPRole_SetParameter(GAPROLE_RSSI_READ_RATE,sizeof(uint16),&desired_rssi_rate);//设定RSSI的参数值        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  SimpleProfile_AddService( GATT_ALL_SERVICES );  // Simple GATT Profile#if defined FEATURE_OAD  VOID OADTarget_AddService();                    // OAD Profile#endif  // Setup the SimpleProfile Characteristic Values  {//.........这里部分代码省略.........
开发者ID:HoobeeTechnology,项目名称:Hoobee,代码行数:101,


示例29: 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;  // 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 );/*  {  //w5500_read_server_mac();  w5500_read_server_ip();  uint32 nest=0;  if(w5500_check_link())  {    w5500_socket_send_cmd(SOCKET_IDEX_0,SOCKET_CMD_OPEN);    do    {      if(nest>20000)      {      w5500_socket_handle_status(w5500_socket_read_status(SOCKET_IDEX_0));      nest=0;      }    nest++;    }    while(w5500_socket_state!= SOCKET_INIT);         w5500_socket_send_cmd(SOCKET_IDEX_0,SOCKET_CMD_CONNECT);      do    {      if(nest>20000)      {      w5500_socket_handle_status(w5500_socket_read_status(SOCKET_IDEX_0));      nest=0;      }    nest++;    }    while(w5500_socket_state!=SOCK_ESTABLISHED);                do    {      if(nest>20000)      {      w5500_socket_send(SOCKET_IDEX_0,"hello wkxboot!!",15); //.........这里部分代码省略.........
开发者ID:wkxboot,项目名称:parking_lock,代码行数:101,


示例30: 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 Parametersuint8 initial_advertising_enable = TRUE;    GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &initial_advertising_enable );    GAPRole_SetParameter( GAPROLE_ADVERT_OFF_TIME, sizeof( uint16 ), &gapRole_AdvertOffTime );    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 );  }  i2c_init();    // Set the GAP Characteristics  uint8 nameFlag = eeprom_read(4);  uint8 nameLen = eeprom_read(5);  if( (nameFlag!=1) || (nameLen>20) )        // First time power up after burning firmware    {    GGS_SetParameter( GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, attDeviceName );    uint8 len = strlen( (char const *)attDeviceName );    TXRX_SetParameter( DEV_NAME_CHAR, len, attDeviceName );        eeprom_write(4, 1);    eeprom_write(5, len);    for(uint8 i=0; i<len; i++)    {      eeprom_write(i+8, attDeviceName[i]);    }  }  else  {        uint8 devName[GAP_DEVICE_NAME_LEN];    for(uint8 i=0; i<nameLen; i++)    {      devName[i] = eeprom_read(i+8);    }    devName[nameLen] = '/0';    GGS_SetParameter( GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, devName );    TXRX_SetParameter( DEV_NAME_CHAR, nameLen, devName );  }     uint8 LocalName[GAP_DEVICE_NAME_LEN];  nameLen = eeprom_read(5);  for(uint8 i=0; i<nameLen; i++)  {    LocalName[i] = eeprom_read(i+8);  }  advertData[3] = nameLen + 1;    osal_memcpy(&advertData[5], LocalName, nameLen);    osal_memset(&advertData[nameLen+5], 0, 31-5-nameLen);  GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( advertData ), advertData );  // 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 );  }//.........这里部分代码省略.........
开发者ID:Bleezworld,项目名称:Biscuit,代码行数:101,



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


C++ GATTServApp_InitCharCfg函数代码示例
C++ GAPRole_SetParameter函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。