EasyManuals Logo

Freenove ESP32 User Manual

Default Icon
159 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #129 background image
Need support? support@freenove.com
127
Chapter 13 BLE
www.freenove.com
BluetoothService.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "BluetoothService.h"
// See the following for generating UUIDs:
// https://www.uuidgenerator.net/
#define SERVICE_UUID "0000ffe0-0000-1000-8000-00805f9b34fb" // UART service UUID
#define CHARACTERISTIC_UUID_RX "0000ffe1-0000-1000-8000-00805f9b34fb"
#define CHARACTERISTIC_UUID_TX "0000ffe1-0000-1000-8000-00805f9b34fb"
BLEServer *pServer = NULL;
BLECharacteristic *pTxCharacteristic;
bool isBleConnected = false;
bool oldBleConnected = false;
uint8_t txValue = 0;
class MyServerCallbacks : public BLEServerCallbacks {
void onConnect(BLEServer *pServer) {
isBleConnected = true;
// connecting
if (isBleConnected && !oldBleConnected) {
// do stuff here on connecting
oldBleConnected = isBleConnected;
Serial.println("Ble Connect");
}
};
void onDisconnect(BLEServer *pServer) {
isBleConnected = false;
// disconnecting
if (!isBleConnected && oldBleConnected) {
oldBleConnected = isBleConnected;
Serial.println("Ble Disconnect");
delay(500); // give the bluetooth stack the chance to get things ready
pServer->startAdvertising(); // restart advertising
}
}
};
class MyCallbacks : public BLECharacteristicCallbacks {
void onWrite(BLECharacteristic *pCharacteristic) {
onBleReceived(pCharacteristic);
}
};

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Freenove ESP32 and is the answer not in the manual?

Freenove ESP32 Specifications

General IconGeneral
BrandFreenove
ModelESP32
CategoryComputer Hardware
LanguageEnglish

Related product manuals