Actually I meant the sample that comes with the library (without any modifications)
#include "BleSerialPeripheralRK.h"
SerialLogHandler logHandler;
SYSTEM_THREAD(ENABLED);
// First parameter is the transmit buffer size, second parameter is the receive buffer size
BleSerialPeripheralStatic<256, 256> bleSerial;
const unsigned long TRANSMIT_PERIOD_MS = 2000;
unsigned long lastTransmit = 0;
int counter = 0;
void setup() {
Serial.begin();
// This must be called from setup()!
bleSerial.setup();
// If you don't have any other services to advertise, just call advertise().
// Otherwise, call getServiceUuid() to get the serial service UUID and add that to your
// custom advertising data payload and call BLE.advertise() yourself with all of your necessary
// services added.
bleSerial.advertise();
}
void loop() {
// This must be called from loop() on every call to loop.
bleSerial.loop();
// Print out anything we receive
if(bleSerial.available()) {
String s = bleSerial.readString();
Log.info("received: %s", s.c_str());
}
if (millis() - lastTransmit >= TRANSMIT_PERIOD_MS) {
lastTransmit = millis();
// Every two seconds, send something to the other side
bleSerial.printlnf("testing %d", ++counter);
Log.info("counter=%d", counter);
}
}
This is only advertises the UUID: 6e400001-b5a3-f393-e0a9-e50e24dcca9e service but once connected it doesn’t expose it
nRF Connect and Bluefruit app can only see these four services
BleAdvertisingData data; // prepare a fresh/empty advertising data instance
data.appendLocalName("myName"); // give the device a name to advertise (can be anywhere in the bundle)
data.appendServiceUUID(bleSerial.getServiceUuid()); // add the UUID that is created by the bleSerial object
// optionally add any additional service UUIDs
// optionally add any custom data you want (if it still fits)
BLE.advertise(&data);