Skip to content

Commit 00020e7

Browse files
committed
📝 Add Microchip Transparent UART
1 parent 113a1f3 commit 00020e7

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

.github/workflows/platformio-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
os: [ ubuntu-latest ]
2222
example:
2323
- "SerialToSerialBLE"
24+
- "SerialToSerial_TransparentUART"
2425
boards:
2526
- [ esp32dev, esp32-s3-devkitc-1, esp32-c3-devkitm-1 ]
2627
nimble: [ false, true ]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include <BLESerial.h>
2+
3+
// FOR ETL: Uncomment the following lines
4+
// #include <Embedded_Template_Library.h>
5+
// #include <etl/queue.h>
6+
// #include <etl/circular_buffer.h>
7+
8+
String device_name = "ESP32-BLE-Slave";
9+
10+
BLESerial SerialBLE;
11+
// If you are using older version of Arduino IDE, you may need to use
12+
// empty template argument (<>), due to the old C++ compiler version (<=std=c++17).
13+
// https://www.cppreference.com/w/cpp/language/ctad.html
14+
//
15+
// Uncomment the line below if you are using an older version of Arduino IDE/C++ compiler
16+
// BLESerial<> SerialBLE;
17+
18+
// FOR ETL: Uncomment one of the following lines
19+
// BLESerial<etl::queue<uint8_t, 255, etl::memory_model::MEMORY_MODEL_SMALL>> SerialBLE;
20+
// OR
21+
// BLESerial<etl::circular_buffer<uint8_t, 255>> SerialBLE;
22+
23+
void setup() {
24+
BLEDevice::init(device_name);
25+
BLEServer* pServer = BLEDevice::createServer();
26+
27+
// Transparent UART Service
28+
// https://developerhelp.microchip.com/xwiki/bin/view/applications/ble/android-development-for-bm70rn4870/transparent-uart-service-for-bm70rn4870/
29+
auto pService = pServer->createService("49535343-FE7D-4AE5-8FA9-9FAFD205E455");
30+
31+
auto pRxCharacteristic = pService->createCharacteristic("49535343-1E4D-4BD9-BA61-23C647249616", BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_WRITE_NR | BLECharacteristic::PROPERTY_NOTIFY);
32+
auto pTxCharacteristic = pService->createCharacteristic("49535343-8841-43F4-A8D4-ECBE34729BB3", BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_NOTIFY);
33+
34+
SerialBLE.begin(pRxCharacteristic, pTxCharacteristic);
35+
}
36+
37+
void loop() {
38+
if (Serial.available()) {
39+
SerialBLE.write(Serial.read());
40+
SerialBLE.flush();
41+
}
42+
if (SerialBLE.available()) {
43+
Serial.write(SerialBLE.read());
44+
}
45+
}

0 commit comments

Comments
 (0)