bluez plugins

来源:互联网 发布:童装淘宝店铺简介 编辑:程序博客网 时间:2024/06/07 22:19

When Bluetoothd initializing, it will load plugins in /usr/lib/bluetooth/plugins by default. Actually, most of bluetooth profiles are implemented as plugins in BlueZ.

In plugin.h, it defines:

struct bluetooth_plugin_desc {
const char *name;
int (*init) (void);
void (*exit) (void);
};

#define BLUETOOTH_PLUGIN_DEFINE(name,init,exit) \
struct bluetooth_plugin_desc bluetooth_plugin_desc = { \
name, init, exit \
};

It means that if you want to implement a plugin, just try to implement to callback functions: init and exit. All other communctions should be communicated with socket or IO channel.

Search macro BLUETOOTH_PLUGIN_DEFINE, you will find:

  1. BLUETOOTH_PLUGIN_DEFINE(“audio”, audio_init, audio_exit)
  2. BLUETOOTH_PLUGIN_DEFINE(“input”, input_init, input_exit)
  3. BLUETOOTH_PLUGIN_DEFINE(“network”, network_init, network_exit)
  4. BLUETOOTH_PLUGIN_DEFINE(“echo”, echo_init, echo_exit)
  5. BLUETOOTH_PLUGIN_DEFINE(“storage”, storage_init, storage_exit)  //no implementation actually
  6. BLUETOOTH_PLUGIN_DEFINE(“serial”, serial_init, serial_exit)

Implement on serial plugin

  1. Connect to dbus system bus;
  2. btd_register_adapter_driver(&serial_proxy_driver);
  3. btd_register_device_driver(&serial_port_driver);
  4. communicate others with socket and dbus;

Implement on echo

  1. Communicate RFCOMM with socket;
  2. Use IO channel for internal event;

Implement on audio

  1. Connect to Dbus system bus;
  2. Load audio.conf;
  3. According to settings, start headset, audio gateway, sink, source, control service;
  4. Register device drivers;

Implement on input

It is similar with audio.

原创粉丝点击