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.
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.
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 PJ
#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
}
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.