add wake up interval

This commit is contained in:
xiehanxin
2023-05-24 20:46:20 +08:00
committed by xiongweichao
parent ebfe2d8f49
commit 7312f3737d
2 changed files with 19 additions and 0 deletions

View File

@@ -57,6 +57,13 @@ menu "Example Configuration"
default 20 if EXAMPLE_MIN_CPU_FREQ_20M
default 10 if EXAMPLE_MIN_CPU_FREQ_10M
config EXAMPLE_ADVERTISE_INTERVAL
int "BLE Advertise interval"
range 0 5000
default 100
help
Wake up interval for BLE advertising. Unit: 1 microsecond.
choice EXAMPLE_USE_IO_TYPE
prompt "I/O Capability"
default BLE_SM_IO_CAP_NO_IO

View File

@@ -30,6 +30,7 @@
#include "console/console.h"
#include "services/gap/ble_svc_gap.h"
#include "bleprph.h"
#include "driver/gpio.h"
static const char *tag = "NimBLE_BLE_PRPH";
static int bleprph_gap_event(struct ble_gap_event *event, void *arg);
@@ -122,6 +123,9 @@ bleprph_advertise(void)
memset(&adv_params, 0, sizeof adv_params);
adv_params.conn_mode = BLE_GAP_CONN_MODE_UND;
adv_params.disc_mode = BLE_GAP_DISC_MODE_GEN;
adv_params.itvl_min = (CONFIG_EXAMPLE_ADVERTISE_INTERVAL*1000/625);
adv_params.itvl_max = (CONFIG_EXAMPLE_ADVERTISE_INTERVAL*1000/625);
rc = ble_gap_adv_start(own_addr_type, NULL, BLE_HS_FOREVER,
&adv_params, bleprph_gap_event, NULL);
if (rc != 0) {
@@ -416,6 +420,14 @@ app_main(void)
nimble_port_freertos_init(bleprph_host_task);
#if CONFIG_IDF_TARGET_ESP32C3
gpio_sleep_set_direction(20, GPIO_MODE_INPUT);
gpio_sleep_set_pull_mode(20, GPIO_PULLUP_ONLY);
#elif CONFIG_IDF_TARGET_ESP32S3
gpio_sleep_set_direction(44, GPIO_MODE_INPUT);
gpio_sleep_set_pull_mode(44, GPIO_PULLUP_ONLY);
#endif
/* Initialize command line interface to accept input from user */
rc = scli_init();
if (rc != ESP_OK) {