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

Device is not advertising when creating custom service using UART service

Hi,

In my application I am creating one more custom service using UART service. I have created new files named ble_nus1.c and ble_nus1.h. In these files I have changed the variable names . But still the device is not advertising when flashing the code.

I am attaching main file and library files here. please can any help me to resolve the issue.

nus_hrs.c

library files:

ble_nus2.c

ble_nus2.h

  • I don't think it's reasonable to ask someone to try to read through your code itself. Tell us what you've tried, what can't be the problem, any parts that you know are working, etc. Show us that you've put some effort into solving the problem, rather than asking us to be your application programmers.

  • In ble_stack_init, you need to increase ble_enable_params.common_enable_params.vs_uuid_count when adding a custom service with a 128-bit UUID.

  • Hi Elias,

    Thanks for your comment. I agree that it is not possible to go through entire code to resolve the issue. I regret for that. Actually I am trying to use two UART profiles in my code so that I can transfer more number of packets. Through one UART profile I am transferring the 1000 samples per seconds. Using another UART(custom) profile I want to send different packets. What I understand If we change UUID of new service then it should work as different service that we want.(This I tried previously with HRS ad HTS service).

    In this case I changed UART service UUID to 0x0004, TX char UUID to 0x0005 and RX char UUID to 0x0006. I had this issue earlier, but at that time execution was stopping at ble_stack_initialization. So after changing clock previous codes worked fine. This time code is stopping at advertising_init function. I am trying to figure out issue.

    Please can you give me some suggestion regarding this?

  • I think you're advertising too many characteristics. You only need to advertise the ones you really want to scan for. Change m_adv_uuids to only have the heart rate service

  • Hi Jastin,

    Thank you so much for the reply. Yes by changing the count to 2 it starts advertising. I can see the two different services on APP. But when I enable both notification only then I am receiving data using second custom service.
    following is the code to send any rough values to custom service from nrf52.

    				void send_to_app()
    		{
    			uint32_t    err_code;
    			uint8_t buff[10] = {0x54,0x55,0x55,0x55,0x55,0x55,0x55,0x55};
    		//    err_code = ble_nus_string_send(&m_nus, buff, 20);
    		//    if (err_code != NRF_ERROR_INVALID_STATE)
    		//    {
    		//			APP_ERROR_CHECK(err_code);
    		//    }		
    			err_code = ble_nus_string_send1(&m_nus1, buff, 20);
    			if (err_code != NRF_ERROR_INVALID_STATE)
    			{
    					APP_ERROR_CHECK(err_code);
    			}
    

    Here I am using two different functions which points to to two different libraries that I have crested for two services.

    When I enable notification of custom service control should transfer to data_handler 1 when send any data data from app. It is not happening.

Related