本文整理汇总了C++中sd_ble_gap_adv_start函数的典型用法代码示例。如果您正苦于以下问题:C++ sd_ble_gap_adv_start函数的具体用法?C++ sd_ble_gap_adv_start怎么用?C++ sd_ble_gap_adv_start使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sd_ble_gap_adv_start函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ble_device_start_advertising
/**@brief Function for starting advertising.
*/
void ble_device_start_advertising(void)
{
uint32_t err_code;
err_code = sd_ble_gap_adv_start(&m_adv_params);
APP_ERROR_CHECK(err_code);
}
示例2: app_beacon_start
void app_beacon_start(void)
{
uint32_t err_code;
uint8_t adv_pdu[ADV_DATA_LEN];
uint8_t adv_len = encode_adv_packet(&adv_pdu[0]);
err_code = sd_ble_gap_adv_data_set(adv_pdu, adv_len, NULL, 0);
if (err_code != NRF_SUCCESS)
{
if (m_beacon.error_handler != NULL)
{
m_beacon.error_handler(err_code);
}
}
err_code = sd_ble_gap_adv_start(&m_beacon.adv_params);
if (err_code != NRF_SUCCESS)
{
if (m_beacon.error_handler != NULL)
{
m_beacon.error_handler(err_code);
}
}
}
示例3: bleApp_advertisingStart
/**@brief Start advertising.
*/
void bleApp_advertisingStart() {
uint32_t err_code;
ble_gap_adv_params_t adv_params;
// Start advertising
memset(&adv_params, 0, sizeof(adv_params));
adv_params.type = BLE_GAP_ADV_TYPE_ADV_IND;
adv_params.p_peer_addr = NULL;
adv_params.fp = BLE_GAP_ADV_FP_ANY;
adv_params.interval = APP_ADV_INTERVAL;
adv_params.timeout = APP_ADV_TIMEOUT_IN_SECONDS;
err_code = sd_ble_gap_adv_start(&adv_params);
/* Allow invalid state errors, trap everything else. We do this because we
* may already be advertising when we try to start advertising again, and
* that's okay. */
if (err_code == NRF_ERROR_INVALID_STATE) {
;
} else {
APP_ERROR_CHECK(err_code);
}
led_setState(LED_BLUE, LED_STATE_SLOW_FLASH);
}
示例4: app_ble_start
/**
* @brief Advertising開始
*/
void app_ble_start(void)
{
uint32_t err_code;
ble_gap_adv_params_t adv_params;
// Start advertising
memset(&adv_params, 0, sizeof(adv_params));
adv_params.type = BLE_GAP_ADV_TYPE_ADV_IND;
adv_params.p_peer_addr = NULL;
adv_params.fp = BLE_GAP_ADV_FP_ANY;
adv_params.interval = MSEC_TO_UNITS(APP_ADV_INTERVAL, UNIT_0_625_MS);
adv_params.timeout = APP_ADV_TIMEOUT_IN_SECONDS;
#ifdef APP_ADV_DISABLE_CH37
adv_params.channel_mask.ch_37_off = 1;
#endif //APP_ADV_DISABLE_CH37
#ifdef APP_ADV_DISABLE_CH38
adv_params.channel_mask.ch_38_off = 1;
#endif //APP_ADV_DISABLE_CH38
#ifdef APP_ADV_DISABLE_CH39
adv_params.channel_mask.ch_39_off = 1;
#endif //APP_ADV_DISABLE_CH39
err_code = sd_ble_gap_adv_start(&adv_params);
APP_ERROR_CHECK(err_code);
led_on(LED_PIN_NO_ADVERTISING);
app_trace_log("advertising start\r\n");
}
示例5: ble_gap_event_handler
static void ble_gap_event_handler(ble_evt_t* evt)
{
switch (evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
break;
case BLE_GAP_EVT_DISCONNECTED:
sd_ble_gap_adv_start(&ble_adv_params);
break;
case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
APP_ERROR_CHECK(sd_ble_gap_sec_params_reply(evt->evt.gap_evt.conn_handle,
BLE_GAP_SEC_STATUS_SUCCESS, &ble_gap_bond_params));
break;
case BLE_GAP_EVT_CONN_SEC_UPDATE:
break;
case BLE_GAP_EVT_AUTH_STATUS:
break;
default:
break;
}
}
示例6: memset
BLETransceiver::Error BLETransceiver::advertise(uint16_t arg_u16_advDuration)
{
uint32_t err_code;
ble_gap_adv_params_t adv_params;
Error loc_s8_err = GENERAL_ERROR;
// Start advertising
memset(&adv_params, 0, sizeof(adv_params));
adv_params.type = BLE_GAP_ADV_TYPE_ADV_IND;
adv_params.p_peer_addr = NULL;
adv_params.fp = BLE_GAP_ADV_FP_ANY;
adv_params.interval = u16_appAdvInterval;
adv_params.timeout = arg_u16_advDuration;
err_code = sd_ble_gap_adv_start(&adv_params);
if(err_code != NRF_SUCCESS)
{
APP_ERROR_CHECK(err_code);
}
else
{
b_isAdvertising = true;
loc_s8_err = NO_ERROR;
}
return loc_s8_err;
}
示例7: main
int main(void)
{
// If transport layer is using UART with flow control we need to get one
// GPIOTE user for the CTS wakeup pin.
APP_GPIOTE_INIT(1);
leds_init();
// Indicate that the application has started up. This can be used to verify that
// application resets if reset button is pressed or the chip has been reset with
// a debugger. The led will be off during reset.
nrf_gpio_pin_set(MAIN_FUNCTION_LED_PIN_NO);
connectivity_chip_reset();
bluetooth_init();
// Enter main loop.
for (;;)
{
uint32_t err_code;
// Start/restart advertising.
if (m_start_adv_flag)
{
err_code = sd_ble_gap_adv_start(&m_adv_params);
APP_ERROR_CHECK(err_code);
nrf_gpio_pin_set(ADVERTISING_LED_PIN_NO);
m_start_adv_flag = false;
}
// Power management.
power_manage();
}
}
示例8: nrf_adv_conn_init
void nrf_adv_conn_init(void)
{
uint32_t error_code;
/* Fill advertisement data struct: */
uint8_t flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;
memset(&ble_adv_data, 0, sizeof(ble_adv_data));
ble_adv_data.flags.size = 1;
ble_adv_data.flags.p_data = &flags;
ble_adv_data.name_type = BLE_ADVDATA_FULL_NAME;
//ble_adv_data.p_manuf_specific_data = &man_data;
ble_gap_conn_sec_mode_t name_sec_mode = {1, 1};
ble_gap_addr_t my_addr;
error_code = sd_ble_gap_address_get(&my_addr);
APP_ERROR_CHECK(error_code);
char name[64];
sprintf(name, "rbc_mesh #%d",
((uint16_t) my_addr.addr[4] << 8) | (my_addr.addr[5]));
error_code = sd_ble_gap_device_name_set(&name_sec_mode, (uint8_t*) name, strlen(name));
APP_ERROR_CHECK(error_code);
/* Set advertisement data with ble_advdata-lib */
error_code = ble_advdata_set(&ble_adv_data, NULL);
APP_ERROR_CHECK(error_code);
/* Start advertising */
error_code = sd_ble_gap_adv_start(&ble_adv_params);
APP_ERROR_CHECK(error_code);
}
示例9: advertising_start
/**@brief Function for starting advertising.
*/
static uint32_t advertising_start(void)
{
uint32_t err_code;
ble_gap_adv_params_t adv_params;
if ((m_flags & DFU_BLE_FLAG_IS_ADVERTISING) != 0)
{
return NRF_SUCCESS;
}
// Initialize advertising parameters (used when starting advertising).
memset(&adv_params, 0, sizeof(adv_params));
err_code = advertising_init(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
VERIFY_SUCCESS(err_code);
adv_params.type = BLE_GAP_ADV_TYPE_ADV_IND;
adv_params.p_peer_addr = NULL;
adv_params.fp = BLE_GAP_ADV_FP_ANY;
adv_params.interval = APP_ADV_INTERVAL;
adv_params.timeout = APP_ADV_TIMEOUT_IN_SECONDS;
err_code = sd_ble_gap_adv_start(&adv_params);
VERIFY_SUCCESS(err_code);
dfu_set_status(DFUS_ADVERTISING_START);
m_flags |= DFU_BLE_FLAG_IS_ADVERTISING;
return NRF_SUCCESS;
}
示例10: advertise_advertise
bool advertise_advertise(void)
{
if (IS_CONNECTING)
{
return false;
}
//If advertising before, stop it.
if (IS_ADVERTISING)
{
sd_ble_gap_adv_stop();
}
advertise_set_data();
ble_gap_adv_params_t adv_settings = { 0 };
adv_settings.type = BLE_GAP_ADV_TYPE_ADV_IND;
adv_settings.fp = BLE_GAP_ADV_FP_ANY;
adv_settings.interval = MSEC_TO_UNITS(25, UNIT_0_625_MS);
adv_settings.timeout = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED;
APP_ERROR_CHECK(sd_ble_gap_adv_start(&adv_settings));
status_set(STATUS_ADVERTISING);
return true;
}
示例11: advertising_start
/**@brief Function for starting advertising.
*/
static void advertising_start(void)
{
uint32_t err_code;
err_code = sd_ble_gap_adv_start(&m_adv_params);
APP_ERROR_CHECK(err_code);
}
示例12: gap_adv_start_handle
/**@brief Function for decoding a command packet with RPC_SD_BLE_GAP_ADV_START 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_adv_start_handle(uint8_t * p_command, uint32_t command_len)
{
ble_gap_adv_params_t adv_params;
ble_gap_addr_t directed_peer_address;
ble_gap_whitelist_t white_list;
uint32_t index = 0;
adv_params.type = p_command[index++];
RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GAP_ADV_START);
if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
{
// Peer Address Present. Decode the peer address.
index += addr_decode(&directed_peer_address, &(p_command[index]));
adv_params.p_peer_addr = &(directed_peer_address);
RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GAP_ADV_START);
}
else
{
adv_params.p_peer_addr = NULL;
}
adv_params.fp = p_command[index++];
RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GAP_ADV_START);
// Whitelist present.
if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
{
uint8_t decoded_length = 0;
uint32_t err_code = whitelist_decode(&white_list,
&(p_command[index]),
&decoded_length);
if (err_code != NRF_SUCCESS)
{
return ble_rpc_cmd_resp_send(SD_BLE_GAP_ADV_START, err_code);
}
index = index + decoded_length;
RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GAP_ADV_START);
adv_params.p_whitelist = &white_list;
RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GAP_ADV_START);
}
else
{
adv_params.p_whitelist = NULL;
}
adv_params.interval = uint16_decode(&p_command[index]);
index += sizeof(uint16_t);
RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GAP_ADV_START);
adv_params.timeout = uint16_decode(&p_command[index]);
RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GAP_ADV_START);
uint32_t err_code = sd_ble_gap_adv_start(&adv_params);
return ble_rpc_cmd_resp_send(SD_BLE_GAP_ADV_START, err_code);
}
示例13: conn_mw_ble_gap_adv_start
uint32_t conn_mw_ble_gap_adv_start(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);
uint32_t err_code = NRF_SUCCESS;
uint32_t sd_err_code;
#if NRF_SD_BLE_API_VERSION > 5
uint8_t conn_cfg_tag;
uint8_t adv_handle;
err_code = ble_gap_adv_start_req_dec(p_rx_buf, rx_buf_len, &adv_handle, &conn_cfg_tag);
SER_ASSERT(err_code == NRF_SUCCESS, err_code);
sd_err_code = sd_ble_gap_adv_start(adv_handle, conn_cfg_tag);
#else
ble_gap_addr_t peer_addr;
ble_gap_adv_params_t adv_params;
ble_gap_adv_params_t * p_adv_params;
adv_params.p_peer_addr = &peer_addr;
p_adv_params = &adv_params;
#if NRF_SD_BLE_API_VERSION >= 4
uint8_t conn_cfg_tag;
err_code = ble_gap_adv_start_req_dec(p_rx_buf, rx_buf_len, &p_adv_params, &conn_cfg_tag);
SER_ASSERT(err_code == NRF_SUCCESS, err_code);
sd_err_code = sd_ble_gap_adv_start(p_adv_params, conn_cfg_tag);
#else
err_code = ble_gap_adv_start_req_dec(p_rx_buf, rx_buf_len, &p_adv_params);
SER_ASSERT(err_code == NRF_SUCCESS, err_code);
sd_err_code = sd_ble_gap_adv_start(p_adv_params);
#endif
#endif
err_code = ble_gap_adv_start_rsp_enc(sd_err_code, p_tx_buf, p_tx_buf_len);
SER_ASSERT(err_code == NRF_SUCCESS, err_code);
return err_code;
}
示例14: advertising_start
/**@brief Start advertising.
*/
static void advertising_start(void)
{
uint32_t err_code;
err_code = sd_ble_gap_adv_start(&m_adv_params);
APP_ERROR_CHECK(err_code);
nrf_gpio_pin_set(ADVERTISING_LED_PIN_NO);
}
示例15: advertising_start
/**@brief Function for starting advertising.
*/
static void advertising_start(void)
{
uint32_t err_code;
err_code = sd_ble_gap_adv_start(&m_adv_params);
APP_ERROR_CHECK(err_code);
err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
APP_ERROR_CHECK(err_code);
}