Hi everyone, I'm developing an application in Windows 10 that tries to connect with an Arduino 33 BLE Nano Rev2. This is the test code:
#include <ArduinoBLE.h>
// Definición de UUIDs (Universal Unique Identifiers)
#define SERVICE_UUID "19b10000-e8f2-537e-4f6c-d104768a1214" // UUID del Servicio
#define CHARACTERISTIC_UUID "19b10001-e8f2-537e-4f6c-d104768a1214" // UUID de la Característica
// Crear el servicio
BLEService myService(SERVICE_UUID);
// Crear la característica con permiso de lectura y escritura
BLECharacteristic myCharacteristic(CHARACTERISTIC_UUID, BLERead | BLEWrite, 20);
void setup() {
// Inicializar la comunicación serie
Serial.begin(9600);
while (!Serial);
// Inicializar el periférico BLE
if (!BLE.begin()) {
Serial.println("Fallo al iniciar el periférico BLE!");
while (1);
}
// Configurar el nombre del dispositivo BLE
BLE.setLocalName("Nano 33 BLE");
myService.addCharacteristic(myCharacteristic); // Añadir la característica al servicio
BLE.addService(myService); // Añadir el servicio
BLE.setAdvertisedServiceUuid(SERVICE_UUID); // Hacer que el servicio sea visible
// Inicializar el valor de la característica
myCharacteristic.writeValue("Hola Mundo!");
// Empezar a anunciar el dispositivo BLE
BLE.advertise();
Serial.println("Dispositivo BLE listo para ser conectado!");
}
void loop() {
// Escuchar por conexiones de clientes
BLEDevice central = BLE.central();
// Si un dispositivo se conecta
if (central) {
Serial.print("Conectado a: ");
Serial.println(central.address());
// Mientras el dispositivo esté conectado
while (central.connected()) {
// Verificar si la característica ha sido escrita
if (myCharacteristic.written()) {
// Leer el valor que fue escrito
// newValue = myCharacteristic.value();
String newValue = reinterpret_cast<const char *> (myCharacteristic.value());
Serial.print("Nuevo valor recibido: ");
Serial.println(newValue);
}
}
// Si se desconecta
Serial.print("Desconectado de: ");
Serial.println(central.address());
}
}
The Nano 33 BLE creates the service and it is detected by a mobile phone with the Light Blue App or the nrF Connect. When I do it with a Windows application developed with C++ Builder v12, it detects the basic services of the Nano 33, but not the newly created service. Do you know how to make a service created from an Arduino visible from Windows? Thanks!!