[nrf51822][SDK12.3] Implement whitelist fast broadcast in 3s, switch to whitelist slow broadcast indefinitely

Publisher:冰心独语uLatest update time:2022-08-24 Source: csdnKeywords:nrf51822 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Whitelist mechanism


White list is the simplest and most straightforward security mechanism in the BLE protocol.

The so-called whitelist is a group of Bluetooth addresses.

Through the whitelist, we can only allow specific Bluetooth devices (listed in the whitelist) to scan and connect to us.

You can also scan and connect only to specific Bluetooth devices (listed in the whitelist).

#define APP_ADV_FAST_INTERVAL 0x0028    /**< Fast advertising interval (in units of 0.625 ms. This value corresponds to 25 ms.). */

#define APP_ADV_SLOW_INTERVAL 0x0C80    /**< Slow advertising interval (in units of 0.625 ms. This value corrsponds to 2 seconds). */


#define APP_ADV_FAST_TIMEOUT 3  /**< The duration of the fast advertising period (in seconds). */

#define APP_ADV_SLOW_TIMEOUT 0  /**< The duration of the slow advertising period (in seconds). */


static void advertising_init(void)

{

    uint32_t               err_code;

    uint8_t                adv_flags;

    ble_advdata_t advdata;

    ble_adv_modes_config_t options;


    // Build and set advertising data

    memset(&advdata, 0, sizeof(advdata));


    adv_flags                       = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;//重点

    advdata.name_type               = BLE_ADVDATA_FULL_NAME;

    advdata.include_appearance      = true;

    advdata.flags                   = adv_flags;

    advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);

    advdata.uuids_complete.p_uuids  = m_adv_uuids;


    memset(&options, 0, sizeof(options));

    options.ble_adv_whitelist_enabled      = true;//重点

    options.ble_adv_directed_enabled       = true;

    options.ble_adv_directed_slow_enabled  = false;

    options.ble_adv_directed_slow_interval = 0;

    options.ble_adv_directed_slow_timeout  = 0;

    options.ble_adv_fast_enabled           = true;

    options.ble_adv_fast_interval          = APP_ADV_FAST_INTERVAL;

    options.ble_adv_fast_timeout           = APP_ADV_FAST_TIMEOUT;

    options.ble_adv_slow_enabled           = true;

    options.ble_adv_slow_interval          = APP_ADV_SLOW_INTERVAL;

    options.ble_adv_slow_timeout           = APP_ADV_SLOW_TIMEOUT;


    err_code = ble_advertising_init(&advdata,

                                    NULL,

                                    &options,

                                    on_adv_evt,

                                    ble_advertising_error_handler);

    APP_ERROR_CHECK(err_code);

}

Keywords:nrf51822 Reference address:[nrf51822][SDK12.3] Implement whitelist fast broadcast in 3s, switch to whitelist slow broadcast indefinitely

Previous article:[nrf52] The difference between low_power_pwm pwm_library pwm_driver
Next article:[nrf51822][SDK12.3] Use [static/dynamic password] for pairing

Recommended ReadingLatest update time:2024-11-15 17:31

s3c2410_gpio_setpin() and s3c2410_gpio_cfgpin() function definitions
snailszzy  's  s3c2410_gpio_setpin() and s3c2410_gpio_cfgpin() function definitions s3c2410_gpio_setpin() in gpio.c Function: Set the value of the corresponding GPIO port, such as pin=S3C2410_GPB5 to=0: Set the output value of S3C2410_GPB5 to 0 If pin=S3C2410_GPB5 to=1: Set the output value of S3C2410_GPB5 to 1 voi
[Microcontroller]
"Whether learning single-chip microcomputers or embedded systems has a future" 3
    The editor has found that many new enthusiasts have joined us recently, and they are all rookies. Some do not know much about their majors and want to ask themselves what they should learn; some want to ask themselves what they will learn for the future... In fact, for these students, the editor recommends that you
[Microcontroller]
s3c2440 GPIO driver
S3C2440 contains more than 130 general GPIOs. At the same time, these ports also have some multiplexing functions (such as ADC input). Some ports can only input, and some ports can only output. Today we will see how to set the output level of a GPIO and how to get the GPIO level of a port.   The operation of GPIO is d
[Microcontroller]
S3C2440—8. Read and write SDRAM
SDRAM: Synchronous Dynamic Random Access Memory, synchronous dynamic random access memory, synchronization means that the memory needs to synchronize the clock, and the internal command transmission and data transmission are based on it; dynamic means that the storage array needs to be constantly refreshed to ensure t
[Microcontroller]
S3C2440—8. Read and write SDRAM
How Tesla will improve the Model Y's range
How does Tesla achieve such a long battery life? The battery and motor remain unchanged, and the range of Tesla's Model Y is slightly reduced compared to Model 3. Even so, the latest data released by the U.S. Environmental Protection Agency (EPA) shows that the comprehensive range of the Model Y high-performance a
[Automotive Electronics]
How Tesla will improve the Model Y's range
Xiaomi's dual-engine strategy has achieved initial results, with revenue exceeding 200 billion for the first time, IoT contributing 30%
On March 31, Xiaomi announced its fourth quarter and full-year results for 2019. In 2019, Xiaomi's operating income was 205.8 billion yuan, a year-on-year increase of 17.7%; its adjusted net profit was 11.5 billion yuan, a year-on-year increase of 34.8%. It is worth noting that this is the second time that Xiaomi's re
[Internet of Things]
Xiaomi's dual-engine strategy has achieved initial results, with revenue exceeding 200 billion for the first time, IoT contributing 30%
S3C6410 SPI full-duplex read and write process analysis (original)
1. SPI controller datasheet 1For details, please refer to: http://blog.csdn.net/hustyangju/article/details/20474659 2 All SPI registers are mapped to the kernel space and accessed using the base address + offset address method. static volatile void  __iomem *spiregs;                 
[Microcontroller]
New nanoscale 3D transistors unveiled
A team from the Massachusetts Institute of Technology in the United States has successfully developed a new nanoscale 3D transistor using ultra-thin semiconductor materials. This is the smallest 3D transistor known to date, and its performance and functions are comparable to or even exceed those of existing silicon-
[Semiconductor design/manufacturing]
New nanoscale 3D transistors unveiled
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号