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

How to find the handle value?

Hi, I modified the ble_app_hrs sample application with one custom service which includes, some custom characteristics (128 bit uuid), Now the problem i am facing is, i am not getting the correct handle values which are shown in master control panel, i.e the default handle for the device name is 3, i can also see it in master control panel, but when i check it inside my application i am not getting the same handle value. Below is my code where i am checking the device name handle value.

static void on_write(ble_evt_t * p_ble_evt) {

ble_gatts_evt_write_t * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write;


        	if(p_evt_write->handle == 3)
		{		
			sd_nvic_SystemReset();
		}

My application is not resetting, when i write something on device name.

The handle value i am getting for all the write event is 0xB001. Please tell me how to solve this.

Regards, Balaji

modified_ble_app_hrs.rar

Parents
  • Handles are assigned sequentially from 1, so there is no way that you can have a handle that is 0xB001 (= 45057), since there is simply not enough RAM on the nRF51822 to have that many handles. This issue must therefore stem from something else.

    Can you please upload your complete application, so that I can have a look at it?

    Edit: I've now had a look at your code, and adding this to main.c's on_ble_evt, made it reset on device name writes as expected:

    
    static void on_ble_evt(ble_evt_t * p_ble_evt)
    {
    ...
        ble_gatts_evt_write_t * write_evt;
    ...
            case BLE_GATTS_EVT_WRITE:
                write_evt = &p_ble_evt->evt.gatts_evt.params.write;
                if (write_evt->handle == 0x03)
                {
                    sd_nvic_SystemReset();
                }
                break;
    ...
    
    

    I'd strongly recommend you to clean up your code until you get it working and only then add things back in to see what causes your problem.

    Edit 2: I've attached the main file after my modifications, but I haven't done any effort on fixing the other mess.

    main.c

    ble_hrs.c

    ble_hrs.h

Reply Children
No Data
Related