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

Testing of Current time service

Hi,

I am unable to test current time service example.I followed all the steps mentioned to test CTS Example.But, below are the log messages:

Again if I try to reset and try to connect to the device.The log messages are as below:

Please suggest me to rectify the errors and also the right way to test CTS example with 1SDK and mobile application.

Thanks & Regards,

Swathi P.

Parents
  • Hello Swathi P,

    Did you follow the Setup and Testing section of the CTS Example Documentation?
    From your error logs, it seems that the Current Time Service is not found on the central device, which causes the peripheral to auto-disconnect.
    You need to make sure that the central is providing this service.
    Which smartphone application and OS are you using?
    If you are using the nRF Connect application, you will need to configure your GATT server to include the Current Time Service, with the Current Time characteristic. The initial value of the characteristic should be C2 07 0B 0F 0D 25 2A 06 FE 08, as detailed in the CTS Example documentation referenced above.

    Please let me know if this resolves your issue,

    Best regards,
    Karl

  • Hi,

    Thank you for the reply.

    In example provided it has already advertising current time service,I think this means central is provided with service.

    I am using Oppo A71,it is android.

    I have configured Server on the mobile.

    To write the initial value the service is not getting discovered.

    Can you also please let me know,what content the initial value of characteristic "C2 07 0B 0F 0D 25 2A 06 FE 08" is holding?

    Thanks & Regards,

    Swathi P

     

  • Hello Swathi P,

    swathi p said:
    Please let me know what does the error in the log exactly mean?

    Please see the line roughly centered in the log, it reads:
    "<info> app: Current Time Service not found on serv<info> app: Current Time Service not found on server." 
    This leads me to believe that you still have not configured your GATT server to provide the CTS service correctly.
    You might find this answer by my colleague helpful to have a look at. Notice especially the Android CTS server Application he references in his reply.
    Again, I would highly recommend that you test this example with the nRF Connect application for Android first, to verify that you have understood and setup the GATT server and example correctly. The description of how to do this is provided as a step-by-step in the example documentation.

    swathi p said:
    I didn't understand that whether we have to give initial value after discovering Service or we have to give while configuring server like while setting properties and giving value.

     You will have to setup the Current Time characteristic on the Current Time Service server before you may discover it on your CTS peripheral device.

    swathi p said:
    in Apple it was displaying time on UART after 2 times connect and disconnect operation and then connect discover service and press button.For third time it is discovering service.But confusing part is I haven't configured any gatt server on iPhone.

    This is as expected, since CTS is a native service on iOS - it is provided to all connected BLE devices.

    Best regards,
    Karl

  • Hi,

    This is as expected, since CTS is a native service on iOS - it is provided to all connected BLE devices.

    Ok.I understood that CTS is native service on iOS,So it doesn't require to configure gatt service.But why Is it like I have to go through connection and disconnection for two times and then for the third time I am able to discover CTS service,Can I know the reason?

    Thanks & Regards,

    Swathi P 

      

  • Hi Swathi, 

    I don't have iOS to reproduce that, but I think you have to bond to the device. After the security procedure is complete, verify that the Current Time Service on the server has been discovered. 

    -Amanda H.

  • your reply is not that helpfull to progress our project.Let us know the exact connection procedure.

    The below are the consequences I am going through while testing

    • I compile and download the program on nRF Chip and scan from nRF Connect then try to connect to nRF Chip from nRF Connect by clicking on connect button.Unable to connect to the device.
    • Then tried erasing the Chip and then programmed with softdevice and application.Now I tried connecting from nRF Connect to nRF Chip,I was able to connect and asked for pair up,accepted to pair up.After some noticable delay I was able to Discover services.Can you please let me know the reason for the delay?
    • If I try to disconnect device it is not getting disconnected,even if I turn off the bluetooth it is not getting disconnected.
    • After pressing reset button it is automatically being in connected state.

    Thanks,

    Swathi P

  • Hi Swathi, 

    swathi p said:
    I compile and download the program on nRF Chip and scan from nRF Connect then try to connect to nRF Chip from nRF Connect by clicking on connect button.Unable to connect to the device.

    Did you erase the chip before downloading the image? The good habit is Erasing the kit every time before downloading the image. 

    swathi p said:
    Then tried erasing the Chip and then programmed with softdevice and application.Now I tried connecting from nRF Connect to nRF Chip,I was able to connect and asked for pair up,accepted to pair up.After some noticable delay I was able to Discover services.Can you please let me know the reason for the delay?

    Please provide the debug log and sniff log to help know the detail. 

    swathi p said:
    If I try to disconnect device it is not getting disconnected,even if I turn off the bluetooth it is not getting disconnected.

      Did you set with "Use autoConnect"? Also, I need the debug log and sniff log to help know what happened.   

    swathi p said:
    After pressing reset button it is automatically being in connected state.

     Did you set with "Use autoConnect"?

    -Amanda H.

Reply
  • Hi Swathi, 

    swathi p said:
    I compile and download the program on nRF Chip and scan from nRF Connect then try to connect to nRF Chip from nRF Connect by clicking on connect button.Unable to connect to the device.

    Did you erase the chip before downloading the image? The good habit is Erasing the kit every time before downloading the image. 

    swathi p said:
    Then tried erasing the Chip and then programmed with softdevice and application.Now I tried connecting from nRF Connect to nRF Chip,I was able to connect and asked for pair up,accepted to pair up.After some noticable delay I was able to Discover services.Can you please let me know the reason for the delay?

    Please provide the debug log and sniff log to help know the detail. 

    swathi p said:
    If I try to disconnect device it is not getting disconnected,even if I turn off the bluetooth it is not getting disconnected.

      Did you set with "Use autoConnect"? Also, I need the debug log and sniff log to help know what happened.   

    swathi p said:
    After pressing reset button it is automatically being in connected state.

     Did you set with "Use autoConnect"?

    -Amanda H.

Children
  • Hi,

    Yes, I have erased the kit every time I have downloading the application.Below is the log info while testing on android.

    The below is the log info while testing on iOS:

     Did you set with "Use autoConnect"?

    No.I didn't set with "Use autoConnect"

    Thanks & Regards,

    Swathi P.

  • Hi Swathi, 

    The disconnection reason is the service is not found on the server. You can use the nRF Connect mobile to configure GATT server as the following to test with the example. 

    -Amanda H.

  • Hi,

    Thank you.Your reply has helped me in testing CTS example.I was success  to connect,bond and discover service and print data on UART.But,If I try to delete bond information and try to scan and connect it is showing below log info and unable to discover service.

    If I erase the kit and then download after deleting bond information then it is working fine.Is CTS service always looking for whitelisted devices?Can you please explain me what exactly it does when we delete bond information on nRF Connect for mobile.

    In my project I cannot frequently erase and download.so please let me know if there is other way to Connect,pair and bond  and discover service after deleting bond information.

    Thanks & Regards,

    Swathi P

  • Hi Swathi, 

    You can do Button 2 long push: Turn off whitelist during advertising or scanning. Please see the BSP BLE Button Assignments. Or You may add the following event handling to the PM callback in peer_manager_handler.c if you want to allow repairing like this:

            case PM_EVT_CONN_SEC_CONFIG_REQ:
                   {
                        pm_conn_sec_config_t config = {.allow_repairing = true};
                        pm_conn_sec_config_reply(p_pm_evt->conn_handle, &config);
                    }
                break;

    and have a loop to go through m_whitelist_peers[] array to check if there is an element inside that array is equal to m_peer_id. If not then you add it as a new node into the array like this: 

            case PM_EVT_PEER_DATA_UPDATE_SUCCEEDED:
            {
                // Note: You should check on what kind of white list policy your application should use.
                if (     p_evt->params.peer_data_update_succeeded.flash_changed
                     && (p_evt->params.peer_data_update_succeeded.data_id == PM_PEER_DATA_ID_BONDING))
                {
                    NRF_LOG_DEBUG("New Bond, add the peer to the whitelist if possible");
                    NRF_LOG_DEBUG("\tm_whitelist_peer_cnt %d, MAX_PEERS_WLIST %d",
                                   m_whitelist_peer_cnt + 1,
                                   BLE_GAP_WHITELIST_ADDR_MAX_COUNT);
    
                    if (m_whitelist_peer_cnt < BLE_GAP_WHITELIST_ADDR_MAX_COUNT)
                    {
    
                        //check if there is any element inside that array is equal to m_peer_id
                        bool already_added= false;
    
                    for (uint8_t i = 0; i<m_whitelist_peer_cnt;i++)
                    
                    {
                    
                        if (m_whitelist_peers[i] == m_peer_id)
                        {
                            already_added= true;
                            break;
                        }
                    }
                            
                    if (!already_added)
                    {
    
                    //End of adding
                    
                        // Bonded to a new peer, add it to the whitelist.
                        m_whitelist_peers[m_whitelist_peer_cnt++] = m_peer_id;
    
                        // The whitelist has been modified, update it in the Peer Manager.
                        err_code = pm_device_identities_list_set(m_whitelist_peers, m_whitelist_peer_cnt);
                        if (err_code != NRF_ERROR_NOT_SUPPORTED)
                        {
                            APP_ERROR_CHECK(err_code);
                        }
    
                        err_code = pm_whitelist_set(m_whitelist_peers, m_whitelist_peer_cnt);
                        APP_ERROR_CHECK(err_code);
                    } 
                    }//End of adding
                }
            } break;
    

    -Amanda H.

  • Hi,

    Thank you for your suggestion.I have tried adding the below statements in main.c pm_evt_handler()

    I just replaced both the cases in pm_evt_handler.Even after deleting bond information I am able to connect by pairing.

    Is it not that pm_evt_handler in main.c you were talking about?

    I didn't find any PM callback  in peer_manager_handler.c.Can you give me the function name?

    Thanks & Regards,

    Swathi P.

Related