本文整理汇总了C++中sd_ble_gap_ppcp_set函数的典型用法代码示例。如果您正苦于以下问题:C++ sd_ble_gap_ppcp_set函数的具体用法?C++ sd_ble_gap_ppcp_set怎么用?C++ sd_ble_gap_ppcp_set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sd_ble_gap_ppcp_set函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ble_conn_params_init
uint32_t ble_conn_params_init(const ble_conn_params_init_t * p_init)
{
uint32_t err_code;
m_conn_params_config = *p_init;
m_change_param = false;
if (p_init->p_conn_params != NULL)
{
m_preferred_conn_params = *p_init->p_conn_params;
// Set the connection params in stack
err_code = sd_ble_gap_ppcp_set(&m_preferred_conn_params);
if (err_code != NRF_SUCCESS)
{
return err_code;
}
}
else
{
// Fetch the connection params from stack
err_code = sd_ble_gap_ppcp_get(&m_preferred_conn_params);
if (err_code != NRF_SUCCESS)
{
return err_code;
}
}
m_conn_handle = BLE_CONN_HANDLE_INVALID;
m_update_count = 0;
return app_timer_create(&m_conn_params_timer_id,
APP_TIMER_MODE_SINGLE_SHOT,
update_timeout_handler);
}
开发者ID:A-L-E-X,项目名称:nRF51822-Arduino,代码行数:34,代码来源:ble_conn_params.cpp
示例2: gap_params_init
/**@brief Function for the GAP initialization.
*
* @details This function shall be used to setup all the necessary GAP (Generic Access Profile)
* parameters of the device. It also sets the permissions.
*
*/
static void gap_params_init(void)
{
uint32_t err_code;
ble_gap_conn_params_t gap_conn_params;
ble_gap_conn_sec_mode_t sec_mode;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
err_code = sd_ble_gap_device_name_set(&sec_mode,
(const uint8_t *)DEVICE_NAME,
strlen(DEVICE_NAME));
APP_ERROR_CHECK(err_code);
memset(&gap_conn_params, 0, sizeof(gap_conn_params));
// Set GAP Peripheral Preferred Connection Parameters (converting connection interval from
// milliseconds to required unit of 1.25ms).
gap_conn_params.min_conn_interval = (4 * APP_CFG_CONNECTION_INTERVAL) / 5;
gap_conn_params.max_conn_interval = (4 * APP_CFG_CONNECTION_INTERVAL) / 5;
gap_conn_params.slave_latency = SLAVE_LATENCY;
gap_conn_params.conn_sup_timeout = CONN_SUP_TIMEOUT;
err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
APP_ERROR_CHECK(err_code);
}
开发者ID:tkadom,项目名称:TWBLE,代码行数:31,代码来源:main.c
示例3: gap_params_init
*/
static void gap_params_init(void)
{
uint32_t err_code;
char deviceaddr_name[16];
ble_gap_conn_params_t gap_conn_params;
ble_gap_conn_sec_mode_t sec_mode;
snprintf(&deviceaddr_name,14,"%s-%.4X%.2X\0",
DEVICE_NAME,
NRF_FICR->DEVICEADDR[0],
NRF_FICR->DEVICEADDR[1]);
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
err_code = sd_ble_gap_device_name_set(&sec_mode, (const uint8_t *)deviceaddr_name, strlen(deviceaddr_name));
APP_ERROR_CHECK(err_code);
err_code = sd_ble_gap_appearance_set(BLE_APPEARANCE_CYCLING_CADENCE_SENSOR);
APP_ERROR_CHECK(err_code);
memset(&gap_conn_params, 0, sizeof(gap_conn_params));
gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
gap_conn_params.slave_latency = SLAVE_LATENCY;
gap_conn_params.conn_sup_timeout = CONN_SUP_TIMEOUT;
err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
APP_ERROR_CHECK(err_code);
开发者ID:longcongduoi,项目名称:nRF51SDK,代码行数:31,代码来源:main.c
示例4: ble_conn_params_change_conn_params
uint32_t ble_conn_params_change_conn_params(ble_gap_conn_params_t * new_params)
{
uint32_t err_code;
m_preferred_conn_params = *new_params;
// Set the connection params in stack
err_code = sd_ble_gap_ppcp_set(&m_preferred_conn_params);
if (err_code == NRF_SUCCESS)
{
if (!is_conn_params_ok(&m_current_conn_params))
{
m_change_param = true;
err_code = sd_ble_gap_conn_param_update(m_conn_handle, &m_preferred_conn_params);
m_update_count = 1;
}
else
{
// Notify the application that the procedure has succeded
if (m_conn_params_config.evt_handler != NULL)
{
ble_conn_params_evt_t evt;
evt.evt_type = BLE_CONN_PARAMS_EVT_SUCCEEDED;
m_conn_params_config.evt_handler(&evt);
}
err_code = NRF_SUCCESS;
}
}
return err_code;
}
开发者ID:0xc0170,项目名称:mbed,代码行数:30,代码来源:ble_conn_params.cpp
示例5: gap_ppcp_set_handle
/**@brief Function for decoding a command packet with RPC_SD_BLE_GAP_PPCP_SET opcode.
*
* This function will decode the command, call the BLE Stack API, and also send command response
* to the peer through the the transport layer.
*
* @param[in] p_command The encoded structure that needs to be decoded and passed on
* to the BLE Stack API.
* @param[in] command_len The length of the encoded command read from transport layer.
*
* @retval NRF_SUCCESS If the decoding of the command was successful, the SoftDevice
* API was called, and the command response was sent to peer,
* otherwise an error code.
* @retval NRF_ERROR_INVALID_LENGTH If the content length of the packet is not conforming to the
* codec specification.
*/
static uint32_t gap_ppcp_set_handle(uint8_t * p_command, uint32_t command_len)
{
uint32_t err_code;
ble_gap_conn_params_t conn_params;
uint32_t index = 0;
ble_gap_conn_params_t * p_conn_param = NULL;
if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
{
conn_params.min_conn_interval = uint16_decode(&p_command[index]);
index += sizeof(uint16_t);
conn_params.max_conn_interval = uint16_decode(&p_command[index]);
index += sizeof(uint16_t);
conn_params.slave_latency = uint16_decode(&p_command[index]);
index += sizeof(uint16_t);
conn_params.conn_sup_timeout = uint16_decode(&p_command[index]);
p_conn_param = &conn_params;
}
RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GAP_PPCP_SET);
err_code = sd_ble_gap_ppcp_set(p_conn_param);
return ble_rpc_cmd_resp_send(SD_BLE_GAP_PPCP_SET, err_code);
}
开发者ID:huiyue000,项目名称:51822,代码行数:44,代码来源:ble_rpc_cmd_decoder_gap.c
示例6: gap_params_init
/**@brief Function for the GAP initialization.
*
* @details This function will setup all the necessary GAP (Generic Access Profile) parameters of
* the device. It also sets the permissions and appearance.
*/
static uint32_t gap_params_init(void)
{
uint32_t err_code;
ble_gap_conn_params_t gap_conn_params = {0};
ble_gap_conn_sec_mode_t sec_mode;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
err_code = gap_address_change();
VERIFY_SUCCESS(err_code);
err_code = sd_ble_gap_device_name_set(&sec_mode,
(const uint8_t *)DEVICE_NAME,
strlen(DEVICE_NAME));
VERIFY_SUCCESS(err_code);
gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
gap_conn_params.slave_latency = SLAVE_LATENCY;
gap_conn_params.conn_sup_timeout = CONN_SUP_TIMEOUT;
err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
return err_code;
}
开发者ID:CWBudde,项目名称:Espruino,代码行数:30,代码来源:nrf_ble_dfu.c
示例7: gap_params_init
// gap name/appearance/connection parameters
static void gap_params_init (void) {
uint32_t err_code;
ble_gap_conn_sec_mode_t sec_mode;
ble_gap_conn_params_t gap_conn_params;
// Full strength signal
sd_ble_gap_tx_power_set(4);
// Let anyone connect and set the name given the platform
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
err_code = sd_ble_gap_device_name_set(&sec_mode,
(const uint8_t *)"BEES", strlen("BEES"));
//(const uint8_t *)DEVICE_NAME, strlen(DEVICE_NAME));
APP_ERROR_CHECK(err_code);
// Not sure what this is useful for, but why not set it
err_code = sd_ble_gap_appearance_set(BLE_APPEARANCE_GENERIC_COMPUTER);
APP_ERROR_CHECK(err_code);
// Specify parameters for a connection
memset(&gap_conn_params, 0, sizeof(gap_conn_params));
gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
gap_conn_params.slave_latency = SLAVE_LATENCY;
gap_conn_params.conn_sup_timeout = CONN_SUP_TIMEOUT;
err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
APP_ERROR_CHECK(err_code);
}
开发者ID:azhn,项目名称:smartbike,代码行数:30,代码来源:main.c
示例8: gap_params_init
/**@brief Function for the GAP initialization.
*
* @details This function sets up all the necessary GAP (Generic Access Profile) parameters of the
* device including the device name, appearance, and the preferred connection parameters.
*/
static void gap_params_init(void)
{
uint32_t err_code;
ble_gap_conn_params_t gap_conn_params;
ble_gap_conn_sec_mode_t sec_mode;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
err_code = sd_ble_gap_device_name_set(&sec_mode,
(const uint8_t *)DEVICE_NAME,
strlen(DEVICE_NAME));
APP_ERROR_CHECK(err_code);
/* YOUR_JOB: Use an appearance value matching the application's use case.
err_code = sd_ble_gap_appearance_set(BLE_APPEARANCE_);
APP_ERROR_CHECK(err_code); */
memset(&gap_conn_params, 0, sizeof(gap_conn_params));
gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
gap_conn_params.slave_latency = SLAVE_LATENCY;
gap_conn_params.conn_sup_timeout = CONN_SUP_TIMEOUT;
err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
APP_ERROR_CHECK(err_code);
}
开发者ID:eqot,项目名称:ble_app_template,代码行数:32,代码来源:main.c
示例9: gap_params_init
/**@brief Function for the GAP initialization.
*
* @details This function will setup all the necessary GAP (Generic Access Profile)
* parameters of the device. It also sets the permissions and appearance.
*/
static void gap_params_init(void)
{
uint32_t err_code;
ble_gap_conn_params_t gap_conn_params;
ble_gap_conn_sec_mode_t sec_mode;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
err_code = sd_ble_gap_device_name_set(&sec_mode,
(const uint8_t *) DEVICE_NAME,
strlen(DEVICE_NAME));
APP_ERROR_CHECK(err_code);
memset(&gap_conn_params, 0, sizeof(gap_conn_params));
gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
gap_conn_params.slave_latency = SLAVE_LATENCY;
gap_conn_params.conn_sup_timeout = CONN_SUP_TIMEOUT;
err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
APP_ERROR_CHECK(err_code);
// Add static pin:
uint8_t passkey[] = STATIC_PASSKEY;
m_static_pin_option.gap.passkey.p_passkey = passkey;
err_code = sd_ble_opt_set(BLE_GAP_OPT_PASSKEY, &m_static_pin_option);
APP_ERROR_CHECK(err_code);
}
开发者ID:chronosfitness,项目名称:nRF51-ble-app-uart-static-passkey,代码行数:34,代码来源:main.c
示例10: gap_params_init
/**@brief Function for the GAP initialization.
*
* @details This function sets up all the necessary GAP (Generic Access Profile) parameters of the
* device including the device name, appearance, and the preferred connection parameters.
*/
static void gap_params_init(void)
{
uint32_t err_code;
ble_gap_conn_params_t gap_conn_params;
ble_gap_conn_sec_mode_t sec_mode;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
err_code = sd_ble_gap_device_name_set(&sec_mode,
(const uint8_t *)DEVICE_NAME,
strlen(DEVICE_NAME));
APP_ERROR_CHECK(err_code);
err_code = sd_ble_gap_appearance_set(BLE_APPEARANCE_GENERIC_KEYRING);
APP_ERROR_CHECK(err_code);
memset(&gap_conn_params, 0, sizeof(gap_conn_params));
gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
gap_conn_params.slave_latency = SLAVE_LATENCY;
gap_conn_params.conn_sup_timeout = CONN_SUP_TIMEOUT;
err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
APP_ERROR_CHECK(err_code);
err_code = sd_ble_gap_tx_power_set(TX_POWER_LEVEL);
APP_ERROR_CHECK(err_code);
}
开发者ID:RobinLin,项目名称:Espruino,代码行数:34,代码来源:main.c
示例11: gap_params_init
/**@brief Function for the GAP initialization.
*
* @details This function shall be used to setup all the necessary GAP (Generic Access Profile)
* parameters of the device. It also sets the permissions and appearance.
*/
static void gap_params_init(void) {
uint32_t err_code;
ble_gap_conn_params_t gap_conn_params;
ble_gap_conn_sec_mode_t sec_mode;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
err_code = sd_ble_gap_device_name_set(&sec_mode, DEVICE_NAME,
strlen(DEVICE_NAME));
APP_ERROR_CHECK(err_code);
static const unsigned ADDR_LEN = 6;
const uint8_t address[] = { 0xe7, 0xAA, 0xAA, 0xAA, 0xAA, 0xAB };
ble_gap_addr_t dev_addr;
dev_addr.addr_type = ADDR_TYPE_PUBLIC;
memcpy(dev_addr.addr, address, ADDR_LEN);
err_code = sd_ble_gap_address_set(&dev_addr);
APP_ERROR_CHECK(err_code);
memset(&gap_conn_params, 0, sizeof(gap_conn_params));
gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
gap_conn_params.slave_latency = SLAVE_LATENCY;
gap_conn_params.conn_sup_timeout = CONN_SUP_TIMEOUT;
err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
APP_ERROR_CHECK(err_code);
}
开发者ID:Joisar,项目名称:BLE-NRF51822-LBS-ANDROID,代码行数:33,代码来源:main.c
示例12: BLE_GAP_CONN_SEC_MODE_SET_OPEN
//This function configures the Generic access Profile
//GAP is a service that must be implemented on all BLE devices
//These are some basic values that other devices can request
//Some of these values might be writable over the air
//The current characteristics are
// Device name
// Appearance
// Peripheral Preferred Connection Parameters
void GAPController::bleConfigureGAP(){
u32 err = 0;
//Set up an open link write permission
//There are multiple security modes defined in the BLE spec
//Use these macros: http://developer.nordicsemi.com/nRF51_SDK/doc/7.1.0/s110/html/a00813.html
ble_gap_conn_sec_mode_t secPermissionOpen;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&secPermissionOpen);
//Set the GAP device name
err = sd_ble_gap_device_name_set(&secPermissionOpen, (u8*)DEVICE_NAME, strlen(DEVICE_NAME));
APP_ERROR_CHECK(err);
//Set the appearance of the device as defined in http://developer.nordicsemi.com/nRF51_SDK/doc/7.1.0/s110/html/a00837.html
err = sd_ble_gap_appearance_set(BLE_APPEARANCE_GENERIC_COMPUTER);
APP_ERROR_CHECK(err);
//Set gap peripheral preferred connection parameters (not used by the mesh implementation)
ble_gap_conn_params_t gapConnectionParams;
memset(&gapConnectionParams, 0, sizeof(gapConnectionParams));
gapConnectionParams.min_conn_interval = Config->meshMinConnectionInterval;
gapConnectionParams.max_conn_interval = Config->meshMaxConnectionInterval;
gapConnectionParams.slave_latency = Config->meshPeripheralSlaveLatency;
gapConnectionParams.conn_sup_timeout = Config->meshConnectionSupervisionTimeout;
err = sd_ble_gap_ppcp_set(&gapConnectionParams);
APP_ERROR_CHECK(err);
}
开发者ID:Pady005,项目名称:fruitymesh,代码行数:36,代码来源:GAPController.cpp
示例13: gap_params_init
////////////////////////////////////////////////////////////////////////////////
//
// GAP Initialization
static void gap_params_init(void)
{
// Create the scan response name
memset(_scanResponse, 0, sizeof(_scanResponse));
memcpy(_scanResponse, SCAN_RESPONSE_BASE, strlen(SCAN_RESPONSE_BASE));
memcpy(_scanResponse + strlen(SCAN_RESPONSE_BASE), STR(BUILD_NUM), 4);
uint32_t err_code;
ble_gap_conn_params_t gap_conn_params;
ble_gap_conn_sec_mode_t sec_mode;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
err_code = sd_ble_gap_device_name_set(&sec_mode,
(const uint8_t *)_scanResponse,
strlen(_scanResponse));
APP_ERROR_CHECK(err_code);
err_code = sd_ble_gap_appearance_set(BLE_APPEARANCE_UNKNOWN);
APP_ERROR_CHECK(err_code);
err_code = sd_ble_gap_tx_power_set(4);
APP_ERROR_CHECK(err_code);
memset(&gap_conn_params, 0, sizeof(gap_conn_params));
gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
gap_conn_params.slave_latency = SLAVE_LATENCY;
gap_conn_params.conn_sup_timeout = CONN_SUP_TIMEOUT;
err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
APP_ERROR_CHECK(err_code);
}
开发者ID:skywavedesign,项目名称:swd_nrf51_s110_qt_template,代码行数:36,代码来源:custom_profile.c
示例14: gap_params_init
/**@brief Function for the GAP initialization.
*
* @details This function sets up all the necessary GAP (Generic Access Profile) parameters of the
* device including the device name, appearance, and the preferred connection parameters.
*/
static void gap_params_init(void)
{
uint32_t err_code;
ble_gap_conn_params_t gap_conn_params;
ble_gap_conn_sec_mode_t sec_mode;
ble_gap_addr_t device_mac;
#ifdef RANDOM_MAC
device_mac.addr_type = BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE;
err_code = sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_AUTO, &device_mac);
#else
uint8_t mac_addr[] = {0x00,0x19,0x25,0x39,0x54,0x95};
device_mac.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC;
memcpy(device_mac.addr, mac_addr,6);
err_code = sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &device_mac);
APP_ERROR_CHECK(err_code);
#endif
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
err_code = sd_ble_gap_device_name_set(&sec_mode,
(const uint8_t *)DEVICE_NAME,
strlen(DEVICE_NAME));
APP_ERROR_CHECK(err_code);
err_code = sd_ble_gap_appearance_set(BLE_APPEARANCE_GENERIC_TAG);
APP_ERROR_CHECK(err_code);
memset(&gap_conn_params, 0, sizeof(gap_conn_params));
gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
gap_conn_params.slave_latency = SLAVE_LATENCY;
gap_conn_params.conn_sup_timeout = CONN_SUP_TIMEOUT;
err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
APP_ERROR_CHECK(err_code);
err_code = sd_ble_gap_tx_power_set(4);
APP_ERROR_CHECK(err_code);
}
开发者ID:jack23912,项目名称:mtconnect04-examples,代码行数:39,代码来源:main.c
示例15: conn_mw_ble_gap_ppcp_set
uint32_t conn_mw_ble_gap_ppcp_set(uint8_t const * const p_rx_buf,
uint32_t rx_buf_len,
uint8_t * const p_tx_buf,
uint32_t * const p_tx_buf_len)
{
SER_ASSERT_NOT_NULL(p_rx_buf);
SER_ASSERT_NOT_NULL(p_tx_buf);
SER_ASSERT_NOT_NULL(p_tx_buf_len);
ble_gap_conn_params_t conn_params;
ble_gap_conn_params_t * p_conn_params = &conn_params;
uint32_t err_code = NRF_SUCCESS;
uint32_t sd_err_code;
err_code = ble_gap_ppcp_set_req_dec(p_rx_buf, rx_buf_len, &p_conn_params);
SER_ASSERT(err_code == NRF_SUCCESS, err_code);
sd_err_code = sd_ble_gap_ppcp_set(p_conn_params);
err_code = ble_gap_ppcp_set_rsp_enc(sd_err_code, p_tx_buf, p_tx_buf_len);
SER_ASSERT(err_code == NRF_SUCCESS, err_code);
return err_code;
}
开发者ID:BLEHexapod,项目名称:nrf_sdk,代码行数:25,代码来源:conn_mw_ble_gap.c
示例16: gap_params_init
// Function for the GAP initialization.
static void gap_params_init(void)
{
uint32_t err_code;
ble_gap_conn_params_t gap_conn_params;
ble_gap_conn_sec_mode_t sec_mode;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
const char deviceName[] = "RGB LED";
err_code = sd_ble_gap_device_name_set(&sec_mode,
(const uint8_t *) deviceName,
strlen(deviceName));
APP_ERROR_CHECK(err_code);
memset(&gap_conn_params, 0, sizeof(gap_conn_params));
gap_conn_params.min_conn_interval = MSEC_TO_UNITS(20, UNIT_1_25_MS);
gap_conn_params.max_conn_interval = MSEC_TO_UNITS(75, UNIT_1_25_MS);
gap_conn_params.slave_latency = 0;
gap_conn_params.conn_sup_timeout = MSEC_TO_UNITS(4000, UNIT_10_MS);
err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
APP_ERROR_CHECK(err_code);
}
开发者ID:electronut,项目名称:nRF51-RGB-LED-test,代码行数:26,代码来源:main.c
示例17: ASSERT_INT
ble_error_t nRF5xGap::setPreferredConnectionParams(const ConnectionParams_t *params)
{
ASSERT_INT(NRF_SUCCESS,
sd_ble_gap_ppcp_set(reinterpret_cast<const ble_gap_conn_params_t *>(params)),
BLE_ERROR_PARAM_OUT_OF_RANGE);
return BLE_ERROR_NONE;
}
开发者ID:AlessandroA,项目名称:mbed,代码行数:8,代码来源:nRF5xGap.cpp
示例18: bluetooth_init
static void bluetooth_init(void)
{
uint32_t err_code;
ble_gap_conn_params_t gppcp;
ble_advdata_t advdata;
ble_gap_conn_sec_mode_t sec_mode;
uint8_t flags = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
// Initialise SoftDevice, and enable BLE event interrupt.
BLE_STACK_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM,
BLE_L2CAP_MTU_DEF,
ble_evt_dispatch,
false);
// Set GAP parameters
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
err_code = sd_ble_gap_device_name_set(&sec_mode, DEVICE_NAME, strlen(DEVICE_NAME));
APP_ERROR_CHECK(err_code);
err_code = sd_ble_gap_appearance_set(BLE_APPEARANCE_GENERIC_TAG);
APP_ERROR_CHECK(err_code);
memset(&gppcp, 0, sizeof(gppcp));
gppcp.min_conn_interval = MIN_CONN_INTERVAL;
gppcp.max_conn_interval = MAX_CONN_INTERVAL;
gppcp.slave_latency = SLAVE_LATENCY;
gppcp.conn_sup_timeout = CONN_SUP_TIMEOUT;
err_code = sd_ble_gap_ppcp_set(&gppcp);
APP_ERROR_CHECK(err_code);
// Build and set advertising data.
memset(&advdata, 0, sizeof(advdata));
advdata.name_type = BLE_ADVDATA_FULL_NAME;
advdata.include_appearance = true;
advdata.flags.size = sizeof(flags);
advdata.flags.p_data = &flags;
err_code = ble_advdata_set(&advdata, NULL);
APP_ERROR_CHECK(err_code);
// Initialise advertising parameters (used when starting advertising).
memset(&m_adv_params, 0, sizeof(m_adv_params));
m_adv_params.type = BLE_GAP_ADV_TYPE_ADV_IND;
m_adv_params.p_peer_addr = NULL; // Undirected advertisement.
m_adv_params.fp = BLE_GAP_ADV_FP_ANY;
m_adv_params.interval = APP_ADV_INTERVAL;
m_adv_params.timeout = APP_ADV_TIMEOUT_IN_SECONDS;
// Start advertising when entering main loop.
m_start_adv_flag = true;
}
开发者ID:rpi-fongming,项目名称:nolem_m2d,代码行数:56,代码来源:main.c
示例19: gap_params_init
/**@brief Function for the GAP initialization.
*
* @details This function sets up all the necessary GAP (Generic Access Profile) parameters of the
* device including the device name, appearance, and the preferred connection parameters.
*/
static void gap_params_init(void)
{
uint32_t err_code;
ble_gap_conn_params_t gap_conn_params;
ble_gap_conn_sec_mode_t sec_mode;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
err_code = sd_ble_gap_device_name_set(&sec_mode,
(const uint8_t *)DEVICE_NAME,
strlen(DEVICE_NAME));
APP_ERROR_CHECK(err_code);
err_code = sd_ble_gap_appearance_set(BLE_APPEARANCE_UNKNOWN);
APP_ERROR_CHECK(err_code);
memset(&gap_conn_params, 0, sizeof(gap_conn_params));
gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
gap_conn_params.slave_latency = SLAVE_LATENCY;
gap_conn_params.conn_sup_timeout = CONN_SUP_TIMEOUT;
err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
APP_ERROR_CHECK(err_code);
err_code = sd_ble_gap_tx_power_set(INITIAL_TX_POWER_LEVEL);
APP_ERROR_CHECK(err_code);
ble_opt_t ble_opt;
uint8_t passkey[6] = { 0 };
// Fetch pin from UICR
uint8_t val = (*((uint32_t *)UICR_PIN_ADDRESS)) & 0x000000FF;
passkey[0] = (val == 0xFF) ? 0x31 : val;
val = ((*((uint32_t *)UICR_PIN_ADDRESS)) & 0x0000FF00) >> 8;
passkey[1] = (val == 0xFF) ? 0x32 : val;
val = ((*((uint32_t *)UICR_PIN_ADDRESS)) & 0x00FF0000) >> 16;
passkey[2] = (val == 0xFF) ? 0x33 : val;
val = ((*((uint32_t *)UICR_PIN_ADDRESS)) & 0xFF000000) >> 24;
passkey[3] = (val == 0xFF) ? 0x34 : val;
val = (*((uint32_t *)(UICR_PIN_ADDRESS+4))) & 0x000000FF;
passkey[4] = (val == 0xFF) ? 0x35 : val;
val = ((*((uint32_t *)(UICR_PIN_ADDRESS+4))) & 0x0000FF00) >> 8;
passkey[5] = (val == 0xFF) ? 0x36 : val;
ble_opt.gap_opt.passkey.p_passkey = passkey;
err_code = sd_ble_opt_set(BLE_GAP_OPT_PASSKEY, &ble_opt);
APP_ERROR_CHECK(err_code);
}
开发者ID:t21,项目名称:HomeHub,代码行数:60,代码来源:main.c
示例20: btle_gap_init
error_t btle_gap_init(void)
{
ble_gap_conn_params_t gap_conn_params = {0};
gap_conn_params.min_conn_interval = msec_to_1_25msec(
CFG_GAP_CONNECTION_MIN_INTERVAL_MS); // in 1.25ms units
gap_conn_params.max_conn_interval = msec_to_1_25msec(
CFG_GAP_CONNECTION_MAX_INTERVAL_MS); // in 1.25ms unit
gap_conn_params.slave_latency = CFG_GAP_CONNECTION_SLAVE_LATENCY;
gap_conn_params.conn_sup_timeout =
CFG_GAP_CONNECTION_SUPERVISION_TIMEOUT_MS / 10; // in 10ms unit
ble_gap_conn_sec_mode_t sec_mode;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); // no security is needed
// ASSERT_STATUS( sd_ble_gap_device_name_set(&sec_mode, //_modify
// (const uint8_t *)
// CFG_GAP_LOCAL_NAME,
// strlen(CFG_GAP_LOCAL_NAME)));
// ASSERT_STATUS( sd_ble_gap_appearance_set(CFG_GAP_APPEARANCE));
// ASSERT_STATUS( sd_ble_gap_ppcp_set(&gap_conn_params));
// ASSERT_STATUS( sd_ble_gap_tx_power_set(CFG_BLE_TX_POWER_LEVEL));
nrf_err_check( sd_ble_gap_device_name_set(&sec_mode,
(const uint8_t *)
CFG_GAP_LOCAL_NAME,
strlen(CFG_GAP_LOCAL_NAME)) );
nrf_err_check( sd_ble_gap_appearance_set(CFG_GAP_APPEARANCE) );
nrf_err_check( sd_ble_gap_ppcp_set(&gap_conn_params) );
nrf_err_check( sd_ble_gap_tx_power_set(CFG_BLE_TX_POWER_LEVEL) );
/* Connection Parameters */
enum {
FIRST_UPDATE_DELAY = APP_TIMER_TICKS(5000, CFG_TIMER_PRESCALER),
NEXT_UPDATE_DELAY = APP_TIMER_TICKS(5000, CFG_TIMER_PRESCALER),
MAX_UPDATE_COUNT = 3
};
ble_conn_params_init_t cp_init = {0};
cp_init.p_conn_params = NULL;
cp_init.first_conn_params_update_delay = FIRST_UPDATE_DELAY;
cp_init.next_conn_params_update_delay = NEXT_UPDATE_DELAY;
cp_init.max_conn_params_update_count = MAX_UPDATE_COUNT;
cp_init.start_on_notify_cccd_handle = BLE_GATT_HANDLE_INVALID;
cp_init.disconnect_on_fail = true;
cp_init.evt_handler = NULL;
cp_init.error_handler = error_callback;
//ASSERT_STATUS ( ble_conn_params_init(&cp_init)); //_modify
nrf_err_check( ble_conn_params_init(&cp_init) );
return ERROR_NONE;
}
开发者ID:A-L-E-X,项目名称:nRF51822-Arduino,代码行数:53,代码来源:btle_gap.cpp
注:本文中的sd_ble_gap_ppcp_set函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论