本文整理汇总了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函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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);
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}