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

scheduler and struct

Hi,

I would like to save some data from characteristic into the Flash. Due to this fact I decided that I will use scheduler. When the value of actual characteristic is changed the writing event handler triggers the following event handler

static void name_write_handler(ble_infs_t *p_infs,  ble_srv_utf8_str_t name)
{		
	
	app_sched_event_put(&name, sizeof(name),scheduler_name_flash_handler);
	
	
}

which is defined in one of my service. Then the scheduler is called by scheduler_name_flash_handler function which is defined as

void scheduler_name_flash_handler(void *p_event_data, ble_srv_utf8_str_t name)
{
}

Maybe it is worth mentioning that ble_srv_utf8_str_t is structure by the following body

typedef struct
{
    uint16_t  length;                                   /**< String length. */
    uint8_t * p_str;                                    /**< String data. */
} ble_srv_utf8_str_t;

I do not know why i get warning incompatible pointer type. I will be really grateful for any help.

Best regards

Samo

Parents
  • It doesn't look like your event handler matches the app_sched_event_handler_t required by app_sched_event_put. It should probably look like:

    void scheduler_name_flash_handler(void *p_event_data, uint16_t size) {
       // Note the signature is void function(void *, uint16_t)
       // Assuming the data really points to a "ble_srv_utf8_str_t", just type cast it.
       ble_srv_utf8_str_t *p_srv_utf8_str = (ble_srv_utf8_str_t *)p_event_data;
        ...
    }
    

    You may need to typecast the parameter being passed too, like:

        app_sched_event_put((void *)&name, sizeof(name),scheduler_name_flash_handler);
    
  • At this point, I have still one short question. How I can check if void *p_event_data is really ble_srv_utf8_str_t type. I would like to apply different types in p_evet_data and if statment before that is required. What is the best solution for my problem.

    Thanks for help

Reply Children
No Data
Related