I have trouble when discover the BLE Peripheral that have the base UUID of characteristics and service are different.
Then I followed several instructions in some cases, but it did not work.
Before I use sd_ble_uuid_vs_add() to add some base UUID of characteristics. The BLE Central still scan the BLE Peripheral but can not discover the characteristic, It returns some UUID = 0 and then crash.
After that, I add base UUID (I have changed NRF_SDH_BLE_VS_UUID_COUNT and size of RAM already), the BLE Central can not scan the BLE Peripheral anymore.
This is my code and the UUID of service and characteristics//ble_nus_c.c
uint32_t ble_nus_c_init(ble_nus_c_t * p_ble_nus_c, ble_nus_c_init_t * p_ble_nus_c_init)
{
uint32_t err_code;
ble_uuid_t uart_uuid;
ble_uuid128_t nus_base_uuid = NUS_BASE_UUID;
ble_uuid128_t char1_base_uuid = CHAR1_BASE_UUID;
ble_uuid128_t char2_base_uuid = CHAR2_BASE_UUID;
ble_uuid128_t char3_base_uuid = CHAR3_BASE_UUID;
VERIFY_PARAM_NOT_NULL(p_ble_nus_c);
VERIFY_PARAM_NOT_NULL(p_ble_nus_c_init);
err_code = sd_ble_uuid_vs_add(&char1_base_uuid, &p_ble_nus_c->uuid_type);
VERIFY_SUCCESS(err_code);
uart_uuid.type = p_ble_nus_c->uuid_type;
uart_uuid.uuid = BLE_UUID_CHARACTERISTIC1;
NRF_LOG_INFO("uart_uuid.uuid = %x, uart_uuid.type = %x",uart_uuid.uuid,p_ble_nus_c->uuid_type);
err_code = sd_ble_uuid_vs_add(&char2_base_uuid, &p_ble_nus_c->uuid_type);
VERIFY_SUCCESS(err_code);
uart_uuid.type = p_ble_nus_c->uuid_type;
uart_uuid.uuid = BLE_UUID_CHARACTERISTIC2;
NRF_LOG_INFO("uart_uuid.uuid = %x, uart_uuid.type = %x",uart_uuid.uuid,p_ble_nus_c->uuid_type);
err_code = sd_ble_uuid_vs_add(&char3_base_uuid, &p_ble_nus_c->uuid_type);
VERIFY_SUCCESS(err_code);
uart_uuid.type = p_ble_nus_c->uuid_type;
uart_uuid.uuid = BLE_UUID_CHARACTERISTIC3;
NRF_LOG_INFO("uart_uuid.uuid = %x, uart_uuid.type = %x",uart_uuid.uuid,p_ble_nus_c->uuid_type);
err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &p_ble_nus_c->uuid_type);
VERIFY_SUCCESS(err_code);
NRF_LOG_INFO("uart_uuid.uuid = %x, uart_uuid.type = %x",uart_uuid.uuid,p_ble_nus_c->uuid_type);
uart_uuid.type = p_ble_nus_c->uuid_type;
uart_uuid.uuid = BLE_UUID_NUS_SERVICE;
NRF_LOG_INFO("uart_uuid.uuid = %x, uart_uuid.type = %x",uart_uuid.uuid,p_ble_nus_c->uuid_type);
p_ble_nus_c->conn_handle = BLE_CONN_HANDLE_INVALID;
p_ble_nus_c->evt_handler = p_ble_nus_c_init->evt_handler;
p_ble_nus_c->handles.nus_tx_handle = BLE_GATT_HANDLE_INVALID;
p_ble_nus_c->handles.nus_rx_handle = BLE_GATT_HANDLE_INVALID;
return ble_db_discovery_evt_register(&uart_uuid);
}
//ble_nus_c.h
#define NUS_BASE_UUID {{0x8E,0x3F,0x28,0xB7,0xAA,0xA7,0x23,0xA9,0x88,0x49,0xCD,0xE4,0x70,0x9B,0x49,0xDD}} /**< Used vendor specific UUID. */
#define CHAR1_BASE_UUID {{0x66,0x9A,0x0C,0x20,0x00,0x08,0x06,0xBD,0xE4,0x11,0xD2,0x9B,0x20,0x64,0x95,0xA0}} /**< Used vendor specific UUID. */
#define CHAR2_BASE_UUID {{0x66,0x9A,0x0C,0x20,0x00,0x08,0xD8,0xBC,0xE4,0x11,0xD8,0xa2,0xD0,0x50,0x86,0xc4}}
#define CHAR3_BASE_UUID {{0xFB,0x34,0x9B,0x5F,0x80,0x00,0x00,0x80,0x00,0x10,0x01,0xE0,0xD0,0x4F,0xBD,0x90}}
#define BLE_UUID_NUS_SERVICE 0x9B70 /**< The UUID of the Nordic UART Service. */
#define BLE_UUID_CHARACTERISTIC1 0x6420 /**< The UUID of the Characteristic1. */
#define BLE_UUID_CHARACTERISTIC2 0x50d0 /**< The UUID of the Characteristic2. */
#define BLE_UUID_CHARACTERISTIC3 0x4fd0 /**< The UUID of the Characteristic3. */
Can you help me fix this? Thanks a lot!!