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

How to define event and event handler

when I use softDevice S110, there exists ble_evt_dispatch function, Can I define event ? if I can, how to define event and how to use event handler . Thank you !

Parents
  • static uint32_t jawbone_char_TriggerEventHistoryReset_add(ble_jawbone_t * p_jawbone, const ble_jawbone_init_t * p_jawbone_init)
    {
        uint32_t            err_code;
        ble_gatts_char_md_t char_md;
        ble_gatts_attr_t    attr_char_value;
        ble_uuid_t          ble_uuid;
        ble_gatts_attr_md_t attr_md;
    		ble_srv_cccd_security_mode_t  char_attr_security_mode_md;
    
        BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&char_attr_security_mode_md.read_perm);
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&char_attr_security_mode_md.write_perm);
    	
    
        memset(&char_md, 0, sizeof(char_md));
        char_md.char_props.read   = 0;
    		char_md.char_props.write   = 1;
        char_md.p_char_user_desc  = NULL;
        char_md.p_char_pf         = NULL;
        char_md.p_user_desc_md    = NULL;
        char_md.p_cccd_md         = NULL;
        char_md.p_sccd_md         = NULL;
    
        BLE_UUID_BLE_ASSIGN(ble_uuid, UUID_TRIGGER_EVENT_HISTORY_RESET_CHAR);
    
        memset(&attr_md, 0, sizeof(attr_md));
    
        attr_md.read_perm  = char_attr_security_mode_md.read_perm;
        attr_md.write_perm = char_attr_security_mode_md.cccd_write_perm;
        attr_md.vloc       = BLE_GATTS_VLOC_STACK;
        attr_md.rd_auth    = 0;
        attr_md.wr_auth    = 0;
        attr_md.vlen       = 0;
    
        memset(&attr_char_value, 0, sizeof(attr_char_value));
    
        attr_char_value.p_uuid    = &ble_uuid;
        attr_char_value.p_attr_md = &attr_md;
        attr_char_value.init_len  = TRIGGER_EVENT_DATA_LEN;
        attr_char_value.init_offs = 0;
        attr_char_value.max_len   = TRIGGER_EVENT_DATA_LEN;
       attr_char_value.p_value = "abcde"; 
        err_code = sd_ble_gatts_characteristic_add(p_jawbone->service_handle, &char_md,
                                                   &attr_char_value,
                                                   &p_jawbone->TriggerEventHistoryReset_handle);	
    		if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }
    		return NRF_SUCCESS;
    }	
    
Reply Children
No Data
Related