esp32:ble_serial_v1
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| esp32:ble_serial_v1 [2019/09/30 08:59] – aistis | esp32:ble_serial_v1 [2019/10/01 21:55] (current) – aistis | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ESP32 bluetooth BLE serial/UART example - forward: serial <=> BLE | ESP32 bluetooth BLE serial/UART example - forward: serial <=> BLE | ||
| + | |||
| + | {{: | ||
| <code cpp> | <code cpp> | ||
| Line 6: | Line 8: | ||
| #include < | #include < | ||
| #include < | #include < | ||
| + | |||
| BLECharacteristic *pCharacteristic; | BLECharacteristic *pCharacteristic; | ||
| bool deviceConnected = false; | bool deviceConnected = false; | ||
| - | + | ||
| - | #define SERVICE_UUID | + | #define SERVICE_UUID |
| - | #define CHARACTERISTIC_UUID_RX " | + | #define CHARACTERISTIC_UUID_RX " |
| - | #define CHARACTERISTIC_UUID_TX " | + | #define CHARACTERISTIC_UUID_TX " |
| + | |||
| class MyServerCallbacks: | class MyServerCallbacks: | ||
| void onConnect(BLEServer* pServer) { deviceConnected = true; Serial.println(" | void onConnect(BLEServer* pServer) { deviceConnected = true; Serial.println(" | ||
| void onDisconnect(BLEServer* pServer) { deviceConnected = false; Serial.println(" | void onDisconnect(BLEServer* pServer) { deviceConnected = false; Serial.println(" | ||
| }; | }; | ||
| + | |||
| class MyCallbacks: | class MyCallbacks: | ||
| void onWrite(BLECharacteristic *pCharacteristic) { | void onWrite(BLECharacteristic *pCharacteristic) { | ||
| Line 25: | Line 27: | ||
| } | } | ||
| }; | }; | ||
| + | |||
| void setup() { | void setup() { | ||
| Serial.begin(115200); | Serial.begin(115200); | ||
| Line 40: | Line 42: | ||
| Serial.println(" | Serial.println(" | ||
| } | } | ||
| + | |||
| void loop() { | void loop() { | ||
| if (deviceConnected) { | if (deviceConnected) { | ||
esp32/ble_serial_v1.1569823181.txt.gz · Last modified: by aistis
