BLE GATT Server Implementation Guide

<\/script>\n
'; }, get iframeSnippet() { const domain = '{ SITE_DOMAIN }'; const type = '{ embed_type }'; const slug = '{ embed_slug }'; return ''; }, get activeSnippet() { return this.method === 'script' ? this.scriptSnippet : this.iframeSnippet; }, copySnippet() { navigator.clipboard.writeText(this.activeSnippet).then(() => { this.copied = true; setTimeout(() => { this.copied = false; }, 2000); }); } }" @keydown.escape.window="open = false" @click.outside="open = false">

Embed This Widget

Theme


      
    

Widget powered by . Free, no account required.

Building custom services and characteristics

| 2 min read

GATT Server Implementation

A GATT server hosts BLE data — it exposes services, characteristics, and descriptors that clients can read, write, and subscribe to. Implementing a well-structured ATT">GATT server is the core of most BLE peripheral development.

Service Design

Services group related characteristics. Each is identified by a UUID — either a 16-bit Bluetooth SIG-assigned UUID or a 128-bit vendor-specific UUID.

UUID Type Size Example Source
16-bit 2 bytes 0x180F (Battery) Bluetooth SIG
128-bit 16 bytes 6e400001-b5a3-... Vendor/developer

Use the BLE UUID Generator to generate vendor-specific UUIDs. Use the GATT Profile Browser to find existing standard definitions before creating custom ones.

Characteristic Properties

Property Bit Meaning
Read 0x02 Client can read the value
Write without response 0x04 Client writes, no ACK
Write 0x08 Client writes with ACK
Notify 0x10 Server pushes updates, no ACK
Indicate 0x20 Server pushes updates with ACK

Notifications and Indications

Notifications and indications are the primary mechanism for server-initiated data push. The client must write to the CCCD (UUID 0x2902) to enable them.

Indication requires client acknowledgment and retransmits on failure — suitable for critical data. Notification is fire-and-forget with lower overhead.

/* Zephyr: send notification */
bt_gatt_notify(conn, attr, data, len);

MTU and Throughput

The default ATT MTU is 23 bytes, yielding 20 bytes of characteristic data per packet. Negotiating a larger MTU with DLE dramatically increases throughput.

MTU Payload per packet Notes
23 (default) 20 bytes No negotiation needed
247 244 bytes Requires DLE on the link
517 514 bytes Maximum per spec

Security

Security Level Requirement Use Case
No security Open Non-sensitive data
Unauthenticated encryption Just Works pairing Eavesdropping protection
Authenticated encryption MITM-protected pairing Sensitive commands

For the full pairing and bonding flow, see BLE Protocol Stack Architecture.

Frequently Asked Questions

Yes, our guides range from beginner introductions to advanced topics. Each guide indicates its difficulty level and prerequisites so you can find the right starting point.