Skip to content

Classic Blueooth

Basically, the Bluetooth protocol stack is split into two parts: a “controller stack” and a “host stack”. The controller stack contains the PHY, Baseband, Link Controller, Link Manager, Device Manager, HCI and other modules, and is used for the hardware interface management and link management. The host stack contains L2CAP, SMP, SDP, ATT, GATT, GAP and various profiles, and functions as an interface to the application layer, thus facilitating the application layer to access the Bluetooth system. The Bluetooth Host can be implemented on the same device as the Controller, or on different devices

The link controller operates in three major states: standby, connection and sniff. It enables multiple connections, and other operations, such as inquiry, page, and secure simple-pairing, and therefore enables Piconet and Scatternet. Below are the features:

Classic Bluetooth

– Device Discovery (inquiry, and inquiry scan) – Connection establishment (page, and page scan) – Multi-connections – Asynchronous data reception and transmission – Synchronous links (SCO/eSCO) – Master/Slave Switch – Adaptive Frequency Hopping and Channel assessment – Broadcast encryption – Authentication and encryption – Secure Simple-Pairing – Multi-point and scatternet management – Sniff mode – Connectionless Slave Broadcast (transmitter and receiver) – Enhanced power control – Ping

Example

ClassicBletooth.ino

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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
#include "BluetoothSerial.h" //Header File for Serial Bluetooth

BluetoothSerial bt; //Object for Bluetooth

int incoming;
int LED = 2;

void setup() {
  Serial.begin(115200);
  bt.begin("ESP32_LED_Control"); //Name of your Bluetooth Signal
  Serial.println("Bluetooth Device is Ready to Pair");
  pinMode (LED, OUTPUT);//Specify that LED pin is output
}

void loop() {

  if (bt.available()) //Check if we receive anything from Bluetooth
  {
    incoming = bt.read(); //Read what we recevive 
    Serial.print("Received:"); 
    Serial.println(incoming);
    if (incoming == 49)
        {
        digitalWrite(LED, HIGH);
        bt.println("LED turned ON");
        }

    if (incoming == 48)
        {
        digitalWrite(LED, LOW);
        bt.println("LED turned OFF");
        }     
  }
  delay(20);
}

Android APP link

Demo