Guest User

Untitled

a guest
May 17th, 2021
64
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. BluetoothSerial bluetoothSerial;
  2.  
  3. Serial.println("Initializing Bluetooth...");
  4. if(!bluetoothSerial.begin("ESP32", true)) {
  5. Serial.println("Error initializing Bluetooth");
  6. } else {
  7. //bluetoothSerial.enableSSP();
  8. bluetoothSerial.onConfirmRequest([](uint32_t num_val){
  9. Serial.println("BT Confirm Request");
  10. });
  11. bluetoothSerial.onData([](const uint8_t *buffer, size_t size){
  12. Serial.println("BT Data");
  13. });
  14. bluetoothSerial.onAuthComplete([](boolean success){
  15. Serial.println("BT AuthComplete");
  16. });
  17. bluetoothSerial.setPin("1234");
  18. }
  19.  
  20. ... in loop():
  21. if(bluetoothSerial.available()) {
  22. Serial.write(bluetoothSerial.read());
  23. }
RAW Paste Data