Presentation is loading. Please wait.

Presentation is loading. Please wait.

Bluetooth.

Similar presentations


Presentation on theme: "Bluetooth."— Presentation transcript:

1 Bluetooth

2 Introduction The Bluetooth protocol operates at 2.4GHz in the same unlicensed ISM band which ZigBee and IEEE WLAN also exist. So BT decided to use frequency hopping to avoid collision. The newest version (BT 4.0/5.0, a.k.a. Bluetooth Low Energy – BLE), which has very different feature from earlier versions (a.k.a. BT classic). BT classic is aimed for streaming data. Application throughput is set between Mbps. BLE is for intermittent data. Application throughput is set <0.3Mbps. 9/17/2018 Chao GAO, VAMK

3 Versions BT 1.0 and 1.0B: first version
BT 1.1: Ratified as IEEE Received Signal Strength Indicator (RSSI) BT 1.2: Ratified as IEEE Faster connection and discovery Higher transmission speed (721kbps) BT 2.0/2.1 + EDR (Enhanced Data Rate using 𝜋 4 -DQPSK and 8DPSK) Bit rate increased to 2.1Mbps BT HS (High Speed) Data transfer increased to 24Mbps, colocated with (BT channel is only used for signalling. BT 4.0/4.1/4.2 + LE (low energy) BT 5.0: Internet of Things (IoT), range and speed enhancement from 4. 9/17/2018 Chao GAO, VAMK

4 Bluetooth Power Classes
4 classes of permitted power for a BT transmitter. In practice the range of a class 1 transmitter is just 20~30m. IEEE WLAN has a standard emisstion power of 20dBm. Class Max Power (mW) In dBm Range (m) 1 100 ? ~100 2 2.5 ~10 3 ~1 4 0.5 -3 ~0.5 An CR2032 battery is usually marked as 240mAh in capacity. [ If it is used to power a BT class 1 transmitter. How many hours the battery will be drained out? 9/17/2018 Chao GAO, VAMK

5 Classic Bluetooth: Topology
Master-slave topology, a BT piconet consists of 1 master and up to 7 active slaves. More slaves can be "parked". Piconets can be extended into scatternet. Parked slave M M M M S S S S M/S S S S S S S S Piconet Scatternet 9/17/2018 Chao GAO, VAMK

6 Classic BT: Modulation and Spectrum
Classic BT uses 1MHz channels from 2400MHz to 2480MHz. Channels are numbered from 1 to 79 and the center frequency can be calculated by 𝐹 𝑐 𝑀𝐻𝑧 =2402+(𝑁−1). Each channel bandwidth is 1MHz. To avoid collision, Frequency Hopping is used. If two BT piconets exist in the same area, what is the chance that two BT transmitters colllide each other? 9/17/2018 Chao GAO, VAMK

7 Classic BT: time-division duplex
The communication between Master/Slave is divided by time. Each time slot is 625us. Thus the overall FH is 1600 times/sec. Master can transmit multi-slot packets (3 and 5 slots, asymmetric). Hopping Channel 12 47 59 8 77 35 625us 366us 1616us time M time S time S 9/17/2018 Chao GAO, VAMK

8 Classic BT: Modulation and Spectrum
Version 1 modulation is GFSK. The two carriers are +/-75kHz from 𝐹 𝑐 . Versions 2/3 use DQPSK and 8DPSK to increase the bit rate. The communication fashion of master/slave is time-division-duplex. It can be either symmetric (M ↔ S) or asymmetric (M → S). In asymmetric, maximum data rate is 723.2kbps (v1), kbps (v2). In symmetric, maximum data rate is 433.9kbps (v1), kbps (v2). M S M S 9/17/2018 Chao GAO, VAMK

9 Bluetooth Low Energy (BLE)
Version 4.0/4.1/4.2 9/17/2018 Chao GAO, VAMK

10 BLE Spectrum and Channls
40 channels, each 2MHz wide. Channels 37,38,39 are advertising channels. Others are hopping data channels. Output power 10dBm. Transmission rate: 1Mbps. Modulation: GFSK. Power consumption at sleep: 1uA. Advertising channels are not overlapped with common WiFi channels. Channel 37, advertising Channel 38, advertising Channel 39, advertising 37 1 2 3 4 5 6 7 8 9 10 38 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 39 Freq. (GHz) 2.400 2.410 2.420 2.430 2.440 2.450 2.460 2.470 2.480 9/17/2018 Chao GAO, VAMK

11 BLE Network Topology The same, master-slave mode in star topologies.
Bluetooth forms only 1-hop network (piconet). The protocol stack doesn’t support multihop. A extended network is called scatternet, but so far there is no standard in protocol. slave master slave slave master slave Internet slave slave Point-to-point Star Internet 9/17/2018 Chao GAO, VAMK

12 BLE Connection Master broadcasts advertisement.
Slave nodes send connect request. Once connected, master informs the salve about hopping sequence and wake up time. Encryption is applied to data packet. Both nodes go to sleep between the transactions. From Advertisement to data transfer, it takes ~3ms time. Master Slave Advertisement Advertising Channel Connect request Poll Data Ack Data Channels Link Layer Terminate sleep sleep Ack 9/17/2018 Chao GAO, VAMK

13 BLE Terminology and GAP
A sensor is a slave or peripheral (generating data) A phone or master is a central. The communication between peripheral and central are standardized as GAP and GATT. GAP: General Access Profile, which defines the communication fashion of a BLE device. There are 2 ways: broadcasting and connecting. In Broadcasting mode, a sensor can be a broadcaster, a phone is then an observer. In connnecting mode, a sensor is a peripheral, a phone is then a central. 9/17/2018 Chao GAO, VAMK

14 GAP and GATT GATT: Generic ATTtribute profile, which decribes in detail how attributes (data) are transfered. GATT is organized in profile-service-characteristic structure. Profile is a collection of services for the same application. E.g., BLS is the profile for "Blood Pressure Service". Service are logic entities of characteristics. Each service is defined by a unique 16-bit ID called UUID. E.g., "Blood Pressure" service is assigned as 0x1810. Characteristics are detail values of entities. E.g., "Blood Pressure Measurement" is assigned as UUID 0x2A35 and the characteristic value is a 8-bit value. 9/17/2018 Chao GAO, VAMK

15 GAP and GATT A detailed GATT characteristics table can be seen: A detailed GATT service table can be seen: "Blood Pressure" service details can be seen: File=org.bluetooth.service.blood_pressure.xml. A characteristic value for "Blood Pressure Measurement" can be seen: File=org.bluetooth.characteristic.blood_pressure_measurement.xml. 9/17/2018 Chao GAO, VAMK

16 Broadcast address (6 octets)
BLE packet format BLE has one fixed packet format and two types: advertising and data. Advertising packets only sent in advertising channels. Preamble 1 octet Access address (4 octets) PDU (2-39 octets) CRC (3 octets) Broadcast address (6 octets) Broadcast data (0-31 octets) PDU header (2 octets) Payload PDU type 4 bits Reserved 2 bits TxAdd 1 bit RxAdd 1 bit Length 6 bits Reserved 6 bits 9/17/2018 Chao GAO, VAMK

17 BLE Programming on RPi A 3rd party library called "BlueZ" is available. Works only on Raspbian "Jessie". You need a BLE USB adapter. See From-A-Raspberry-Pi/. ~ $ wget ~ $ tar xvf bluez-5.44.tar.xz ~ $ cd bluez-5.44 ~ $ sudo apt-get update ~ $ sudo apt-get install -y libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev ~ $ ./configure ~ $ make ~ $ sudo make install 9/17/2018 Chao GAO, VAMK

18 BLE Programming on RPi #include <stdio.h>
#include <stdlib.h> #include <unistd.h> #include <sys/socket.h> #include <bluetooth/bluetooth.h> #include <bluetooth/hci.h> #include <bluetooth/hci_lib.h> int main(int argc, char **argv) { inquiry_info *ii = NULL; int max_rsp, num_rsp; int dev_id, sock, len, flags; int i; char addr[19] = { 0 }; char name[248] = { 0 }; dev_id = hci_get_route(NULL); sock = hci_open_dev( dev_id ); if (dev_id < 0 || sock < 0) { perror("opening socket"); exit(1); } len = 8; max_rsp = 255; flags = IREQ_CACHE_FLUSH; ii = (inquiry_info*)malloc(max_rsp * sizeof(inquiry_info)); num_rsp = hci_inquiry(dev_id, len, max_rsp, NULL, &ii, flags); if( num_rsp < 0 ) perror("hci_inquiry"); for (i = 0; i < num_rsp; i++) { ba2str(&(ii+i)->bdaddr, addr); memset(name, 0, sizeof(name)); if (hci_read_remote_name(sock, &(ii+i)->bdaddr, sizeof(name), name, 0) < 0) strcpy(name, "[unknown]"); printf("%s %s\n", addr, name); } free( ii ); close( sock ); return 0; } free( ii ); close( sock ); } 9/17/2018 Chao GAO, VAMK

19 BLE Programming on Embedded Sys.
CYPRESS co.ltd has PSoC®4 BLE as single-chip solution. "PSoC Creator" is a free Windows-based IDE. Within "PSoC creator" you can configure a BLE device. 9/17/2018 Chao GAO, VAMK

20 BLE Programming on Embedded Sys.
See "Getting Started with PSoC® 4 BLE" 9/17/2018 Chao GAO, VAMK


Download ppt "Bluetooth."

Similar presentations


Ads by Google