Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "BluetoothSerial.h"
- #if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
- #error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
- #endif
- BluetoothSerial SerialBT;
- char chr_bt[10];
- int c_bt;
- String str_bt, buf_str_bt;
- unsigned long cur_time, old_time;
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(115200);
- SerialBT.begin("ESP32test"); //Bluetooth device name
- Serial.println("The device started, now you can pair it with bluetooth!");
- }
- void loop() {
- // put your main code here, to run repeatedly:
- while(SerialBT.available()){
- chr_bt[c_bt] = SerialBT.read();
- c_bt++;
- }
- cur_time = millis();
- if(cur_time - old_time >= 1000){
- for(int i=0; i<c_bt - 2; i++){
- str_bt += String(chr_bt[i]);
- }
- if(str_bt == "rst"){
- Serial.println("EEPROM ERASE");
- }
- str_bt = "";c_bt = 0;
- old_time = cur_time;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement