Seeed xiao nrf52840 uuid changes automatically

const uint8_t BLE_UUID_SERVICE[] =
{
    0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
    0x00, 0x10, 0x00, 0x00, 0x1c, 0x18, 0x00, 0x00
};
//BLEService bleService(BLE_UUID_SERVICE);
BLEService bleService(0x181c);
BLECharacteristic bleCharacteristic(0x2A56);

I am testing with two nrf52840 modules as slave equipment.
I set the same characteristic uuid to the same service uuid.
However, in the nrf connect app, it appears as the same uuid, but when I print the log in the app I made,I see uuids with different characteristics.
(Before connecting, the service uuid appears the same, but after connecting, the service uuid also appears different.)
I wondered if I made the app wrong, so when I tried to communicate with the uuid I set on the board, one device communicated properly and the other device did not.
So when I tried to communicate with different uuids shown in the app log, both devices communicated.
Is it possible that the characteristic uuid is not set to the same uuid even on the same board?
I have never operated the boards together because the uuid may conflict.

Hi there,

So I’m looking at this and thinking, The BLE is concerned with the MAC and roll central or peripheral, AFAIK not the UUID, now there’s probably a catch in there based on advertising or some crazy cool capability we don’t yet understand. :star_struck:
So post some code so we can see , or can you explain what this is for? goal wise?
what do you hope to achieve.?
Are you using an MIT API2 for the mobile?
GL :slight_smile: PJ :v:

I’m attaching the code

BLEService bleService(0x181c);
BLECharacteristic bleCharacteristic(0x2A56);

void setup() {
  Serial.begin(115200);
  Serial.println("Initialise the Bluefruit nRF52 module");

  Bluefruit.begin();
  Bluefruit.setTxPower(8);
  Bluefruit.setName("BLE");
  Bluefruit.autoConnLed(false);

  Bluefruit.Periph.setConnectCallback(connect_callback);
  Bluefruit.Periph.setDisconnectCallback(disconnect_callback);

  bleService.begin();

  bleCharacteristic.setProperties(CHR_PROPS_READ | CHR_PROPS_NOTIFY | CHR_PROPS_WRITE);
  bleCharacteristic.setPermission(SECMODE_OPEN, SECMODE_OPEN);
  bleCharacteristic.begin();
  bleCharacteristic.setWriteCallback(callbackCharacteristicWrite);
  startAdv();

}

void startAdv(void) {

  Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);

  Bluefruit.Advertising.addTxPower();
  Bluefruit.Advertising.addService(bleService);

  Bluefruit.ScanResponse.addName();

  Bluefruit.Advertising.restartOnDisconnect(true);
  Bluefruit.Advertising.setInterval(32, 244);  // in unit of 0.625 ms
  Bluefruit.Advertising.setFastTimeout(30);    // number of seconds in fast mode
  Bluefruit.Advertising.start(0);              // 0 = Don't stop advertising after n seconds
}

Ok so
I went to a more complete attempt

#include <bluefruit.h>

// Define BLE service and characteristic
BLEService bleService(0x181c);  // UUID of the service
BLECharacteristic bleCharacteristic(0x2A56); // UUID of the characteristic

void setup() {
  Serial.begin(9600);
  Serial.println("Initialise the Bluefruit nRF52 module");

  // Initialize Bluefruit
  Bluefruit.begin();
  Bluefruit.setTxPower(8);
  Bluefruit.setName("BLE");
  Bluefruit.autoConnLed(false);

  // Set connection and disconnection callbacks
  Bluefruit.Periph.setConnectCallback(connect_callback);
  Bluefruit.Periph.setDisconnectCallback(disconnect_callback);

  // Start the BLE service
  bleService.begin();

  // Configure the characteristic
  bleCharacteristic.setProperties(CHR_PROPS_READ | CHR_PROPS_NOTIFY | CHR_PROPS_WRITE);
  bleCharacteristic.setPermission(SECMODE_OPEN, SECMODE_OPEN);
  bleCharacteristic.begin();
  bleCharacteristic.setWriteCallback(callbackCharacteristicWrite);

  // Start advertising
  startAdv();
}

void startAdv(void) {
  Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
  Bluefruit.Advertising.addTxPower();
  Bluefruit.Advertising.addService(bleService);
  Bluefruit.ScanResponse.addName();

  Bluefruit.Advertising.restartOnDisconnect(true);
  Bluefruit.Advertising.setInterval(32, 244);  // in unit of 0.625 ms
  Bluefruit.Advertising.setFastTimeout(30);    // number of seconds in fast mode
  Bluefruit.Advertising.start(0);              // 0 = Don't stop advertising after n seconds
}

// Callback functions
void connect_callback(uint16_t conn_handle) {
  Serial.println("Connected");
}

void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
  Serial.println("Disconnected");
}

void callbackCharacteristicWrite(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len) {
  Serial.print("Characteristic written with value: ");
  Serial.write(data, len);
  Serial.println();
}

void loop() {
  // Main loop can be used for other tasks or left empty
}

No problem connecting and passing data?

Serial output as expected.

HTH
GL :slight_smile: PJ
I used BSP 1.1.1 BTW


the DK is running the Nordic_LBS for control group, other two Xiao Sense are running same code as posted. one battery and one USB C
:v:

all three connected…

Thanks for testing :grinning: :smiling_face_with_three_hearts:

Where are you running the app? On iPhone I noticed the uuid’s for devices are ephemeral, meaning for security they will change when you re-pair the device. So don’t assume they remain constant for a given slave device. But you can advertise the same service from two devices, as they are distinct targets. The service uuid’s can be searched for multiple targets.