210 lines
4.8 KiB
C
210 lines
4.8 KiB
C
/**
|
||
* @file bluetooth_provisioning_config.h
|
||
* @brief 蓝牙配网配置文件
|
||
*
|
||
* 本文件定义了蓝牙配网功能的各种配置参数,包括设备名称、
|
||
* 安全设置、超时时间等,可根据项目需求进行调整
|
||
*/
|
||
|
||
#pragma once
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
/**
|
||
* @brief 蓝牙配网基本配置
|
||
*/
|
||
|
||
// 设备名称最大长度
|
||
#define BT_PROVISIONING_MAX_DEVICE_NAME_LEN 32
|
||
|
||
// SSID最大长度
|
||
#define BT_PROVISIONING_MAX_SSID_LEN 32
|
||
|
||
// 密码最大长度
|
||
#define BT_PROVISIONING_MAX_PASSWORD_LEN 64
|
||
|
||
/**
|
||
* @brief 蓝牙配网超时配置
|
||
*/
|
||
|
||
// 广播超时时间(毫秒),0表示永不超时
|
||
#define BT_PROVISIONING_ADV_TIMEOUT_MS 0
|
||
|
||
// 客户端连接超时时间(毫秒)
|
||
#define BT_PROVISIONING_CLIENT_TIMEOUT_MS (5 * 60 * 1000) // 5分钟
|
||
|
||
// WiFi连接超时时间(毫秒)
|
||
#define BT_PROVISIONING_WIFI_TIMEOUT_MS (100 * 1000) // 100秒,增加超时时间避免过快重新进入配网
|
||
|
||
// WiFi连接最大重试次数
|
||
#define BT_PROVISIONING_WIFI_MAX_RETRY 2
|
||
|
||
/**
|
||
* @brief 蓝牙配网安全配置
|
||
*/
|
||
|
||
// 是否启用安全模式(加密通信)
|
||
#define BT_PROVISIONING_SECURITY_ENABLED 0
|
||
|
||
// 是否需要配对确认
|
||
#define BT_PROVISIONING_REQUIRE_PAIRING 0
|
||
|
||
// 预共享密钥(PSK)- 用于加密通信
|
||
// 注意:如果启用安全模式,客户端也需要使用相同的PSK
|
||
#define BT_PROVISIONING_PSK "Airhub2025"
|
||
|
||
/**
|
||
* @brief 蓝牙配网功能开关
|
||
*/
|
||
|
||
// 是否启用WiFi扫描功能
|
||
#define BT_PROVISIONING_ENABLE_WIFI_SCAN 1
|
||
|
||
// 是否自动发送WiFi状态报告
|
||
#define BT_PROVISIONING_AUTO_REPORT_STATUS 1
|
||
|
||
// 是否在配网成功后自动停止蓝牙服务
|
||
#define BT_PROVISIONING_AUTO_STOP_ON_SUCCESS 1
|
||
|
||
// 自动停止延迟时间(毫秒)
|
||
#define BT_PROVISIONING_AUTO_STOP_DELAY_MS 5000
|
||
|
||
// 是否在配网失败后自动重启配网服务
|
||
#define BT_PROVISIONING_AUTO_RESTART_ON_FAIL 1
|
||
|
||
// 自动重启延迟时间(毫秒)
|
||
#define BT_PROVISIONING_AUTO_RESTART_DELAY_MS 10000
|
||
|
||
/**
|
||
* @brief 蓝牙配网日志配置
|
||
*/
|
||
|
||
// 日志标签
|
||
#define BT_PROVISIONING_LOG_TAG "BluetoothProvisioning"
|
||
|
||
// 是否启用详细日志
|
||
#define BT_PROVISIONING_VERBOSE_LOG 1
|
||
|
||
// 是否记录WiFi密码(安全考虑,建议设为0)
|
||
#define BT_PROVISIONING_LOG_PASSWORD 0
|
||
|
||
/**
|
||
* @brief 蓝牙配网性能配置
|
||
*/
|
||
|
||
// 蓝牙配网任务栈大小(字节)
|
||
#define BT_PROVISIONING_TASK_STACK_SIZE 8192
|
||
|
||
// 蓝牙配网任务优先级
|
||
#define BT_PROVISIONING_TASK_PRIORITY 5
|
||
|
||
// 蓝牙配网任务核心绑定(-1表示不绑定)
|
||
#define BT_PROVISIONING_TASK_CORE_ID -1
|
||
|
||
/**
|
||
* @brief 蓝牙广播参数配置
|
||
*/
|
||
|
||
// 广播间隔最小值(单位:0.625ms)
|
||
#define BT_PROVISIONING_ADV_INT_MIN 0x20 // 20ms
|
||
|
||
// 广播间隔最大值(单位:0.625ms)
|
||
#define BT_PROVISIONING_ADV_INT_MAX 0x40 // 40ms
|
||
|
||
// 广播类型
|
||
#define BT_PROVISIONING_ADV_TYPE ESP_BLE_ADV_TYPE_IND
|
||
|
||
// 广播通道映射
|
||
#define BT_PROVISIONING_ADV_CHNL_MAP ESP_BLE_ADV_CHNL_ALL
|
||
|
||
// 广播过滤策略
|
||
#define BT_PROVISIONING_ADV_FILTER_POLICY ESP_BLE_ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY
|
||
|
||
/**
|
||
* @brief 蓝牙连接参数配置
|
||
*/
|
||
|
||
// 连接间隔最小值(单位:1.25ms)
|
||
#define BT_PROVISIONING_CONN_INT_MIN 0x10 // 20ms
|
||
|
||
// 连接间隔最大值(单位:1.25ms)
|
||
#define BT_PROVISIONING_CONN_INT_MAX 0x20 // 40ms
|
||
|
||
// 从设备延迟
|
||
#define BT_PROVISIONING_SLAVE_LATENCY 0
|
||
|
||
// 监督超时(单位:10ms)
|
||
#define BT_PROVISIONING_SUPERVISION_TIMEOUT 0x48 // 720ms
|
||
|
||
/**
|
||
* @brief 蓝牙配网状态指示配置
|
||
*/
|
||
|
||
// 是否启用LED状态指示
|
||
#define BT_PROVISIONING_ENABLE_LED_INDICATOR 1
|
||
|
||
// 是否启用蜂鸣器状态指示
|
||
#define BT_PROVISIONING_ENABLE_BUZZER_INDICATOR 0
|
||
|
||
// 是否启用语音提示
|
||
#define BT_PROVISIONING_ENABLE_VOICE_PROMPT 1
|
||
|
||
/**
|
||
* @brief 蓝牙配网数据存储配置
|
||
*/
|
||
|
||
// 是否保存WiFi凭据到NVS
|
||
#define BT_PROVISIONING_SAVE_CREDENTIALS 1
|
||
|
||
// NVS命名空间
|
||
#define BT_PROVISIONING_NVS_NAMESPACE "bt_prov"
|
||
|
||
// WiFi SSID存储键
|
||
#define BT_PROVISIONING_NVS_SSID_KEY "wifi_ssid"
|
||
|
||
// WiFi密码存储键
|
||
#define BT_PROVISIONING_NVS_PASSWORD_KEY "wifi_pass"
|
||
|
||
// WiFi BSSID存储键
|
||
#define BT_PROVISIONING_NVS_BSSID_KEY "wifi_bssid"
|
||
|
||
/**
|
||
* @brief 蓝牙配网兼容性配置
|
||
*/
|
||
|
||
// 是否兼容ESP-IDF官方配网APP
|
||
#define BT_PROVISIONING_COMPATIBLE_OFFICIAL_APP 1
|
||
|
||
// 是否支持自定义数据传输
|
||
#define BT_PROVISIONING_SUPPORT_CUSTOM_DATA 1
|
||
|
||
// 自定义数据最大长度
|
||
#define BT_PROVISIONING_MAX_CUSTOM_DATA_LEN 512
|
||
|
||
/**
|
||
* @brief 编译时配置检查
|
||
*/
|
||
|
||
// 检查必要的ESP-IDF组件是否启用
|
||
#ifndef CONFIG_BT_ENABLED
|
||
#warning "蓝牙配网需要启用CONFIG_BT_ENABLED"
|
||
#endif
|
||
|
||
#ifndef CONFIG_BLUEDROID_ENABLED
|
||
#warning "蓝牙配网需要启用CONFIG_BLUEDROID_ENABLED"
|
||
#endif
|
||
|
||
#ifndef CONFIG_BT_BLUFI_ENABLE
|
||
#warning "蓝牙配网需要启用CONFIG_BT_BLUFI_ENABLE"
|
||
#endif
|
||
|
||
#ifndef CONFIG_ESP32_WIFI_ENABLED
|
||
#warning "蓝牙配网需要启用WiFi功能"
|
||
#endif
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|