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 !
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 !
The events come from the S110, and you can not define these events yourself.
To handle these event, set the handler function by calling softdevice_handler_set
if you are using the softdevice handler from the SDK. If you are not using the softdevice handler from the SDK you can handle these events by calling sd_ble_evt_get
directly.
first sorry for my english , i can not find sofedevice_handler_set message, and the write charactristic operate will gernerate what events?
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;
}
Try to search for softdevice_ble_evt_handler_set();
. This is the function used in SDK 9 to register the ble_evt_dispatch()
event handler.
What do you mean exactly by "and the write characteristic operate will generate what events"? When you perform a write operation the GATT event "BLE_GATTS_EVT_WRITE" will be passed to ble_evt_dispatch()
Is there a question here?