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

what does the function "evt_handler()" do and the definition be?

Hi! I am studying some program code of BLE examples. I have a doubt about what does the evt_handler() do. E.g. in the example "ble_app_hrs_s130_pca10028"

static void on_hrm_cccd_write(ble_hrs_t * p_hrs, ble_gatts_evt_write_t * p_evt_write)
{...p_hrs->evt_handler(p_hrs, &evt); .. }

in the example "ble_app_rscs_s130_pca10028

static void on_meas_cccd_write(ble_rscs_t * p_rscs, ble_gatts_evt_write_t * p_evt_write)
{...p_rscs->evt_handler(p_rscs, &evt);...}

I can just find the typedef struct about it, such as:

typedef void(* 	ble_hrs_evt_handler_t )(ble_hrs_t *p_hrs, ble_hrs_evt_t *p_evt)

But I can not unstandard what does the evt_handler() do from the the typedef. Could anybody give me some explain about it or tell me where can find the more detail definition about the function "evt_handler()"? Thank you for your reply and help!

Parents
  • In addition to what @tasketrond said it might be worth mentioning that in those examples the evt_handler actually does nothing. In the hrs example the evt_handler is set to:

    hrs_init.evt_handler                 = NULL; 
    

    in services_init(). Then the hrs_init.evt_handler is copied into p_hrs.evt_handler in ble_hrs_init() in ble_hrs.c. The same goes for the rscs example. The option to use an event handler is there to offer flexibility and the ability to expand on the example.

Reply
  • In addition to what @tasketrond said it might be worth mentioning that in those examples the evt_handler actually does nothing. In the hrs example the evt_handler is set to:

    hrs_init.evt_handler                 = NULL; 
    

    in services_init(). Then the hrs_init.evt_handler is copied into p_hrs.evt_handler in ble_hrs_init() in ble_hrs.c. The same goes for the rscs example. The option to use an event handler is there to offer flexibility and the ability to expand on the example.

Children
Related