s110_nrf51822 Migration Document
A fatal programming error hapened
For Android, it is recommended to install the MCP (Master Control Panel) provided by Nordic
BLE Device Monitor
Ble-sniffer_win_1.0.1_1111_sniffer.exe
Universal access configuration file (Gineric access Profile,gap), which
Ensure that different Bluetooth products can find each other and establish a connection.
(GAP) defines how Bluetooth discovers and establishes a secure (or insecure) connection to other devices.
It handles some general patterns of business (such as inquiries, commands, and searches) and some security issues (such as warranties),
It also handles some of the connected business (such as link setup, channel, and connection creation).
Gap Code:
Gap_params_init ()
This function accomplishes two things:
To set the security mode for a connection
Set connection interval
3.1.2 Gap Initialize Safe Mode configuration:
Gap is also usually responsible for activating the security features of the BLE connection. Only some of the authentication-authenticated connections
The data is readable or writable. Once a connection is formed, the two devices can be called paired through a process.
When pairing, the key establishes a connection for encryption and authentication.
In a typical case, a peripheral requires a central device to provide a key to complete the pairing process. This could be
A fixed value, such as "000000", or possibly a randomly generated value is provided to the user. Central device Send
After the correct key, the two devices Exchange security key encryption and authentication links.
In many cases, the same central device and peripherals will often establish connections and disconnects. BLE
A security feature allows two devices to give each other a long-lasting security key when paired. This feature is called
Bindings enable two re-connected devices to quickly re-determine encryption and authentication without having to undergo a full pairing process,
As long as they store the long-term key information.
Device Name Modification:
Err_code = Sd_ble_gap_device_name_set (&sec_mode, (const uint8_t*) device_name,
Strlen (device_name));
Gap initialization Set Connection interval
Before the connection, the peripheral devices need to broadcast first, to the central device to advertise their existence, mainly with these parameters:
Broadcast interval: unit 0.625MS, broadcast fast, easy to be discovered by the central equipment, slow to save electricity.
Broadcast duration: To save power, it can be broadcast for a period of time.
In a typical Bluetooth system, peripheral devices find specific ad data that allows any central device to know that he is a connected device.
The ad content contains the device address and can contain some additional data, such as the device name. A search request is sent after the central device receives the broadcast
Answer a search reply to peripherals, peripherals, and peripheral devices. This is the device discovery process, and the central device knows that the peripheral is a connected
Equipment. A central device can send a request to establish a connection to a peripheral device, and a connection condition contains some connection parameters:
Connection interval:
In a BLE connection, the FM mechanism needs to be used so that two devices can be sent and received on a specific channel,
After a certain period of time will jump to a new channel, LL layer is responsible for the channel switching.
Slave-to-machine incubation period:
This parameter describes the number of times the slave has skipped a connection event. This gives the peripheral a certain degree of flexibility if it does not have any data
Transfer, it can choose to skip connection events and stay asleep, thus providing some savings in strength. This decision depends on the peripheral equipment.
Watchdog timeout:
The watchdog time-out is from Min. (100ms) to maximum 3200 (32.0s).
Short connection interval:
High power consumption, data throughput, short send wait time
Long Connection interval:
Low power consumption, low data throughput, long send wait time
Low or 0 latent value:
The slave can receive the data from the host computer in the case of high power consumption without data transmission.
High latent value:
From the machine in the absence of data transmission can be low power, from the machine can not receive the host's data in time, but the host can receive the data from the machine in time.
1:nrf51822 layering of Bluetooth protocols
Application layer:
Speed & Cadence, Blood pressure, heart rate, thermometer
Battery, Proximity, HID over GATT
Master protocol layer:
GATT GAP ATT SMP l2cap
Control layer:
Host Controller Interface (HCI)
Link Layer (LL)
Physical Layer (PHY)
2.1.1 Role
In order to create and maintain a BLE connection, the concept of "role" was introduced. A BLE device is not a concentrator role or a peripheral device.
Role, which is determined by who initiated the connection. The concentrator device is always the initiator of the connection, and the peripheral device is always the connected person.
2.1.2 Broadcast
The concentrator can establish a connection with the peripheral device, the peripheral must be broadcast, and it sends a broadcast every time interval
The packet, which is called the broadcast interval, has a range of 20ms to 10.24s. The broadcast interval affects when the connection is established.
Before the concentrator sends a connection request to initiate a connection, it must receive a broadcast packet after the peripheral sends a broadcast packet
Only listen for connection requests for a short period of time.
A broadcast packet can carry up to 31 bytes of data, which usually contains a user-readable name, information about the device sending the packet
A similar flag used to indicate whether this device can be found.
When the concentrator receives a broadcast packet, it may send a request for more packets, called a scan response.
broadcasts, including scan requests and scan responses, appear on 3 frequencies away from the 2.4G band used by the WLAN to prevent interference by WiFi.
2.1.3 Scan
Scanning is the process by which a concentrator listens for broadcast packets and sends a scan request, and it has 2 timing parameters that require special attention: scanning windows and scanning
Interval.
2.1.4 Initiated
If the concentrator wants to establish a connection, the scanner will take the same procedure when it hears the broadcast packet: When the connection is initiated, the concentrator
A connection request is sent after a broadcast packet is received.
2.1.5 Connection
Concentrator and peripherals The first Exchange data is defined as a connection state.
2.2 Common attribute profiles (GATT)
The GATT layer is the layer where real data is transmitted. Includes a data transfer and storage framework as well as basic operations.
Gatta defines two types of roles:
Servers (server) and clients (client),
Note: A device can act as both a server and a client. This uses the development Board as the server, the mobile phone as the client.
2.2.2 The normative level of GATT
A GATT server organizes data through a table called an attribute table, which is the data that is used to actually send.
2.2.2.1 Property
A property contains a handle, a UUID, a value, a handle is an index of an attribute in the GATT table, and a handle to each property in a device is
The only one. The UUID contains information about the data type in the attribute table, which is key information that understands the meaning of each byte of a value in the attribute table.
There may be many properties in an GATT table, and these properties may have the same UUID.
2.2.2.2 characteristics
An attribute contains at least 2 attributes: An attribute is used to declare, and a property is used to hold the value of an attribute.
2.2.2.3 Descriptor
Any attribute in an attribute that is not defined as a property value is a descriptor. Descriptor when an additional property is provided to provide more information about the characteristics of the
It provides an example of a human-identifiable feature description.
2.2.2.4 Service
A service contains one or more attributes that are logically related to the collection body.
2.2.2.5 profile (data configuration file)
A profile file can contain one or more services, a profile file that contains the information needed for a service, or a peer device