一直不知道 事件是怎么触发的.事件触发回调
觉得很神奇.很迷糊.
其实bluez不能单独的看,也要在 内核中看代码
文件src/adapter.c (bluez)
...
mgmt_register(adapter->mgmt, MGMT_EV_CONNECT_FAILED,
adapter->dev_id,
connect_failed_callback,
adapter, NULL);
mgmt_register(adapter->mgmt, MGMT_EV_DEVICE_UNPAIRED,
adapter->dev_id,
unpaired_callback,
adapter, NULL);
mgmt_register(adapter->mgmt, MGMT_EV_AUTH_FAILED,
adapter->dev_id,
auth_failed_callback,
adapter, NULL);
mgmt_register(adapter->mgmt, MGMT_EV_NEW_LINK_KEY,
adapter->dev_id,
new_link_key_callback,
adapter, NULL);
文件 net/bluetooth/mgmt.c
...
static const u16 mgmt_events[] = {
MGMT_EV_CONTROLLER_ERROR,
MGMT_EV_INDEX_ADDED,
MGMT_EV_INDEX_REMOVED,
MGMT_EV_NEW_SETTINGS,
MGMT_EV_CLASS_OF_DEV_CHANGED,
MGMT_EV_LOCAL_NAME_CHANGED,
MGMT_EV_NEW_LINK_KEY,
MGMT_EV_NEW_LONG_TERM_KEY,
MGMT_EV_DEVICE_CONNECTED,
MGMT_EV_DEVICE_DISCONNECTED,
MGMT_EV_CONNECT_FAILED,
MGMT_EV_PIN_CODE_REQUEST,
MGMT_EV_USER_CONFIRM_REQUEST,
MGMT_EV_USER_PASSKEY_REQUEST,
MGMT_EV_AUTH_FAILED,
MGMT_EV_DEVICE_FOUND,
MGMT_EV_DISCOVERING,
MGMT_EV_DEVICE_BLOCKED,
MGMT_EV_DEVICE_UNBLOCKED,
MGMT_EV_DEVICE_UNPAIRED,
MGMT_EV_PASSKEY_NOTIFY,
MGMT_EV_NEW_IRK,
MGMT_EV_NEW_CSRK,
MGMT_EV_DEVICE_ADDED,
MGMT_EV_DEVICE_REMOVED,
MGMT_EV_NEW_CONN_PARAM,
MGMT_EV_UNCONF_INDEX_ADDED,
MGMT_EV_UNCONF_INDEX_REMOVED,
MGMT_EV_NEW_CONFIG_OPTIONS,
有没有觉得似曾相识.
好了可以接着看了.
---------------------------我的天空里没有太阳,总是黑夜,但并不暗,因为有东西代替了太阳。虽然没有太阳那么明亮,但对我来说已经足够。凭借着这份光,我便能把黑夜当成白天。我从来就没有太阳,所以不怕失去。
--------《白夜行》