1*042d53a7SEvalZeroBLE User Guide 2*042d53a7SEvalZero---------------- 3*042d53a7SEvalZero 4*042d53a7SEvalZeroApache Mynewt offers the world's first fully open-source Bluetooth Low 5*042d53a7SEvalZeroEnergy (BLE) or Bluetooth Smart stack fully compliant with Bluetooth 5 6*042d53a7SEvalZerospecifications with support for Bluetooth Mesh. It is called NimBLE. 7*042d53a7SEvalZero 8*042d53a7SEvalZeroBLE technology operates in the unlicensed industrial, scientific and 9*042d53a7SEvalZeromedical (ISM) band at 2.4 to 2.485 GHz which is available in most 10*042d53a7SEvalZerocountries. It uses a spread spectrum, frequency hopping, full-duplex 11*042d53a7SEvalZerosignal. BLE FHSS employs 40 2-MHz-wide channels to ensure greater 12*042d53a7SEvalZeroreliability over longer distances. It also features 0-dBm (1 mW) power 13*042d53a7SEvalZerooutput and a typical maximum range of 50 meters. With Bluetooth 5 14*042d53a7SEvalZerospecification range can be increased 4 times and speed 2 time. 15*042d53a7SEvalZero 16*042d53a7SEvalZero.. toctree:: 17*042d53a7SEvalZero :hidden: 18*042d53a7SEvalZero :titlesonly: 19*042d53a7SEvalZero 20*042d53a7SEvalZero ble_sec 21*042d53a7SEvalZero ble_setup/ble_setup_intro 22*042d53a7SEvalZero ble_hs/ble_hs 23*042d53a7SEvalZero btshell Usage API <btshell/btshell_api> 24*042d53a7SEvalZero mesh/index 25*042d53a7SEvalZero 26*042d53a7SEvalZero.. contents:: 27*042d53a7SEvalZero :local: 28*042d53a7SEvalZero :depth: 2 29*042d53a7SEvalZero 30*042d53a7SEvalZeroNote that BLE is not compatible with standard Bluetooth. 31*042d53a7SEvalZero 32*042d53a7SEvalZeroFeatures 33*042d53a7SEvalZero~~~~~~~~ 34*042d53a7SEvalZero 35*042d53a7SEvalZeroNimBLE complies with Bluetooth Core Specification 5.0 which makes it an 36*042d53a7SEvalZeroideal wireless technology for the Internet of Things (IoT). 37*042d53a7SEvalZero 38*042d53a7SEvalZero- LE Advertising Extensions 39*042d53a7SEvalZero- 2Msym/s PHY for higher throughput 40*042d53a7SEvalZero- Coded PHY for LE Long Range 41*042d53a7SEvalZero- High Duty Cycle Non-Connectable Advertising 42*042d53a7SEvalZero- Channel Selection Algorithm #2 to utilize channels in more efficient 43*042d53a7SEvalZero way. 44*042d53a7SEvalZero- LE Privacy 1.2 for frequent changes to the device address to make it 45*042d53a7SEvalZero difficult to track for outsiders 46*042d53a7SEvalZero- LE Secure Connections featuring FIPS-compliant algorithms. 47*042d53a7SEvalZero- LE Data Length Extension for higher throughput 48*042d53a7SEvalZero- **Coming Soon**: Assigning an Internet Protocol (IP) address 49*042d53a7SEvalZero (complaint with the IPv6 or 6LoWPAN standard) to a Bluetooth device 50*042d53a7SEvalZero through Internet Protocol Support Profile (IPSP) 51*042d53a7SEvalZero 52*042d53a7SEvalZeroThe Bluetooth 5 is backward compatible with previous Bluetooth version 53*042d53a7SEvalZero4.2 which is also supported by Apache Mynewt. 54*042d53a7SEvalZero 55*042d53a7SEvalZeroBluetooth Mesh features 56*042d53a7SEvalZero~~~~~~~~~~~~~~~~~~~~~~~ 57*042d53a7SEvalZero 58*042d53a7SEvalZeroBluetooth Mesh is a great addition to and opens a wide range of new 59*042d53a7SEvalZeropossibilities for the IoT connectivity space. NimBLE fully supports the 60*042d53a7SEvalZerofollowing Bluetooth Mesh features: 61*042d53a7SEvalZero 62*042d53a7SEvalZero- Advertising and GATT bearers 63*042d53a7SEvalZero- PB-GATT and PB-ADV provisioning 64*042d53a7SEvalZero- Foundation Models (server role) 65*042d53a7SEvalZero- Relay support 66*042d53a7SEvalZero- GATT Proxy 67*042d53a7SEvalZero 68*042d53a7SEvalZeroComponents 69*042d53a7SEvalZero~~~~~~~~~~ 70*042d53a7SEvalZero 71*042d53a7SEvalZeroA Bluetooth low energy stack (NimBLE included) consists of two 72*042d53a7SEvalZerocomponents with several subcomponents: 73*042d53a7SEvalZero 74*042d53a7SEvalZero- **Controller** 75*042d53a7SEvalZero 76*042d53a7SEvalZero - **Physical Layer**: adaptive frequency-hopping Gaussian Frequency 77*042d53a7SEvalZero Shift Keying (GFSK) radio using 40 RF channels (0-39), with 2 MHz 78*042d53a7SEvalZero spacing. 79*042d53a7SEvalZero - **Link Layer**: with one of five states (Standby, Advertising, 80*042d53a7SEvalZero Scanning, Initiating, Connection states) active at any time 81*042d53a7SEvalZero 82*042d53a7SEvalZero- **Host** 83*042d53a7SEvalZero 84*042d53a7SEvalZero - **Logical Link Control and Adaptation Protocol (L2CAP)**: provides 85*042d53a7SEvalZero logical channels, named L2CAP channels, which are multiplexed over 86*042d53a7SEvalZero one or more logical links to provide packet segmentation and 87*042d53a7SEvalZero reassembly, flow control, error control, streaming, QoS etc. 88*042d53a7SEvalZero - **Security Manager (SM)**: uses Security Manager Protocol (SMP) 89*042d53a7SEvalZero for pairing and transport specific key distribution for securing 90*042d53a7SEvalZero radio communication 91*042d53a7SEvalZero - **Attribute protocol (ATT)**: allows a device (*Server*) to expose 92*042d53a7SEvalZero certain pieces of data, known as *Attributes*, to another device 93*042d53a7SEvalZero (*Client*) 94*042d53a7SEvalZero - **Generic Attribute Profile (GATT)**: a framework for using the 95*042d53a7SEvalZero ATT protocol to exchange attributes encapsulated as 96*042d53a7SEvalZero *Characteristics* or *Services* 97*042d53a7SEvalZero - **Generic Access Profile (GAP)**: a base profile which all 98*042d53a7SEvalZero Bluetooth devices implement, which in the case of LE, defines the 99*042d53a7SEvalZero Physical Layer, Link Layer, L2CAP, Security Manager, Attribute 100*042d53a7SEvalZero Protocol and Generic Attribute Profile. 101*042d53a7SEvalZero - **Host Controller Interface (HCI)**: the interface between the 102*042d53a7SEvalZero host and controller either through software API or by a hardware 103*042d53a7SEvalZero interface such as SPI, UART or USB. 104*042d53a7SEvalZero 105*042d53a7SEvalZeroSubsequent chapters in this manual will go into the details of the 106*042d53a7SEvalZeroimplementation of each component, APIs available, and things to consider 107*042d53a7SEvalZerowhile designing a NimBLE app. 108*042d53a7SEvalZero 109*042d53a7SEvalZeroExample NimBLE projects 110*042d53a7SEvalZero~~~~~~~~~~~~~~~~~~~~~~~ 111*042d53a7SEvalZero 112*042d53a7SEvalZeroMynewt comes with two built-in projects that allow users to play with 113*042d53a7SEvalZeroNimBLE, try the tutorials out with, and see how to use available 114*042d53a7SEvalZeroservices. 115*042d53a7SEvalZero 116*042d53a7SEvalZero1. **btshell** : A simple shell application which provides a basic 117*042d53a7SEvalZero interface to the host-side of the BLE stack. 118*042d53a7SEvalZero2. **bleprph**: A basic peripheral device with no user interface. It 119*042d53a7SEvalZero advertises automatically on startup, and resumes advertising whenever 120*042d53a7SEvalZero a connection is terminated. It supports a maximum of one connection. 121*042d53a7SEvalZero3. **blemesh**: A sample application for Bluetooth Mesh Node using 122*042d53a7SEvalZero on/off model. 123