bluetooth protocol stack implementation - bluetooth

I want to know how to implement bluetooth protocol stack. Any good links or references will be appreciated. How and from where should I start
Thanks.

All the standards and specs are available from www.bluetooth.org. From the Core Specification to all the BlueTooth Profiles currently available. It might only take you a decade or so to assimilate that lot :)
If you want to play with a BlueTooth stack I would recommend a Linux platform with the Bluez stack. Plus you can check out the source for Bluez itself. There is a Bluez API in almost any programming language you could want.
For devices, aside from a PC dongle, or Bluetooth built in to a laptop, most mobile phones support an amazing number of bluetooth profiles, as do other mobile devices.
If you want to build your own thing, there is an Arduino platform with a BlueTooth module from BlueGiga, pretty sure it only does RFCOMM and SPP though.
There are numerous books, from a programmers POV. I chewed through Bluetooth Essentials for Programmers but found it pretty light-weight. Doesn't go much beyond making an RFCOMM link.
Good Luck!

Related

Open source implementations of BLE stack

Are there any open source implementations of BLE stack other than BlueZ and Bluedroid?
There are a couple of open source BLE stacks:-
NimBLE - Apache mynewt's Bluetooth Low Energy stack.
BTstack - BlueKitchen's Bluetooth stack.
Zephyr - small footprint kernel for resource constrained systems.
smallTooth - PIC only but may be adaptable to ARM.
Blessed - BLE stack targeting embedded bare-metal devices (nrf51 only).
I hope this helps.
I have used NimBLE, the Apache Mynewt Bluetooth stack in a product.
It works really well on the Nordic NRF51 and NRF52 chips, and is written portably, so it doesn't look like it would be too hard to port it to other platforms. The code is nice and clean. Mynewt also comes with secure boot and software upgrade.
Couple of links:
http://mynewt.apache.org/latest/network/ble/ble_intro/
https://www.youtube.com/watch?v=LCmwTWLcVBs
Hope this helps.
You have for example the Zephyr project: https://nexus.zephyrproject.org/content/sites/site/org.zephyrproject.zephyr/dev/subsystems/bluetooth/bluetooth.html.

Do i need Bluez when using a bluetooth dongle

i am new to Linux and Bluetooth. i know that the standard implementation of the bluetooth protocol stack is bluez. I know that alsa is not supporting bluez anymore and if you want to use audio over bluetooth, you need pulseaudio. so pulseaudio should support HSP/HFP since version 6 and bluez 5.x. Know i was wondering if i can connect a usb-dongle to my hardwareboard (raspberryPi) there is a serial connection to the board. is that right? so the Dongle has the BT-STack and you can use alsa audio over USB like an USB HEadset?
i hope someone can help me.
The answering this vast addressable question is not that easy. I have few hints which will help you to narrow down.
BlueZ is user layer stack to communicate or use the functionality of Linux Kernel Bluetooth subsystem and provides helpers to developers.
USB Dongle itself doesn't have any stack and I don't really understand your question in that sense. To brief, USB Bluetooth Dongle is just the hardware device with Bluetooth functionalities. To make it functional, you need Linux Kernel Bluetooth system support enabled and either you can directly make use of "socket" system calls to pair,connect etc., or use BlueZ to develop applications with API's
BlueZ itself doesn't provide API's for developers, instead it makes use of the DBus to provide methods, properties and signals with vast range functionalities. Check here
If you interested in Audio Playback using Bluetooth, then you should register your media player and audio sink with BlueZ with according media DBus Interfaces.
To add, I am currently developing a framework library to wrap the DBus functionality provided by BlueZ for friendly development of applications. Check this repo and it is currently in initial development phase.

Is Bluetooth 4.0+ BLE?

I am trying to identify which android phones support Bluetooth Low Energy and I am a bit confused on whether or not a device with BTv4.0+ is BLE compatible.
To be more precise, I am looking at the device Samsung Galaxy J5. According to http://www.gsmarena.com/samsung_galaxy_j5-7184.php, the bluetooth version is 4.1 but it doesn't mention anything about BLE.
According to the bluetooth specification:
"Bluetooth Low Energy (LE) (also called Bluetooth Smart or Version 4.0+ of the Bluetooth specification) is the power- and application-friendly version of Bluetooth that was built for the Internet of Things (IoT).". According to this I would presume that 4.0+ is BLE.
However if you see the specs of Samsung Galaxy S6 (http://www.gsmarena.com/samsung_galaxy_s6-6849.php) it mentions that it supports both BTv4.1 and BLE. It therefore distinguishes the two BT specifications.
Any information would be very helpful
Edit
Additional reference information for interested parties:
from bluetooth.org: Two flavors of Bluetooth The two most prevalent implementations of the specification are Bluetooth Basic Rate/Enhanced Data Rate (BR/EDR), which was adopted as version 2.0/2.1, and Bluetooth with low energy (LE), which was adopted as version 4.0/4.1/4.2. Each implementation has different use cases and each implementation uses a different chipset to meet essential hardware requirements. Dual-mode chipsets are also available for applications that include both use cases. - See more at: https://www.bluetooth.com/specifications/bluetooth-core-specification#sthash.7X7IrtWy.dpuf
Instead of relying on gsmarena with unreliable information, you can refer to Bluetooth SIG's official information.
Based on this Bluetooth SIG's announcement and this one, BLE is a core specification of Bluetooth 4.0. Bluetooth 4.1 and 4.2 also adopt this core specification.
However, all this still depends on whether the manufacturers implement the firmware. To keep track of all this, Bluetooth SIG maintains a list of devices currently supporting any profile (for example GATT).
This crossed my mind myself as I saw it as a pointless advancement until I saw the low energy bLE (bluetooth low energy) side of it. In my pastime I tinker with various electronics and with various BLE 4.x modules and their pro's and cons are HUGE.
All in all, BLE is better as Bluetooth pretty much is battery drain on the most robust of phones.
I found a nice little writeup (pretty simple yet comprehensive) here: http://www.argenox.com/bluetooth-low-energy-ble-v4-0-development/library/a-guide-to-selecting-a-bluetooth-chipset/
Do cut my answer short, as the bag you linked shows it as being "NFC" compatible, then yet, it's BLE 4.x. (That's Near Field Communication i.e. similar to your your contactless bank card). The v4.1, A2DP which you mention is how one "audio device talks to another" via bluetooth. (dvanced Audio Distribution Profile).
If you're really bored, there's a long list of other profiles (other than A2D):
https://en.wikipedia.org/wiki/List_of_Bluetooth_profiles
Hope this helps!
Happy bluetoothing!

Understanding Bluetooth profiles

I am trying to get my hands dirty on understanding Bluetooth (BT) for building a BT based speaker. When i read through Google on selecting the device, i came across CSR, TI and few more of them. After some research and talking to ppl, they suggested to go with TI (CC256x series). Few questions i have here are:
Can the same TI chip be used as Speaker, BT headset?
Can both SPP profiles and audio profiles co-exist together?
I am not sure as a application developer, i should know about BT firmware but wanted to get some insight on how BT works. Any good books?
Sorry for asking basic question here
-Prashanth
Yes! Audio transfer requires a high data rate which means you have to use a chip that supports bluetooth classic and not low energy (ble). The CC256x offers both a bluetooth classic and a dual bluetooth (classic + low energy) version, both will work.
Yes! SPP and audio profiles are implemented on different streams and it is normal for them to co-exist.
Good books on bluetooth classic are hard to come by, one of the best places to start is the Apple developer documentation (linked down below). The developer area of bluetooth.org is also a good place to start.
https://developer.apple.com/library/mac/documentation/DeviceDrivers/Conceptual/Bluetooth/BT_Intro/BT_Intro.html
https://developer.bluetooth.org/

Tools for bluetooth monitoring

For my project I have an Android phone and an Arduino device that communicate via Bluetooth. I was wondering if anyone knows any software tools I could use to monitor a bluetooth communications between two devices. Something like a packet eavesdropping. Preferably for Linux.
Take a look at ubertooth one. In the linked webpage there are instructions on how to build the dongle, as well as links to shops selling assembled dongles may be bought. Ubertooth one should work well with Kismet, and thus in Linux, by using a BT plugin (disclaimer: I have no personal experience on this).
Sounds like you are after a Bluetooth sniffer.
Bad news: They are almost exclusively Windows OS based and cost mega-$.
http://www.fte.com/products/bluetooth.aspx
If you were using BlueZ for one side of the communication you could use the BlueZ HCIDUMP app and Wireshark.
I don't think anyone has made a Linuz/Bluez Sniffer - could be wrong.

Resources