how can i make a ios bluetooth classic program? is this Mission Impossible?

i must make a code that ios app communicate with esp32 module over bluetooth classic .

i have been searching for several weeks...

but i didn't find out sample code for bluetooth classic.

i found one code that use External Accessory Framework. but this needs a registration for that device

some one says that i can't this. because ESP32 Module can't be registered .

and i found another one it is coded by reactive native. but finally, this one use a MFi(Made For Iphone) that use External Accessory Framework.

i guess..

is it impossilbe that making a ios app that communicate with other device over bluetooth classic ?

so, now i am finding some apps that can communicate esp32 module that is coded by arduino IDE over bluetooth classic, and this arduino app can communicate with android bluetooth classic terminal app.

please help me

Replies

The is no API for Bluetooth Classic on iOS. You cannot do this.

Add a Comment

What exactly are you trying to accomplish? That sample code and video shows how Core Bluetooth supports GATT over Classic, which means basically the same capabilities as GATT over LE. But Classic-only profiles (such as, for example, profiles built on the Serial Port Profile) are not supported.

  • BTW, on this forum it’s preferable to keep the discussion going in replies rather than comments.

  • my ios app receive several format data from ESP32 Module that use Bluetooth Classic.(it is arduino file made by arduinoIDE) after receiving data, i just show data as chart at my ios app, and save it to local sqlite3 db at ios phone.

    i already made this code with Bluetooth Low energy , but my customer want me to make code with Bluetooth classic the reason of this demand is many phone use rather bluetooth classic phones than bluetooth low energy phones.

  • if it is , then i can make a ios app that Gatt over classic,

    so i can receive data that was sent by ESP32 which use bluetooth classic ( arduino file includes "bluetoothSerial.h") if i made a code that use gatt over classic ?

    is there any code for this style ?

Add a Comment

but my customer want me to make code with Bluetooth classic the reason of this demand is many phone use rather bluetooth classic phones than bluetooth low energy phones

Not clear what you mean. All iPhones support Bluetooth LE. Or is your goal to receive data from non-Apple phones? How does your ESP32 module fit into this?

i already made this code with Bluetooth Low energy

Then your iOS-side code is basically done. You need to implement a GATT server on the peripheral side that it can talk to, regardless of the transport.

#include "BluetoothSerial.h"

BluetoothSerial SerialBT;
bool isconnected = false;

void Bt_Status (esp_spp_cb_event_t event, esp_spp_cb_param_t *param) { if (event == ESP_SPP_SRV_OPEN_EVT) { Serial.println ("Bluetooth: Connected"); isconnected = true; } else if (event == ESP_SPP_CLOSE_EVT ) { Serial.println ("Bluetooth: Disconnected"); isconnected = false; } }

void setup() { Serial.begin(115200);
while (!Serial);
Serial.print("\n"); Serial.println("dbg> ESP32 Test program. Start ...");

SerialBT.register_callback (Bt_Status);
Serial.println("The device started, now you can pair it with bluetooth!"); if(!SerialBT.begin("ESP32")){
Serial.println("An error occurred initializing Bluetooth"); }else{ Serial.println("Bluetooth initialized. Bluetooth Started!"); Serial.println("Bluetooth device name(ESP32), Ready to pair..."); } }

void loop() {

if (Serial.available()){
char command = Serial.read();
Serial.print("Recived command : "); Serial.print(command); Serial.print(", ");

if(command == '3'){
Serial.println("REQ#3:");
cmd_tx_result_data1(); //test1: make string & TX data: swing raw data, bluetooth
} else{
Serial.println("Wrong command(3)");
Serial.println("Usage: ");
Serial.println(" REQ#3: make string & TX data"); }

}

}

void cmd_tx_result_data1() {
String tx_data1 = "here is some format code";
if (isconnected) {
Serial.print("dbg> tx_data1 = "); Serial.println(tx_data1); SerialBT.print(tx_data1);
} else { Serial.println ("dbg> Bluetooth: Client Not Connected"); }

}

  • upper code is communication bluetooth classic part of esp32 bluetooth classic communication.

    i need to make a ios app code(swift or swiftUI) to receive data sent from above esp32 code.

Add a Comment

The is no API for Bluetooth Classic on iOS

What I should have written was "there is no API for things that you actually want to use, like serial ports, on Bluetooth Classic". Yes you can do GATT over classic - I had forgotten about that - but I'm not actually aware of any practical use for it.

arduino file includes "bluetoothSerial.h"

That doesn't look promising.

Pro tip: when posting code, use the “code block” formatting feature to make it readable, like this:

void Bt_Status (esp_spp_cb_event_t event, esp_spp_cb_param_t *param) {
    if (event == ESP_SPP_SRV_OPEN_EVT) {
        Serial.println ("Bluetooth: Connected");
        /* ... */
    }
}

That doesn't look promising.

Indeed. That code is using Bluetooth as a plain old serial port, which isn’t compatible with Core Bluetooth on iOS.

Here's one way of doing it. https://youtu.be/PXFC-Y7eRiE

esp32 module using bluetooth_classic can find and connect with MacBook M2 Pro 2023 but iphone mini 13 can't connect with this esp32 module.

how can Macbook m2 pro 2023 find and connect with esp32 ?

just like macbook m2 pro , i want esp32 to communicate with iphone mini 13 just like macbook m2 pro.

If you‘re serious about communication between iOS and ESP32, use BLE’s L2Cap Channels. They offer a serial-like stream abstraction over BLE and work fine from both MacOS, iOS, and Android.