Zrozumienie procesów reklamy i skanowania Bluetooth w celu efektywnego odkrywania urządzeń
Bluetooth Low Energy (BLE) has e te dominant standard for short-range wireles communication in thee Internet of Things (IoT), wearable technology, and modern locating-based services. The entire ecosystem depends on a simple yet highly nuanced handshake: responsising and scanning. The averser broadcasts ites presence, and thee scanner listens. While the Bluetooth stack abstracts much of this complex, developers and insers whers master these process build. Whale arty artie, effect, remissivestérevite, revide. Thats intelse intels intels intels intels intels intels intels intels instils
Thee Foundation of Connectionless Communication
Bluetooth reklama reklamowa and scanning form an asymetric communication model. Te reklama transmits data packates at regular intervals, thee reklame te scanner listens for these packagets on specific radio channels. Critically, this initival handshaki is connectionless - thee reklamer does nknot wwho is listening, and the scanner does not conneclett until it decides to, based othedives. Thes foundation enables use cases ranging m simple insilention (ition, edireviton, edion), Eddyne complex connection connectiones appetiones appetiones.
Anatomy of a Bluetooth Wolfing Packet
Uzgodnienie, co is inside an anverdising packet is the first step toward optimization. A legacy anvidatising Protocol Data Unit (PDU) confists of four main parts:
- Xi1; Xi1; FLT: 0 Xi3; Xi3; Preamble (1 bajt): Xi1; Xi1; FLT: 1 Xi3; Xi3; Xised sequence (1010 or 0101) used for receiver syncization.
- Xi1; Xi1; FLT: 0 XI3; Xi3; Access Adres (4 bajty): Xi1; Xi1; FLT: 1 XI3; Xi3; For legacy reklama, this is always Xi1; Xi1; FLT: 0 XI3; Xi3;. Dedicated accessis addisses are used for data channels.
- Xi1; Xi1; FLT: 0 XI3; XI3; PDU Header (2 bajty): XI1; XI1; FLT: 1 XI3; XI3; Definites the PDU type (ADV _ IND, ADV _ NONCONN _ IND, SCAN _ REQ, etc.), length of the payload, and channel information.
- Xion1; Xion1; FLT: 0 Xion3; Xion3; Payload (0- 37 bajtów): Xion1; FLT: 1 Xion3; Xion3; Xion3; Vynts the reklamsers adors (AdvA) and reklamsering data (AdvData).
- Xi1; Xi1; FLT: 0 Xi3; Xi3; CRC (3 bajty): Xi1; FLT: 1 Xi3; Xi3; Cyclic Redundancy Check for error detection.
For developers, the mest critial; Xi1; FLT: 0 Supporte3; Xi3; AdvData Xi1; Xi1; FLT: 1 Supporte3; Xi3; fielde is the most critical Xionent. It is structured as a sequence of AD (Xiing Data) structures, each contenting a length byte, an AD type byte, and the actusaal data. Common AD types included:
- Xi1; Xi1; FLT: 0 Xi3; Xi3; Flags: Xi1; Xi1; FLT: 1 Xi3; Xi3; Indicates LE Limited Discovenable Mode, LE General Discovenable Mode, andd BR / EDR support.
- Xi1; Xi1; FLT: 0 Xi3; Xi3; Local Name: Xi1; FLT: 1 Xi3; Xi3; Shortened or complete device name.
- VII.1; VII.1; FLT: 0 VII3; VII3; VII3; VII3; VII3; VII3; VII3; VII3d; VII3d; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId; VIId) VIId; VIId) VIId) VIId) VIId) VIId; VIId) VIId) VIId; VIId; VIId) VIId) VIId) VIId) VIId) VII@@
- Xi1; Xi1; FLT: 0 Xi3; Xi3; Xirer Specific Data: Xi1; Xi1; FLT: 1 Xi3; Xi3; FLT: 1 Xion3; Xion3; FLT: 0 Xion3; Xion3; Xion3; Xion3; Xion3; Xion3; Xion3; Xion3s iBeacon or Google 's Eddystone; Custom data used by the Xionrer (np.s., Xione' s iBeacon on or Google 's Eddystone).
Primary Philadelphing Channels
Te deliable discotie despite Wi- Fi interference, BLE mandates that reklastising packets be transmited on three primary channels: 37 (2402 MHz), 38 (2426 MHz), and 39 (2480 MHz). These channels are carefully ted to reside in thee gaps between thee center disidencies of thee most castin Wi- Fi channels (1, 6, and 11). A scanner listens on all tree channeels in sequence, ensuring high probability receptiof reception evesten congestements.
Ingeling Modes andTypes
Te Bluetooth Core Specification definiuje several reklamatising PDU type, each tailored for specific use case. Choosing thee correct type is fundamentaltal to o optimizing power and discvery behavor.
- Xion1; Xion1; FLT: 0 Xion3; Xion3; ADV _ IND (Connectable Undirected Xioning): Xion1; FLT: 1 Xion3; Xion3; The most Xionn mode. The reklamer is discverable andd accepts connection requests from from any scanner. Used for general device discowery (np., pairing a smartphone).
- W przypadku gdy nie ma możliwości, aby w przypadku gdy w przypadku braku takiego rozwiązania nie ma możliwości, należy podać nazwę i adres, w którym można się znaleźć.
- Reference 1; Reference 1; FLT: 0 Reference 3; Reference 3; ADV _ NONCONN _ IND (Non-connectable Undirected Referenciing): Order 1; FLT: 1 Reference 3; Reference 3; Thee device is purely broadcasting and cannot t connections. Used extensively for beacons and broadcast sensors, as it consumes less power by eliminating connection overhead.
- (Scannable Undirected Commerciing): dem1; dem1; FLT: 1 conferenci3; EDF: 0,3; ED3; ADV _ SCAN _ IND (Scannable Undirected Commerciing): dem1; FLT: 1,3; EDF; Device is discverable but nott connectable. It can respond to scanners, allowing scanners to gather additional data without confirming a full connection.
Each mode has a corresponding english 1; Xi1; FLT: 0 XI3; XI3; duty cycle english 1; XI1; FLT: 1 XI3; XI3. connectable modes typically use a higher duty cycle to ensure fast connection connectiont, while non-connectable modes can use a lower duty cycle to conservete power.
Deep Dive into the Bluetooth Scanning Process
Scanning is thee active or passive listening for reklamsering packets. The scanner schedule receive windows on thee primary reklamsertising channels. The success of discvery depends entirely on thee overlap between thee reklamser 's transmissionon schedule and thee scanner' s listening schedule.
Passive Scanning: Eavesdropping for Efficiency
In passive scanning, the scanner simplity opens a requieve window and listens for reklamatising PDUs. It does nots transmity any requests. This is the lowest power scanning mode because the radio spends minimal time in transmit mode (which typically draft 10- 20 mA). Passive scanning is ideal for applications that only need tte data already present in thee andevisistising packet, such a beaccon receiver playing a URL or a temratine.
Scanners that only need to detect a handful of Service UUIDS or a considerr ID can operate entirele in passive mode, signitantly reducing system power requirements. For example, a smart home hub monitoring for a specific BLE sensor can stay in passive scan moste moste of the time.
Active Scanning: Gaining Richer Context
When thee scanner requires mone information than what is provided in thee initival 31- byte reklamatising payload, it performs an active scan. Upon receiving an reklamatising packet (specially, an ADV _ IND or ADV _ SCAN _ IND), the scanner transmits a activation 1; 1; FLT: 0 condiv3; SCAN _ REQ presentising packet; FOR 1; FLT: 1; FLT: 1; PDU. Thee reklaser respondwith a exor11; FLT: 2 contribuil3; PDU: 3DU; PDU; DU; DU; DDDDDDT; DT; DT; FLP; FLV; FLV; FLV; FLT: 1; FLT
Active scanning is powerful because it allows the scanner to obtain the device 's full local name or detailed services data before deciding to connect. However, this comes at a cost:
- Xiv1; Xiv1; FLT: 0 Xiv3; Xiv3; Increased Power Consumption: Xiv1; Xiv1; FLT: 1 Xiv3; Xiv3; The scanner muct power its transmitter for the SCAN _ REQ.
- Xi1; Xi1; FLT: 0 Xi3; Xi3; Increased Air Traffic: Xi1; FLT: 1 Xi3; Xion3; The SCAN _ REQ / SCAN _ RSP exchange adds overheadd, potentially incogning g collision probabilities in dense environments.
- Xi1; Xi1; FLT: 0 Xi3; Xi3; Privacy Implications: Xi1; FLT: 1 Xi3; Xi3; Active scanning reveals the scanner 's presence andd MAC addicts to the reklamser.
For passive beacons that do nott two expose their ir full name until a user taps on them, active scanning is appropriate. For simple presence devition, passive scanning is superior.
Scanning Filters andDuplicate Detection
In a dense BLE environment, a scanner can be aboumed by tysięczne of packets per second. To handle this, modern Bluetooth stacks implement explorated filtering.
- Xi1; Xi1; FLT: 0 Xi3; Xi3; Device Filtering: Xi1; FLT: 1 Xi3; Xi1; The scanner can be configured to only process packets frem a whitelist of specific MAC addisses or a set of services UUIDS. This is critical for background scanning on mobile devices to conservene battery.
- Reference 1; FLT: 0 is 3; FLT: 0 is 3; Duplicate Filtering: indi1; FLT: 1 is 3; FLT: 1 is; FL3; Thee stack can automatically discard duplicate packets frem the same device. This prevents the application layer frem being flooded witch repeates reklama. The messates 1; FLT: 1 messa3; parameter in Android 's preventionation the fl1; FLT: 4; FLT: 2 mega3; OS Britionas 3; or the 1e Britude 1l flT: 3 megail 3n; iOS' s 's previdens; FLV: 4; FLT: 3; controlies.
- Reference: Assessment 1; FLT: 0 Xi3; RSSI Filtering: Agression1; FLT: 1 Xion3; Agression3; Some advanced scanners allow filtering based on signat contricth, ignorang devices that are too far way (or too close) to be relevant.
Optimizing the messaing andScanning Ecosystem
Te Key to efficient device discvery lies in tuning thee parameters of both thee reklamser and thee scanner to match thee specific application requirements. The trade-off i s almost always s between power consumption and discvery latency.
Parametry Tuning Reconting Parameters
Te mosty impactful parameter is thee ideas 1; Xi1; FLT: 0 supporte3; Xi3; reklamatising interval presentation 1; Xi1; FLT: 1 supporte3; Xi1; FLT: 5 supporte3; XI3;). It is definited as a multiple of 0.625 ms, ranging from 20 ms to 10.24 seconds. A random delay of 0- 10 ms is added ted teach interval to prevent perstent collisions.
Faszt vs. Slow Portuguing
Bluetooth Core Specification zaleca dwa razy wyższe poziomy duty cycles for reklamodawców:
- Xi1; Xi1; FLT: 0 XI3; XI3; Fast XIING: XI1; XI1; FLT: 1 XI3; XI3; FLT: 0 XI3; FLT: 0 XI3; XI3; Fact XIING: XI1; FLT: 1 XI1; FLT: 1 XI3; XI1; FLT: 0 XI1; FLT: 0 Ms Of 30 Ms to 60 ms. This mode is intended for rapid discvery, such ates whein a device is pairing or whein a user is actively intecting with the device. It providevideves sub- 100 mvery latency but consumes consumes viant power.
- W przypadku gdy w odniesieniu do danego produktu nie ma zastosowania art. 4 ust. 1 lit. a), należy podać numer identyfikacyjny produktu.
Developers should implement a vent 1; vent 1; vent 1; fl1; flT: 0 context; else 3; flora competitising strategy; else; flt: 1 contextion; else;. For example, a sensor could anvietisie rapidly for 30 seconds after a button press (to facilate faste connection), then fall back to a slo w interval for thee rest of thee day te te save battery.
Parametry Tuning Scanning
Thee scanner 's behavor is governed by two parameters: Xi1; Xi1; FLT: 0 Xi3; Xi3; scan window Xi1; Xi1; FLT: 1 Xi3; (Xi1; FLT: 6 XI3; XI3;) And Xi1; FLT: 2 XI3; XI3; SCAN interval XI1; XI1; FLT: 3 XI3; XI3; (XI1; FLT: 7 XI3; XI3;).
- Xi1; Xi1; FLT: 0 Xi3; Xi3; Scan Window: Xi1; FLT: 1 Xi3; Xi3; The duration of one e listening period on a specific channel.
- Xi1; Xi1; FLT: 0 Xi3; Xi3; Scan Interval: Xi1; Xi1; FLT: 1 Xi3; Xi3; The total time between two scan window open.
Thee ratio indi1; Xi1; FLT: 8; Xi3; definites the scanning duty cycle. A Xi1; Xi1; FLT: 0 Xi3; Xi3; 100% duty cycle presendi1; Xi1; FLT: 1 XI3; XI3; means the scanner is constantly listening (Xi1; XI1; FLT: 9 XI3; XI3; = 1; FLT: 10 X3; XI3;). Thi providepentes thee fastest discrevery but the battery rapidly. A XI1; X1; FLT: 2 X33XD; X3D; XI1; FLT: 3D; XE; 3s; meanthin; meirths; meanthir; meirneg onyg onyl. 1%. 1%.
Modern mobile operating systems provide predefinit scan profiles to managed this trade-off:
- Xi1; Xi1; FLT: 0 Xi3; Xi3; SCAN _ MODE _ LOW _ POWER Xi1; Xi1; FLT: 1 Xi3; Xi3; (Android): ~ 10% duty cycle, 0.5 s interval.
- Xi1; Xi1; FLT: 0 Xi3; Xi3; SCAN _ MODE _ BALANCED Xi1; Xi1; FLT: 1 Xi3; Xi3; (Android): ~ 25% duty cycle.
- Xiv1; Xiv1; FLT: 0 Xiv3; Xiv3; Xiv3; SCAN _ MODE _ LOW _ LATENCY Xiv1; Xiv1; FLT: 1 Xiv3; Xiv3; (Android): ~ 100% duty cycle, 2s interval.
For iOS, thee system manages scanning parameters dynamically based on thee app 's state (nearound vs. background). Background scanning cycles are much much longer to conservee batterie.
Advanced Filtering andData Structures
Beyond basic MAC and UUID filtering, developers can optimize discvery by carefly structuring the anviewtising data. Given the 31-byte payload limit, every y byte counts.
- VII.1; VII1; FLT: 0 VII3; VII3; VII3; VII3; VII3; VII3; VII3; VII3; VII3d; VII3d; VIIe 16- bit Bluetooth SIG- assigned UIDs when enevever possible instead of 128- bit conserm UIDs. They fit more efficiently into the packet.
- Xi1; Xi1; FLT: 0 XI3; XI3; XIrer Specific Data: XI1; XI1; FLT: 1 XI3; XI3; FLT: 1 XI3; FLT: 0 XI3; XI3; XIRER Specific Data: XI1; XI1; XI1; FLT: 1 XI3; XI3; XI3; FLT: XIF: FLT: 0 XIX3; FLT: 0 XIXIX3; XIX3; XIXIX3; XRER: XIXIXIXIXIF: AF: AXIXIXIXIXIXIXIXIXIXIXIXIXIXIXIXIXYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY@@
- Xi1; Xi1; FLT: 0 XI3; XI3; XI3; Eddystone and iBeacon: XI1; XI1; FLT: 1 XI3; XI3; THE ARE WELL-KINE frame type that utilizate the XIRER Specific Data field. Scanners specifically look for these frame type, allowing for extremely dimenele XID Filtering at thee radio level.
Advanced Portuguing wigh Bluetooth 5.x Auracast
Bluetooth 5.0 wprowadzić a signitant evolution in reklamatising capabilities, moving beyond thee legacy 31- byte channels.
Extended Portuguing
BLE 5.0 expanded the anvertising channels from the original 3 primary channels to do indiv1; indiv1; FLT: 0 condiv3; indiv3; 39 andivils indiv1; indiv1; FLT: 1 condiv3; indiv3; (chandiels 37- 39 plus 40- 47 are used for secondary andivatising). Extended andivatising allows for:
- Xi1; Xi1; FLT: 0 Xi3; Xi3; Larger Payloads: Xi1; Xi1; FLT: 1 Xi3; Xi3; Up to 255 bytes in a single reklamsising packet.
- Xi1; Xi1; FLT: 0 Xi3; Xi3; Hier Data Rats: Xi1; Xi1; FLT: 1 Xi3; Xi3; Using the 2M PHY (2 Mbps).
- Xi1; Xi1; FLT: 0 Xi3; Xi3; Longer Range: Xi1; Xi1; FLT: 1 Xi3; Xi3; Using the Coded PHY (125 kbps or 500 kbps), which can accee over a kilometr of range in ideal conditions.
- Xi1; Xi1; FLT: 0 XI3; XI3; Primary / Secondary Channels: XI1; XI1; FLT: 1 XI3; XI3; The scanner discvers the device on the primary channels (37, 38, 39) and learns which secondary channel the reklamser will use to send thee actual data. This allows the scanner to tune te thee secondary channel, saving power.
Extended reklamatising is essential for modern IoT gateways and asset tracking tags that need to transmit large compatits of data (like sensor logs or firmware images) with out establishing a full connection.
Periodic Britiing (PAwR i PAST)
Periodic convering takes BLE broadcasting to thee next level. The anverser sends packets at a fixed interval. The scanner can syncizize with the and learns the timing of thee periodyc trains. To synchronize, thee scanner first discvers the device via extended anordicising andd learns the timing of thee periodic train.
Responses: 1; Xi1; FLT: 0 X3; Xi3; PAwR (Periodic Xiling with Responses) Xi1; Xi1; FLT: 1 XI3; XI3; Is a game- changer for two- way communication. It allows a gateway to communicate with thorbine end nodes efficiently, definiing specific responsie slots for each node. This forms the forefur high- density sensor networks like Electronic Shelf Labels (ESLs).
Xi1; Xi1; FLT: 0 XI3; XI3; PAST (Periodic XIING Sync Tranfer) XI1; XI1; FLT: 1 XI3; XI3; allows a device that is already synchized with a periodic reklaser to share that syncization information witch another device. This is the tectal backbone of XIF 1; FLT: 2 XI3; XI3; Auracast XI1; XI1; XI1; FLT: 3 XI3; THE new Bluetooth widcast audio standard.
Auracast: Connectionless Audio
Auracaszt leverages Periodic ing too broadcast audio streams. Hearing aids, earbuds, and speakers scan for Auracast streams. The scanner (np., a phone or hearing aid) synchronizes with the periodic train andd receives the audio data. This is fundamentally different from classic A2DP streaming, as it allows unlimited requirvers to listen viand supportts faicures like sharing audio from a TV to multiple pairs of headheadphone.
Practical Rozważania for Robuss Odkrywanie Systemów
Building a production- ready BLE system requires nawigating the real- term districts of radio physics, batterie chemistry, and operating system limits.
Power Consumption Analysis
Te radio is thee most power-hungry consident on a BLE device. A typical BLE SoC draws 10- 20 mA during active transmissionon or reception. Average power is calculated as:
Xi1; Xi1; FLT: 0 Xi3; Xi3; Avg Power = (TX / RX Current) x Xifyphyrncosyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndifyndify@@
At 1-second orditising intervals, thee duty cycle is minuscule (routly 0.5-1 ms of radio on per second = 0.1% duty cycle). Thii allows a CR2032 coin cell battery to power a beacotn for over a year. Changing to a 100 ms interval progrese the duty cycle to ~ 1%, reducing battery life to a few months. Always calcate thee duty cycle before commerciting to a battery source.
Operating System and Platform Constraints
Mobile operating systems impose strict limits on BLE scanning to protect battery life andd user privacy.
- W przypadku gdy w wyniku badania nie można określić, czy dany produkt jest zgodny z wymogami określonymi w art. 1 ust. 1 lit. a), b) i c) rozporządzenia (UE) nr 1303 / 2013, należy podać numer identyfikacyjny, jeżeli jest to konieczne, aby umożliwić identyfikację produktu.
- Reference 1; Identi1; FLT: 0 is 3; Identi3; Android (Google): Identi1; FLT: 1 is 3; Identi3; Android 8 + inputed background execution limits. Apps scanning in thee background must use a nourond services (if dimenting background scanning) or use beor1; Identi1; FLT: 12 giandis3; With appropriate 1; INT: 1; INT: 13; IND 3; IG 3AE; ID 12 + ITH 1QE; IN: 1GR: 1GF: 14 X3PH 3Permisson, whites a runtimes permitoon likon.
Inżynierowie muszą mieć tect ich ir discvery logic on both platforms underer background conditions, as thes behavor often differs significant from number around operation.
Coexistence andInterference Management
The 2.4 GHz ISM band is a crowded space. Wi- Fi, Zigbee, Thread, and even microvave ovens interfere wigh BLE. The Bluetooth stack handles this thrugh indiv1; indiv1; FLT: 0 message 3; Adaptive Frequency Hopping (AFH) indiv1; indiv1; FLT: 1 message 3; indiv3; on data channels. However, the three primary advisising channels (37, 38, 39) do not hop. If Wi- Fi activity is high on channels 1, and 1d 11, ordivatising packlost.
Developers can limovate this by:
- Using presenta1; Beli1; FLT: 0 presenta3; Extended presenting presenta1; Ely1; FLT: 1 presenta3; Elytae; (BLE 5.x) which utizes more channels for secondary data transmissionon.
- Ensuring the anvisiing interval is long enough to avoid persistent collision wigh Wi- Fi beacons.
- Wdrożenie programu solare-level retransmissionon or acknowment if critical data is being broadcast.
Konkluzja: Mastering thee Discovery Handshake
Efficient Bluetooth device discothery is nott a binary state of being context quentit; connectant quentit; or quentice quentit; diconnectes. Quentiquit; Is a continuous optimization problem involving packet design, power management, and parameter tuning. The reklameser mutt broadcast its presence in a way that is discverable for thee intended use case z wasting battery. The scanner mutt listen intellientlyn, filtering noise focing on concentrant on appendignals.
By mastering the interplay between reklastising intervals, scanning duty cycles, and data filtering, developers cant cant systems that are only reliable andd responsive but also power-enfficient enough t run for years on a single battery. As Bluetooth technology continues to evolvve with auracast and high- density channeling, the principles of efficient reklatising and scanning will mein at thee heart of the wireless ecostem.
Further Reading and d Resources
- Xi1; Xi1; FLT: 0 Xi3; Xi3; Bluetooth SIG Core Specification 5.4: Xi1; FLT: 1 Xi3; Xi3; Xi1; FLT: 2 Xi3; Xi3; Valume 6, Part B - Link Layer Specification Xif1; Xi1; FLT: 3 Xi3; Xif3; Xif3; Xifs;
- Xi1; Xi1; FLT: 0 Xi3; Xi3; Xi3; Android BLE Overview: Xi1; FLT: 1 Xi3; Xi3; Xi1; FLT: 2 Xi3; Xi3; Developer Guide for BLE Scanning andd Xiling Xi1; Xi1; FLT: 3 Xi3; Xi3; Xi3;
- Xi1; Xi1; FLT: 0 Xi3; Xi3; iOS Cory Bluetooth Programming Guide: Xi1; Xi1; FLT: 1 Xi3; Xi1; FLT: 2 Xi3; FLT: 2 Xi3; Xi3; Understanding Background Execution and State Restoration Xi1; Xi1; FLT: 3 Xi3; Xi3; Xi3;
- Basics: Xi1; Xi1; FLT: 0 Xi3; Xi3; Punch Through BLE: Xi1; FLT: 1 Xi3; Xi1; Xi1; FLT: 2 Xi3; Xi3; XiED Technical Overview of BLE Architecture Xi1; Xi1; FLT: 3 Xi3; Xi3; Xi3;
- Xi1; Xi1; FLT: 0 Xi3; Xi3; Auracact Broadcass Audio: Xi1; Xi1; FLT: 1 Xi3; Xi1; FLT: 2 XI3; Xi3; Technical Impletion to Connectionless Audio XI1; Xi1; FLT: 3 Xi3; Xi3; Xi3; XI3;