W!o+ 的《小伶鼬工坊演義》︰樹莓派 3 三兩事之藍牙篇【上】

既然因為 UART 的問題將樹莓派 3 的速度調降,以求『藍牙』之『共存』,也已知道可能影響到『藍牙』的操作性,將如之何哉?由於

藍牙

藍牙英語:Bluetooth),一種無線技術標準,用來讓固定與行動裝置,在短距離間交換資料,以形成個人區域網路(PAN)。其使用短波特高頻(UHF)無線電波,經由2.4至2.485 GHz的ISM頻段來進行通信[1]。1994年由電信商愛利信(Ericsson)發展出這個技術[2]。它最初的設計,是希望建立一個RS-232資料線的無線通訊替代版本。它能夠連結多個裝置,克服同步的問題。

藍牙技術目前由藍牙技術聯盟(SIG)來負責維護其技術標準。截至2013年為止,SIG已擁有超過20,000間公司成員,其成員的領域分布在電信、電腦、網路與消費性電子產品上[3]IEEE曾經將藍牙技術標準化為IEEE 802.15.1,但是這個標準已經不再繼續使用。

藍牙Bluetooth)一詞是斯堪的納維亞語言詞彙Blåtand/Blåtann的英語化。這個詞的來源是10世紀丹麥和挪威國王藍牙哈拉爾丹麥語Harald Blåtand Gormsen),借國王的綽號「Blåtand」當名稱,[4]直接翻譯成中文爲「藍牙」(blå=藍,tand=牙)。在中文圈,「藍牙」又稱為「藍芽」。2006年,藍牙技術聯盟組織已將全球中文譯名統一改採直譯為「藍牙」,並註冊為該組織的註冊商標

藍牙的標誌是盧恩字母 Runic letter ior.svgHagall,ᚼ)和 Runic letter berkanan.svgBjarkan,ᛒ)的組合,也就是Harald Blåtand的首字母HB的合寫。

……

藍牙4.0

  • 藍牙4.0是Bluetooth SIG於2010年7月7日推出的新的規範。其最重要的特性是支援省電;
  • Bluetooth 4.0,協定組成和當前主流的Bluetooth h2.x+EDR、還未普及的Bluetooth h3.0+HS不同,Bluetooth 4.0是Bluetooth從誕生至今唯一的一個綜合協定規範,
  • 還提出了「低功耗藍牙」、「傳統藍牙」和「高速藍牙」三種模式。
  • 其中:高速藍牙主攻資料交換與傳輸;傳統藍牙則以資訊溝通、裝置連線為重點;藍牙低功耗顧名思義,以不需占用太多頻寬的裝置連線為主。前身其實是 NOKIA開發的Wibree技術,本是作為一項專為行動裝置開發的極低功耗的移動無線通信技術,在被SIG接納並規範化之後重新命名為 Bluetooth Low Energy(後簡稱低功耗藍牙)。這三種協定規範還能夠互相組合搭配、從而實作更廣泛的應用模式,此外,Bluetooth 4.0還把藍牙的傳輸距離提升到100米以上(低功耗模式條件下)。
  • 分Single mode與Dual mode。
  • Single mode只能與BT4.0互相傳輸無法向下相容(與3.0/2.1/2.0無法相通);Dual mode可以向下相容可與BT4.0傳輸也可以跟3.0/2.1/2.0傳輸
  • 超低的峰值、平均和待機模式功耗,覆蓋範圍增強,最大範圍可超過100米。
  • 速度:支援1Mbps資料傳輸率下的超短封包,最少8個八組位,最多27個。所有連線都使用藍牙2.1加入的減速呼吸模式(sniff subrating)來達到超低工作迴圈。
  • 跳頻:使用所有藍牙規範版本通用的自適應跳頻,最大程度地減少和其他2.4 GHz ISM頻段無線技術的串擾。
  • 主控制:可以休眠更長時間,只在需要執行動作的時候才喚醒。
  • 延遲:最短可在3毫秒內完成連線設定並開始傳輸資料。
  • 健壯性:所有封包都使用24-bit CRC校驗,確保最大程度抵禦干擾。
  • 安全:使用AES-128 CCM加密演算法進行封包加密和認證。
  • 拓撲:每個封包的每次接收都使用32位元尋址,理論上可連線數十億裝置;針對一對一連線最佳化,並支援星形拓撲的一對多連線;使用快速連線和斷開,資料可以在網狀拓撲內轉移而無需維持複雜的網狀網路。

藍牙4.1

  • 藍牙4.1是藍牙技術聯盟於2013年底推出的新的規範,其目的是為了讓 Bluetooth Smart 技術最終成為物聯網(Internet of Everything)發展的核心動力。
  • 此版本為藍牙4.0的軟體更新版本,搭載藍牙4.0裝置的終端可通過軟體更新獲得此版本。
  • 對於開發人員而言,該更新是藍牙技術發展史上一項重要的進步。該更新提供了更高的靈活性和掌控度,讓開發人員能創造更具創新並催化物聯網(IOT)發展的產品。
  • 支援多裝置連接。
  • 智慧連接:增加設置裝置間連接頻率的支援。製造商可以對裝置設置連接進行設置,使得裝置可以更加智慧的控制裝置電量。

藍牙4.2

───

 

實在是個『大規範』,而且與時變遷!根本無從說起,故於此處先列出重要的資訊來源,以備不時之需︰

【 Linux Kernel 官方藍牙之標準堆疊】

BlueZ

Official Linux Bluetooth protocol stack

About

bluetooth

The Bluetooth wireless technology is a worldwide specification for a small-form factor, low-cost radio solution that provides links between mobile computers, mobile phones, other portable handheld devices, and connectivity to the Internet. The specification is developed, published and promoted by the Bluetooth Special Interest Group (SIG).

features

BlueZ provides support for the core Bluetooth layers and protocols. It is flexible, efficient and uses a modular implementation. It has many interesting features:

  • Complete modular implementation
  • Symmetric multi processing safe
  • Multithreaded data processing
  • Support for multiple Bluetooth devices
  • Real hardware abstraction
  • Standard socket interface to all layers
  • Device and service level security support

Currently BlueZ consists of many separate modules:

  • Bluetooth kernel subsystem core
  • L2CAP and SCO audio kernel layers
  • RFCOMM, BNEP, CMTP and HIDP kernel implementations
  • HCI UART, USB, PCMCIA and virtual device drivers
  • General Bluetooth and SDP libraries and daemons
  • Configuration and testing utilities
  • Protocol decoding and analysis tools

The current set of supported profiles is available here.

───

 

【 Debian 之藍牙指南】

BluetoothUser

Using Bluetooth in a Debian system

Introduction

We assume you have a Bluetooth adapter in your computer and a Bluetooth device (such as a mobile phone or PDA). This documents describes what you need to do to use Bluetooth to communicate with other Bluetooth devices.

The steps described below are required before you can use the services Bluetooth offers. Once you have setup Bluetooth, you can for example

  • exchange data with devices, such as sending music or videos to/from your phone
  • use a mobile phone to give your computer mobile internet access
  • use Bluetooth peripherals with your computer, such as a Bluetooth wireless mouse

See the links below for details.

───

 

【樹莓派 3 之藍牙官方設定】

by real_ale » Tue Mar 01, 2016 12:04 pm
How do i setup bluetooth on RPi 3.

 

by Douglas6 » Tue Mar 01, 2016 12:13 pm
Code: Select all
sudo apt-get install pi-bluetooth

seems to be the best way

───

 

【目前 Jessie 之藍牙版本】

pi@raspberrypi ~ apt-cache show bluez Package: bluez Version: 5.23-2+rpi1 Architecture: armhf Maintainer: Debian Bluetooth Maintainers <pkg-bluetooth-maintainers@lists.alioth.debian.org> Installed-Size: 2588 Depends: libc6 (>= 2.15), libdbus-1-3 (>= 1.1.1), libglib2.0-0 (>= 2.28.0), libreadline6 (>= 6.0), libudev1 (>= 196), init-system-helpers (>= 1.18~), kmod, udev (>= 170-1), lsb-base, dbus Conflicts: bluez-audio (<= 3.36-3), bluez-utils (<= 3.36-3) Breaks: udev (<< 170-1) Replaces: bluez-audio (<= 3.36-3), bluez-input, bluez-network, bluez-serial, bluez-utils (<= 3.36-3), udev (<< 170-1) Multi-Arch: foreign Homepage: http://www.bluez.org Priority: optional Section: admin Filename: pool/main/b/bluez/bluez_5.23-2+rpi1_armhf.deb Size: 595204 SHA256: f50a38dc3fe08e8509ea748a174e2f715ffd5618fc1552c7038d4639fbb2262e SHA1: d88c98a72920646177c059ab09a78a85a0f77370 MD5sum: 10cd0648f9cf2ceab7848e5775b2800e Description: Bluetooth tools and daemons  This package contains tools and system daemons for using Bluetooth devices.  .  BlueZ is the official Linux Bluetooth protocol stack. It is an Open Source  project distributed under GNU General Public License (GPL). Description-md5: ef25d6a9f4a57e78f32faa7b58ef4e59  Package: bluez Source: bluez (5.23-2) Version: 5.23-2+b1 Architecture: armhf Maintainer: Debian Bluetooth Maintainers <pkg-bluetooth-maintainers@lists.alioth.debian.org> Installed-Size: 2481 Depends: libc6 (>= 2.15), libdbus-1-3 (>= 1.1.1), libglib2.0-0 (>= 2.28.0), libreadline6 (>= 6.0), libudev1 (>= 196), init-system-helpers (>= 1.18~), kmod, udev (>= 170-1), lsb-base, dbus Conflicts: bluez-audio (<= 3.36-3), bluez-utils (<= 3.36-3) Breaks: udev (<< 170-1) Replaces: bluez-audio (<= 3.36-3), bluez-input, bluez-network, bluez-serial, bluez-utils (<= 3.36-3), udev (<< 170-1) Multi-Arch: foreign Homepage: http://www.bluez.org Priority: optional Section: admin Filename: pool/main/b/bluez/bluez_5.23-2+b1_armhf.deb Size: 598842 SHA256: 1d63e2abab63f2109f2e0b80ecb1f6e7fed2c595e716390cbe4ea721e5f0e6d7 SHA1: 5187964d89ce428b99fd1f87203c54546e5e34ee MD5sum: 66b230ec94a4dff426d8354315f917bf Description: Bluetooth tools and daemons  This package contains tools and system daemons for using Bluetooth devices.  .  BlueZ is the official Linux Bluetooth protocol stack. It is an Open Source  project distributed under GNU General Public License (GPL). Description-md5: ef25d6a9f4a57e78f32faa7b58ef4e59  pi@raspberrypi ~ 

 

【 BlueZ 5.23 之發行摘要】

Release of BlueZ 5.23

This is mostly a bug-fix release with fixes for concurrent authorization attempts (for untrusted devices), HID, uHID, OBEX, MAP and AVRCP. We now also have better support for AVCTP/AVRCP decoding with btmon.

On the Android side a notable enhancement is the ability to take advantage of kernel whitelist support to enable LE passive scanning (something that’s available from Linux Kernel release 3.17 onward)..

bluez-5.23.tar.xz

───

 

同時確認當下

【藍牙mini- UART 之連接速度 115200 】

pi@raspberrypi ~ $ more /lib/systemd/system/hciuart.service
[Unit]
Description=Configure Bluetooth Modems connected by UART
ConditionPathIsDirectory=/proc/device-tree/soc/gpio@7e200000/bt_pins
Before=bluetooth.service
After=dev-ttyS0.device

[Service]
Type=forking
ExecStart=/usr/bin/hciattach /dev/ttyS0 bcm43xx 115200 noflow -

[Install]
WantedBy=multi-user.target

 

以及參考

【 man hciattach 手冊】

HCIATTACH(1)              Linux System Administration             HCIATTACH(1)

NAME
       hciattach - attach serial devices via UART HCI to BlueZ stack

SYNOPSIS
       hciattach  [-b] [-n] [-p] [-t timeout] [-s speed] [-l] [-r] tty type|id
       speed flow bdaddr

DESCRIPTION
       Hciattach is used to attach a serial UART to the Bluetooth stack as HCI
       transport interface.

OPTIONS
       -b     Send break.

       -n     Don't detach from controlling terminal.

       -p     Print the PID when detaching.

       -t timeout
              Specify an initialization timeout.  (Default is 5 seconds.)
……

 

大膽踏上征途的耶!!??