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

How to switch UUID at Android apps

Hi

I now is developing Android apps on the basis of NRF UART v2.0. My s110 NRF51 device will switch two modes for differnet 128-bit UUID. These two modes have independent service and TX/RX characteristcis.Except UUID base, the operation of these two are same.

Mode A Service: 6E400001-B5A3-F393-E0A9-E50E55534243 TX characteristic: 6E400002-B5A3-F393-E0A9-E50E55534243 RX characteristic: 6E400003-B5A3-F393-E0A9-E50E55534243 Mode B Service: 6E400001-B5A3-F393-E0A9-E50E55535253 TX characteristic: 6E400002-B5A3-F393-E0A9-E50E55535253 RX characteristic: 6E400003-B5A3-F393-E0A9-E50E55535253

My apps connected NRF51 at mode A. It can work normally. Then, I switch NRF51 to mode B. I found apps cannot change to connect NRF51 at mode B which has different UUID base.

At my apps code, I really switch to the UUID at mode B. However, it seems apps will be stuck at UUID of mode A. Would you have any comment or solution about it? Thanks.

  • I assume you are resetting your device and changing the services in the Attribute Table when changing modes.

    Allthough you are switching between two modes, the Bluetooth address remains the same and the Android phone will therefore treat it as the same device with the same services and characteritics as before and not perform a new Service Discovery unless the peripheral indicates that its services has changed.

    You can do this by calling sd_ble_gatts_service_changed() after connecting to indicate that the Attribute table has changed and that the peer should perform a Service Discovery.

    -Bjørn

  • Dear Bjørn

    At my firmware code, 1.#define IS_SRVC_CHANGED_CHARACT_PRESENT 1 2. Add sd_ble_gatts_service_changed() at CONNECTED event of on_ble_evt() as below

    However, it still cannot change servicesat apps side. I traced source code of sdk8.1.0 \ble_app_hrs\pca10028\s130_with_dfu. It seems I shall set CCCD of service changed in advance. Could you tell me how to set the CCCD? Thanks.

    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:  
    					//Connected by upstream central. Scan start to find neighbor peripherals			
    						m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;	
    			
    						sd_ble_gatts_service_changed(m_conn_handle, 0x0001, 0xFFFF);
    
  • Could you check the return value of sd_ble_gatts_service_changed() ? Also verify that you're getting the BLE_GATTS_EVT_SC_CONFIRM event.

Related