Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i need to make ios swift app that receive data from esp32 that use "bluetoothserial.h" #133

Open
digerati73 opened this issue Jul 27, 2023 · 0 comments

Comments

@digerati73
Copy link

#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"); }

}

i need to receive data from above esp32 code at ios app coded by swift or swiftUI
but i failed...

i found this "react-native-bluetooth-serial" project.

can i receive data from above esp32 code using "react-native-bluetooth-serial" program ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant