Skip to content

Commit 94abf9f

Browse files
author
Victor Tchistiak
committed
20190916 - initial: Add example app for Master mode
1 parent bc2cafc commit 94abf9f

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//This example code is in the Public Domain (or CC0 licensed, at your option.)
2+
//By Evandro Copercini - 2018
3+
//
4+
//This example creates a bridge between Serial and Classical Bluetooth (SPP)
5+
//and also demonstrate that SerialBT have the same functionalities of a normal Serial
6+
7+
#include "BluetoothSerial.h"
8+
9+
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
10+
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
11+
#endif
12+
13+
BluetoothSerial SerialBT;
14+
15+
uint8_t address[6] = {0xAA, 0xBB, 0xCC, 0x11, 0x22, 0x33};
16+
String MACadd = "AA:BB:CC:11:22:33";
17+
String name = "OBDII";
18+
char *pin = "1234"; //<- standard pin would be provided by default
19+
20+
void setup() {
21+
Serial.begin(115200);
22+
//SerialBT.setPin(pin);
23+
SerialBT.begin("ESP32test", true);
24+
//SerialBT.setPin(pin);
25+
Serial.println("The device started in master mode, make sure remote BT device is on!");
26+
//delay(2000);
27+
SerialBT.connect(address);
28+
//SerialBT.connect(name);
29+
}
30+
31+
void loop() {
32+
if (Serial.available()) {
33+
SerialBT.write(Serial.read());
34+
}
35+
if (SerialBT.available()) {
36+
Serial.write(SerialBT.read());
37+
}
38+
delay(20);
39+
}

0 commit comments

Comments
 (0)