本文整理汇总了C++中sd_ble_gap_appearance_set函数的典型用法代码示例。如果您正苦于以下问题:C++ sd_ble_gap_appearance_set函数的具体用法?C++ sd_ble_gap_appearance_set怎么用?C++ sd_ble_gap_appearance_set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sd_ble_gap_appearance_set函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: 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
示例2: 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
示例3: 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
示例4: 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
示例5: 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
示例6: 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
示例7: 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);
// Set appearence
sd_ble_gap_appearance_set(0);
APP_ERROR_CHECK(err_code);// Check for errors
}
开发者ID:xiaoma2105,项目名称:SH_Repo,代码行数:35,代码来源:main.c
示例8:
ble_error_t nRF5xGap::setAppearance(GapAdvertisingData::Appearance appearance)
{
if (sd_ble_gap_appearance_set(appearance) == NRF_SUCCESS) {
return BLE_ERROR_NONE;
} else {
return BLE_ERROR_PARAM_OUT_OF_RANGE;
}
}
开发者ID:AlessandroA,项目名称:mbed,代码行数:8,代码来源:nRF5xGap.cpp
示例9: 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
示例10: gap_appearance_set_handle
/**@brief Function for decoding a command packet with RPC_SD_BLE_GAP_APPEARANCE_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_appearance_set_handle(uint8_t * p_command, uint32_t command_len)
{
uint16_t appearance = uint16_decode(&(p_command[0]));
RPC_DECODER_LENGTH_CHECK(command_len, sizeof(appearance), SD_BLE_GAP_APPEARANCE_SET);
uint32_t err_code = sd_ble_gap_appearance_set(appearance);
return ble_rpc_cmd_resp_send(SD_BLE_GAP_APPEARANCE_SET, err_code);
}
开发者ID:huiyue000,项目名称:51822,代码行数:25,代码来源:ble_rpc_cmd_decoder_gap.c
示例11: 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
示例12: 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
示例13: gap_params_init
static void gap_params_init(void)
{
uint32_t err_code;
ble_gap_conn_sec_mode_t sec_mode;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); //no security needed
//set BLE name
err_code = sd_ble_gap_device_name_set(&sec_mode,(const uint8_t *)DEVICE_NAME,strlen(DEVICE_NAME));
BLE_ERROR_CHECK(err_code);
//set BLE appearance
err_code = sd_ble_gap_appearance_set(BLE_APPEARANCE_GENERIC_TAG);
BLE_ERROR_CHECK(err_code);
}
开发者ID:HumanDynamics,项目名称:OpenBadge,代码行数:15,代码来源:ble_setup.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_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));
if (err_code == NRF_SUCCESS)
debug_printf("Device name set!\r\n");
else
{
debug_printf("Ooops.. Something went wrong with setting the name..\r\n");
APP_ERROR_CHECK(err_code);
}
err_code = sd_ble_gap_appearance_set(BLE_APPEARANCE_UNKNOWN);
if (err_code == NRF_SUCCESS)
debug_printf("Appearance set!\r\n");
else
{
debug_printf("Ooops.. Something is wrong with setting the appearrance..\r\n");
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);
if (err_code == NRF_SUCCESS)
debug_printf("Connection parameters set!\r\n");
else
{
debug_printf("Ooops.. Something is wrong with setting connection parameters..\r\n");
APP_ERROR_CHECK(err_code);
}
sd_ble_gap_tx_power_set(4);
}
开发者ID:stelios26,项目名称:Aphrodite,代码行数:51,代码来源:main.c
示例15: ASSERT_TRUE
ble_error_t nRF5xGap::setAdvertisingData(const GapAdvertisingData &advData, const GapAdvertisingData &scanResponse)
{
/* Make sure we don't exceed the advertising payload length */
if (advData.getPayloadLen() > GAP_ADVERTISING_DATA_MAX_PAYLOAD) {
return BLE_ERROR_BUFFER_OVERFLOW;
}
/* Make sure we have a payload! */
if (advData.getPayloadLen() == 0) {
return BLE_ERROR_PARAM_OUT_OF_RANGE;
}
/* Check the scan response payload limits */
//if ((params.getAdvertisingType() == GapAdvertisingParams::ADV_SCANNABLE_UNDIRECTED))
//{
// /* Check if we're within the upper limit */
// if (advData.getPayloadLen() > GAP_ADVERTISING_DATA_MAX_PAYLOAD)
// {
// return BLE_ERROR_BUFFER_OVERFLOW;
// }
// /* Make sure we have a payload! */
// if (advData.getPayloadLen() == 0)
// {
// return BLE_ERROR_PARAM_OUT_OF_RANGE;
// }
//}
/* Send advertising data! */
ASSERT_TRUE(ERROR_NONE ==
sd_ble_gap_adv_data_set(advData.getPayload(),
advData.getPayloadLen(),
scanResponse.getPayload(),
scanResponse.getPayloadLen()),
BLE_ERROR_PARAM_OUT_OF_RANGE);
/* Make sure the GAP Service appearance value is aligned with the
*appearance from GapAdvertisingData */
ASSERT_TRUE(ERROR_NONE == sd_ble_gap_appearance_set(advData.getAppearance()),
BLE_ERROR_PARAM_OUT_OF_RANGE);
/* ToDo: Perform some checks on the payload, for example the Scan Response can't */
/* contains a flags AD type, etc. */
return BLE_ERROR_NONE;
}
开发者ID:AlessandroA,项目名称:mbed,代码行数:45,代码来源:nRF5xGap.cpp
示例16: gap_params_init
static void gap_params_init(void)
{
uint32_t err_code;
ble_gap_conn_params_t gap_conn_params;
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);
}
开发者ID:JUMA-IO,项目名称:nRF51_Platform,代码行数:18,代码来源:device_main.c
示例17: gap_params_init
/**@brief 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);
err_code = sd_ble_gap_appearance_set(BLE_APPEARANCE_CYCLING_SPEED_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:rpi-fongming,项目名称:nolem_m2d,代码行数:29,代码来源:main.c
示例18: conn_mw_ble_gap_appearance_set
uint32_t conn_mw_ble_gap_appearance_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);
uint16_t appearance;
uint32_t err_code = NRF_SUCCESS;
uint32_t sd_err_code;
err_code = ble_gap_appearance_set_req_dec(p_rx_buf, rx_buf_len, &appearance);
SER_ASSERT(err_code == NRF_SUCCESS, err_code);
sd_err_code = sd_ble_gap_appearance_set(appearance);
err_code = ble_gap_appearance_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,代码行数:24,代码来源:conn_mw_ble_gap.c
示例19: advertising_init
/**@brief Function for initializing the Advertising functionality.
*
* @details Encodes the required advertising data and passes it to the stack.
* Also builds a structure to be passed to the stack when starting advertising.
*/
static void advertising_init(void)
{
uint32_t err_code;
ble_advdata_t advdata;
ble_gap_conn_sec_mode_t sec_mode;
uint8_t flags = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
// Set GAP parameters
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_WATCH);
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 = false;
advdata.flags = flags;
err_code = ble_advdata_set(&advdata, NULL);
APP_ERROR_CHECK(err_code);
// Initialize 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;
}
开发者ID:kevin-ledinh,项目名称:banana-tree,代码行数:41,代码来源:main.c
示例20: bleApp_gapParamsInit
/**@brief 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.
*/
void bleApp_gapParamsInit() {
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, (uint8_t *)deviceName, strlen(deviceName));
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_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);
}
开发者ID:M-Blocks,项目名称:MBlocks-MB,代码行数:29,代码来源:bleApp.c
注:本文中的sd_ble_gap_appearance_set函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论