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

Configurable UUID

Hello,

I want to change the 16-bit of 128-bit UUID at runtime. is this possible?

let me explain...

1)the first both central and peripheral set 128-bit UUID like this....

6e400000-b5a3-f393-e0a9-e50e24dcca9e

  1. now after connection the central send 16-bit service UUID to peripheral this will overwrite too 0x0000 number and disconnect from central and than after advertise with newer one service UUID like this..

6e400004-b5a3-f393-e0a9-e50e24dcca9e

is this possible?

please correct me if i m wrong..

thank you..

  • i want to change ....this bit in UUID..

    //ble_uuid.uuid = BLE_UUID_NUS_SERVICE;

    ble_uuid.uuid = tag_uuid;

  • Well it doesn't matter where you store it, internal flash, external, UICR region, it's up to you where your app stores config data. Pstorage module should be enough. If you use it and you don't see the desired result then you simply have a bug in your project so test it properly, do UART or RTT tracing, do simple little steps and verify after each etc. This is nothing we could fix for you on forum.

  • If we use the Pstorage for store the UUID....and we want to read the UUID at time of power of board.

    so that the board advertise with new UUID.

    so is this possible to read the UUID from pstorage in the time of service initialize?

  • Sure, you can do whatever you want with your pstorage;)

  • but i am not able to read data from pstorage at time of ble_nus_init.

    Here i send the snapshots of this function...

    uint32_t ble_nus_init(ble_nus_t * p_nus, const ble_nus_init_t * p_nus_init) { uint32_t err_code; ble_uuid_t ble_uuid; ble_uuid128_t nus_base_uuid = NUS_BASE_UUID;

    VERIFY_PARAM_NOT_NULL(p_nus);
    VERIFY_PARAM_NOT_NULL(p_nus_init);
    
    // Initialize the service structure.
    p_nus->conn_handle             = BLE_CONN_HANDLE_INVALID;
    p_nus->data_handler            = p_nus_init->data_handler;
    p_nus->is_notification_enabled = false;
    
    /**@snippet [Adding proprietary Service to S110 SoftDevice] */
    // Add a custom base UUID.
    err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &p_nus->uuid_type);
    VERIFY_SUCCESS(err_code);
    
    ble_uuid.type = p_nus->uuid_type;
    //ble_uuid.uuid = BLE_UUID_NUS_SERVICE;
    	
    
    	uint8_t *load_uuid;
    	pstorage_test_init();
    	UART_sendCString("pstorage_test_init\r\n");
    	load_uuid = pstorage_test_load();
    	
    	UART_sendCString("pstorage_test_load\r\n");
    
    	tag_uuid = (uint16_t)((load_uuid[0] << 8) | (load_uuid[1] & 0xFF));
    	if(tag_uuid == 0xFFFF)
    	{
    			printf("ble_nus_init tag_uuid = 0\r\n");
    			tag_uuid = 0x0000;
    	}
    	else
    	{
    		
    		printf("Tag UUID is :- %d\r\n",tag_uuid);
    	}
    	ble_uuid.uuid = tag_uuid;
    
    
    // Add the service.
    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
                                        &ble_uuid,
                                        &p_nus->service_handle);
    /**@snippet [Adding proprietary Service to S110 SoftDevice] */
    VERIFY_SUCCESS(err_code);
    
    // Add the RX Characteristic.
    err_code = rx_char_add(p_nus, p_nus_init);
    VERIFY_SUCCESS(err_code);
    
    // Add the TX Characteristic.
    err_code = tx_char_add(p_nus, p_nus_init);
    VERIFY_SUCCESS(err_code);
    
    return NRF_SUCCESS;
    

    } id.uuid = tag_uuid;

    i can not get the interrupt from pstorage at time of load the data..

Related