This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

creating custom service and characteristics with Bluetooth Base UUID.

Hi,

Am using nrf51822

uint32_t ble_nus_c_init(ble_nus_c_t * p_ble_nus_c, ble_nus_c_init_t * p_ble_nus_c_init)
{

		// for RN_4871
	  uint32_t      err_code;
    ble_uuid_t    uart_uuid;
    ble_uuid128_t nus_base_uuid = NUS_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(&nus_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_NUS_SERVICE;
	
	
    ble_uuid128_t char1_base_uuid = CHAR1_BASE_UUID;

    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_NUS_TX_CHARACTERISTIC;


    ble_uuid128_t char2_base_uuid = CHAR2_BASE_UUID;

    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_NUS_RX_CHARACTERISTIC;

    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);
}	
a central, i want to discover the service of anothe rble module (which is RN4871 from microship).

My problem here is that this RN4871 advertise a service with a different base UUID for service and for its two characteristics. 

Am not able to discover this service, although i tried to use the fucntion  sd_ble_uuid_vs_add(.....) more then one time, first time for service and two times for each characteristic.

after each use of "sd_ble_uuid_vs_add" a VERIFY_SUCCESS(err_code); is used, but is stucks after the first use of sd_ble_uuid_vs_add().

PS1 : the bases are : 

#define NUS_BASE_UUID {{0x55, 0xE4, 0x05, 0xD2, 0xAF, 0x9F, 0xA9, 0x8F, 0xE5, 0x4A, 0x7D, 0xFE, 0x43, 0x53, 0x53, 0x49}} //Used vendor specific UUID.
#define CHAR1_BASE_UUID {{0x16, 0x96, 0x24, 0x47, 0xC6, 0x23, 0x61, 0xBA, 0xD9, 0x4B, 0x4D, 0x1E, 0x43, 0x53, 0x53, 0x49}} // Used vendor specific UUID.
#define CHAR2_BASE_UUID {{0xB3, 0x9B, 0x72, 0x34, 0xBE, 0xEC, 0xD4, 0xA8, 0xF4, 0x43, 0x41, 0x88, 0x43, 0x53, 0x53, 0x49}} // Used vendor specific UUID.

#define BLE_UUID_NUS_SERVICE 0x5343 // The UUID of the Nordic UART Service.
#define BLE_UUID_NUS_TX_CHARACTERISTIC 0x5343 // The UUID of the Characteristic1.
#define BLE_UUID_NUS_RX_CHARACTERISTIC 0x5344 // The UUID of the Characteristic2.

PS2: i adjusted the RAM.

PS3: i adjusted   the uuid count with :  p_ble_enable_params->common_enable_params.vs_uuid_count = 3 in function ble_stack_init(void)
 since am using SDk 12.3.0 ( don't has NRF_SDH_BLE_VS_UUID_COUNT in it's sdk_config.h)

would you help me please.

Thnks in advance

Parents
  • Hi,

    after each use of "sd_ble_uuid_vs_add" a VERIFY_SUCCESS(err_code); is used, but is stucks after the first use of sd_ble_uuid_vs_add().

    Can you elaborate on what you mean by "stucks"? Do you get any errors returned from the call to sd_ble_uuid_vs_add() or any other function? What is the state of your application? Is any APP_ERROR_CHECK hit? What have you found by debugging?

    PS3: i adjusted   the uuid count with :  p_ble_enable_params->common_enable_params.vs_uuid_count = 3 in function ble_stack_init(void)
     since am using SDk 12.3.0 ( don't has NRF_SDH_BLE_VS_UUID_COUNT in it's sdk_config.h)

    This should be good.

  • Hi,

    when i use sd_ble_uuid_vs_add() only one time for the service , err_code will be 0x00 meaning NRF_SUCCESS..

    wheni use sd_ble_uuid_vs_add() for 3 times err_code will be 0x04 meanning NRF_ERROR_NO_MEM

    by "Stucks" i mean when i call sd_ble_uuid_vs_add() for the second time for the characteristic the APP_ERROR_CHECK (err_code) leads directly to the end of the function, it means that an error has occured, i think err_code = 0x04 which is NRF_ERROR_NO_MEM i told you.

    i think i have a memory problem although i thought i've well adjusted it after reading some information.

    the below presents my RAM area :

    RAM1 :

    starts : 0x20002800 -- size: 0xDDE0 (using Keil)

    i hope am close to solve this issue.

    ble_nus_c.c (modified)

    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;
        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);
    		APP_ERROR_CHECK (err_code);
    		uart_uuid.type = p_ble_nus_c->uuid_type;
        uart_uuid.uuid = BLE_UUID_NUS_TX_CHARACTERISTIC;
    
    
    
        err_code = sd_ble_uuid_vs_add(&char2_base_uuid, &p_ble_nus_c->uuid_type);
        //VERIFY_SUCCESS(err_code);
    		APP_ERROR_CHECK (err_code);
    		uart_uuid.type = p_ble_nus_c->uuid_type;
        uart_uuid.uuid = BLE_UUID_NUS_RX_CHARACTERISTIC;
    	
    	
        err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &p_ble_nus_c->uuid_type);
        VERIFY_SUCCESS(err_code);
    		//APP_ERROR_CHECK (err_code);
        uart_uuid.type = p_ble_nus_c->uuid_type;
        uart_uuid.uuid = BLE_UUID_NUS_SERVICE;
    
        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_rx_handle = BLE_GATT_HANDLE_INVALID;
        p_ble_nus_c->handles.nus_tx_handle = BLE_GATT_HANDLE_INVALID;
    
        return ble_db_discovery_evt_register(&uart_uuid);
    }
    

    ble_nus_c.h (modified)

    #define NUS_BASE_UUID									 {{0x55, 0xE4, 0x05, 0xD2, 0xAF, 0x9F, 0xA9, 0x8F, 0xE5, 0x4A, 0x7D, 0xFE, 0x43, 0x53, 0x53, 0x49}} //Used vendor specific UUID. 
    
    #define CHAR1_BASE_UUID                {{0xB3, 0x9B, 0x72, 0x34, 0xBE, 0xEC, 0xD4, 0xA8, 0xF4, 0x43, 0x41, 0x88, 0x43, 0x53, 0x53, 0x49}} // Used vendor specific UUID.
    #define CHAR2_BASE_UUID                {{0x16, 0x96, 0x24, 0x47, 0xC6, 0x23, 0x61, 0xBA, 0xD9, 0x4B, 0x4D, 0x1E, 0x43, 0x53, 0x53, 0x49}} // Used vendor specific UUID.
    
    #define BLE_UUID_NUS_SERVICE                 0x5343                      // The UUID of the Nordic UART Service. 
    #define BLE_UUID_NUS_TX_CHARACTERISTIC       0x5344                      // The UUID of the Characteristic1. 
    #define BLE_UUID_NUS_RX_CHARACTERISTIC       0x5343                      // The UUID of the Characteristic2. 

  • Your changes to ble_nus_c.h seems sensible. This also worked when I tested on my side. Perhaps the issue is with how you configured support for more UUIDs?

    Referring to the NUS central sample in SDK 12.3 I did this minor change to main.c to make it work,

    diff --git a/examples/ble_central/ble_app_uart_c/main.c b/examples/ble_central/ble_app_uart_c/main.c
    index ca13f2a..55bf742 100644
    --- a/examples/ble_central/ble_app_uart_c/main.c
    +++ b/examples/ble_central/ble_app_uart_c/main.c
    @@ -494,6 +494,8 @@ static void ble_stack_init(void)
                                                         PERIPHERAL_LINK_COUNT,
                                                         &ble_enable_params);
         APP_ERROR_CHECK(err_code);
    +    
    +    ble_enable_params.common_enable_params.vs_uuid_count = 3;
     
         //Check the ram settings against the used number of links
         CHECK_RAM_START_ADDR(CENTRAL_LINK_COUNT,PERIPHERAL_LINK_COUNT);
    

    And in the Keil project I configure the IRAM1 start address to 0x20002800 and size to 0x1800 (could perhaps be optimized).

  • Yes, thank you, that's what i've been doing, but i figured out my mistake, i was increasing the vs_uuid_count in another strucrure.

    Thanks Smiley

  • Did you solve the problem? Did you successfully connect?

Reply Children
No Data
Related