From 0cd2355014de9bdd340e062ade593f41394ee9c5 Mon Sep 17 00:00:00 2001 From: chain40 Date: Tue, 10 Jun 2025 22:08:30 +0800 Subject: [PATCH] fix: Replace custom UUID with BLE UUID for ble uart --- le_uart_srv.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/le_uart_srv.c b/le_uart_srv.c index 2d2eeac..ca31c6a 100644 --- a/le_uart_srv.c +++ b/le_uart_srv.c @@ -27,10 +27,10 @@ extern "C" #if NRF_MODULE_ENABLED(BLE_UART_SRV) -#define BLE_UUID_UART_SERVICE 0x0001 /**< The UUID of the Service. */ -#define BLE_UUID_UART_RX_CHAR 0x0002 /**< The UUID of the RX Characteristic. */ -#define BLE_UUID_UART_TX_CHAR 0x0003 /**< The UUID of the TX Characteristic. */ -#define BLE_UUID_UART_BAUD_CHAR 0x0004 /**< The UUID of the Baud Characteristic. */ +#define BLE_UUID_UART_SERVICE 0xFFF8 /**< The UUID of the Service. */ +#define BLE_UUID_UART_RX_CHAR 0xFFF9 /**< The UUID of the RX Characteristic. */ +#define BLE_UUID_UART_TX_CHAR 0xFFFA /**< The UUID of the TX Characteristic. */ +#define BLE_UUID_UART_BAUD_CHAR 0xFFFB /**< The UUID of the Baud Characteristic. */ #define BLE_UART_BASE_UUID \ { \ @@ -197,20 +197,17 @@ static ret_code_t add_baud_characteristic(uint16_t uuid, uint8_t uuid_type, ble_ void le_uart_srv_init(void) { ret_code_t err_code; - ble_uuid128_t nus_base_uuid = BLE_UART_BASE_UUID; - uint8_t uuid_type = 0; - ble_uuid_t ble_uuid; + uint8_t uuid_type = 0; /**@snippet [Adding proprietary Service to the SoftDevice] */ - // Add a custom base UUID. - err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &uuid_type); - APP_ERROR_CHECK(err_code); + ble_uuid_t ble_uuid = { + .type = BLE_UUID_TYPE_BLE, + .uuid = BLE_UUID_UART_SERVICE, + }; // Add the service. - ble_uuid.type = uuid_type; - ble_uuid.uuid = BLE_UUID_UART_SERVICE; - err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, + err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &ble_uart_context.service_handle); APP_ERROR_CHECK(err_code);