fix: Replace custom UUID with BLE UUID for ble uart

This commit is contained in:
chain40
2025-06-10 22:08:30 +08:00
parent 453278fa33
commit 0cd2355014
+10 -13
View File
@@ -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);