Basic flutter bluetooth questions

1,613

Bluetooth is a standard set of binary protocols for short-range wireless communication between devices.

Bluetooth “Classic” (BR/EDR) supports speeds up to about 24Mbps. Generally speaking, classic Bluetooth is mainly used for audio such as wireless telephone connections, wireless headphones and wireless speakers.

Bluetooth 4.0 introduced a low energy mode, “Bluetooth Low Energy” (BLE or LE, also known as “Bluetooth Smart”), that operates at 1Mbps. This mode allows devices to leave their transmitters off most of the time. As a result it is “Low Energy”. Bluetooth Low Energy is more often seen in wearable devices, smart IoT devices, fitness monitoring equipment, and battery-powered accessories.

BLE functionality is dominated by key/value pairs that create a Generic Attribute Profile (GATT).

BLE defines multiple roles that devices can play:

  • The Broadcaster (beacon) is a transmitter only application.
  • The Observer (scanner) is for receiver only applications.
  • Devices acting in the Peripheral role can receive connections.
  • Devices acting in the Central role can connect to Peripheral devices.

At the application level, Bluetooth is about Profiles built on the Bluetooth standard to more clearly define what kind of data a Bluetooth module is transmitting. The device’s application determines which profiles it must support. There are a number of profiles adopted by the Bluetooth SIG that allow for interoperability:

Classic Profiles: https://www.bluetooth.com/specifications/profiles-overview/

BLE Profiles: https://www.bluetooth.com/specifications/gatt/

BLE allows for Custom Services & Characteristics to be created. However, trying to develop both ends of the Bluetooth link at the same time is challenging especially if you are new to BLE. I would suggest you develop one end at a time. There are number of generic tools, such as a BLE Peripheral Simulator for Peripheral role and scanning and exploration tools for the Central Role, to help. There are also some developer boards such as micro:bit and puck-js that can be useful for learning to connect to devices from a phone.

Share:
1,613
afarre
Author by

afarre

Computer Engineer, 1996. Barcelona.

Updated on December 25, 2022

Comments

  • afarre
    afarre over 1 year

    I'm undertaking a new project involving flutter and bluetooth. For this I read a bit about it and tried a test project, but I still have questions I find no easy answer for.

    Firstly, BLE vs Bluetooth. BLE is nothing else than Bluetooth version 4, mostly used in IoT applications. It can run in mobile phones, but is there any compatibility issues? AKA, can a BLE device comunicate with a bluetooth device or do they both need to be using the same bluetooth version?

    This question comes from testing a flutter blue example and not discovering any devices, while my standard phone's bluetooth discovers 10+ devices (tested on a Meizu 16th). Do I need two devices with the same flutter bluetooth app in order for them to see each other and interact? I understand that in order to send info around, I will need two devices with the same flutter app, but for now I just wanted to test de scan device funtionality and returning 0 devices has thrown me off a bit.

    Secondly, I've seen some bluetooth packages around such as flutter_blue, flutter_bluetooth_serial (based on flutter_blue), flutter_reactive_ble and bluetooth. Which one do you think is best suited when taking into account my project is based on making a questionnaire -> sending it over bluetooth ->getting the filled questionnaires back via bluetooth?

    In short, my knowledge in flutter is rather basic, and an absolute 0 in bluetooth, so I'd appreciate some wise council in the current state of art of bluetooth in flutter so that I have a strong starting point and avoid common mistakes.

    EDIT: to complement @ukBaz's answer where he explains the theory behind bluetooth, if anyone finds himself using the flutter_blue example, just keep in mind to turn on both bluetooth and GPS in your device, for the example to work.

    With ukBaz's explanations and a working example, I can undertake this project, thanks.

    EDIT 2: explanation as to why location services are needed here.