This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to add custom service to the Ble_app_template example

Hello i am using nrf52810 with SDK version 17.0.2 , i want to add custom service to the ble_app_template example and i followed this tutorial link https://github.com/edvinand/custom_ble_service_example so at first debug i got this error as expected 

next i have change the RAM_START AND RAM_SIZE as per the memory size mentioned in the error then i DEBUG it again so the i got 

so i don't know what's happening please help me to resolve this . 

thank you.

Parents
  • Hello,

    Please make sure to have DEBUG defined in your preprocessor defines, like shown in the included image:

    This will make your logger output a detailed error message whenever a non-NRF_SUCCESS error code is passed to an APP_ERROR_CHECK.
    Please do this, and let me know what the error message reads, along with which function that returned the error code pointed to in the error message.

    Best regards,
    Karl

  • Hello,

    mr Karl i am very happy to communicate with you and thank you so much for your reply, i tried as you said  and i got this error,

    thank you,

  • Hello,

    sagarnayakm said:
    i think first error is resolved like now its advertising Device name

    I am happy to hear that the initial issue is resolved!
    How did you resolve it?

    Could you also tell me which step of the tutorial you are currently working on?

    sagarnayakm said:
    then i have add read and write characteristics to the service but its not added. for more information please have look 

    Could you confirm that you pass all the returned error codes to an APP_ERROR_CHECK?
    Furthermore, I see that you use a lot of breakpoints in your code - please be advised that you may not use breakpoints while the SoftDevice is enabled, since they will halt the CPU and cause the SoftDevice to assert immediately upon resuming the program. This is because the SoftDevice keeps track of upcoming BLE events using a timer instances, and so it will assert if it for some reason is unable to process them.

    Best regards,
    Karl

  • How did you resolve it?

    Hello, i adding step by step peice of code to ble_cus .c and .h  files i don't exactly the issue.

    Could you also tell me which step of the tutorial you are currently working on?

    Yes, now i am in step 7 like when i write 01 value the led4 should on and again if i write 01 led should off .

    so its working fine. for my application its enough right.??

    or should i need to continue the propagating and remaining steps also.

    now i can see in my nrf_connect mobile app like this 

      

    so, please tell me that for sending some data from app to device is it enough.?? or i need to follow remaining steps also.

    thank you.

  • I am glad to hear that it is working after following the tutorial, great!

    I would recommend that you follow the tutorial to the end because it contains important information about how to forward service specific events to your application, along with the notify property, which comes in handy in a multitude of applications.
    If it turns out that the parts are not directly relevant to your application now it is still good to know for future reference, and to better understand how the BLE protocol and communication works.

    Best regards,
    Karl

  • If it turns out that the parts are not directly relevant to your application now it is still good to know for future reference, and to better understand how the BLE protocol and communication works.

    Yes, i will follow the tutorial but now i wrote data 01 to the device and led is turn on. If i want to receive the exact data which i have sent is not possible. i tried to receive  data by adding this line but whatever the data if i write same result at the receiving side for more information please have look at this,

    this is the data i am getting for different input, but i need the same data what i sent from the mobile application and here the line i have added in the write function 

    static void on_write(ble_cus_t * p_cus, ble_evt_t const * p_ble_evt)
    {
        ble_gatts_evt_write_t * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write;
        
        // Check if the handle passed with the event matches the Custom Value Characteristic handle.
     
        uint8_t *sagar=p_evt_write->data;
        printf("sagar:0x%x\r\n",sagar);
        if (p_evt_write->handle == p_cus->custom_value_handles.value_handle)
        {
    
            nrf_gpio_pin_toggle(LED_4); 
        }
    
    }
     

  • Yes, this is covered in the next step of the tutorial which concerns forwarding of service events to the application layer.
    It will show you how to pass the received data to your application using service specific events.

    Best regards,
    Karl

Reply Children
  • Yes, this is covered in the next step of the tutorial which concerns forwarding of service events to the application layer.

    Ok. thank you so much  Karl i will complete whole tutorial and let you know the status.

    thank you.  

  • Great, I look forward to hearing how it goes!

  • Hello,

    Hi, mr.Karl i now i am  at step 8 and i can't connect the BLE it gives the NRF_ERROR_NULL. In tutorial they have mentioned that make sure that the evt_type is not NULL but when on_connect evt_type becomes BLE_EVT_CONNECTED right.?? so how the evt becomes NULL here for more information please have look at this.

    and one more thing that adding custom characteristics i faced some issues yesterday in cus_init() exactly at sd_ble_gatts_service_add() function returns so i have  done this then only characteristic is a

    added and its working fine. is that effects here.??

    please let me know,i am looking forward for your suggestions.

    thank you.

    so 

Related