Phone nearby

BLE GATT Server

A phone finds and controls the device. Starting point for local setup.

Phone nearby Phone connects in ESP32 BLE parts (not S2)

Official path: examples/bluetooth/bluedroid/ble/gatt_server

01 Overview

The device is a GATT server and advertises. Espressif recommends the service-table example for production.

  • Use when: App setup without a router.
  • Skip when: you need public-internet control.

02 Hardware

  • BLE-capable module. Not ESP32-S2.
  • Pairing button and status LED are common. Advertising costs energy.

03 Software flow

1. Init controller + Bluedroid.

2. Create service, characteristic, CCCD, advertise.

3. Notifications only after CCCD is written.

4. Change name and UUIDs before shipping.

04 Core points

  • Notify is not on by default.
  • Demo UUIDs cannot ship.
  • Custom work: protocol, bonding, interval, Wi-Fi provisioning combo.

中文

手机近场

BLE GATT Server

手机发现并控制设备。近场配置和控灯/控锁的起点。

手机近场 被手机连接 ESP32 BLE parts (not S2)

官方路径: examples/bluetooth/bluedroid/ble/gatt_server

01 项目概述

设备当 GATT 服务器并广播。官方建议量产改用 service table 示例。

  • 适用: App 近场配置、不依赖路由器。
  • 不适用: 远程公网控制。

02 项目硬件描述

  • 带 BLE 的模组。S2 无此路径。
  • 常加配对键和状态灯。广播耗电,电池产品要按键才广播。

03 项目软件流程描述

1. 初始化控制器 + Bluedroid。

2. 建服务、特征、CCCD,开始广播。

3. 对端写 CCCD 后才能通知。

4. 出货必须改名字和 UUID,避免和演示设备撞车。

04 项目核心点

  • 通知不会自动开。
  • 官方 UUID 不能出货。
  • 可定制: 协议、绑定、广播间隔、与 Wi-Fi 配网拼接。