void onBleReceived(BLECharacteristic *pCharacteristic) {
std::string rxValue = pCharacteristic->getValue();
static String bleInputString = "";
Serial.print("onBleReceived: ");
if (rxValue.length() > 0) {
for (int i = 0; i < rxValue.length(); i++) {
bleInputString += rxValue[i];
if (rxValue[i] == '\n') {
Serial.println(bleInputString);
/*You can do something with the information you receive*/
bleInputString = ""; //Clear bleInputString.
}
}
}
}
#ifndef __BLUETOOTHSERVICE_H
#define __BLUETOOTHSERVICE_H
#include "Arduino.h"
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>
class BLEServer;
class BLECharacteristic;
class BLEServerCallbacks;
void bleSetup();
void bleStop();
void bleSend(std::string msg);
extern void onBleReceived(BLECharacteristic *pCharacteristic);
#endif