Documentation
¶
Overview ¶
Package bluetooth is a high level dbus warp for bluez5. You SHOULD always use dbus to call the interface of Bluetooth.
The dbus interface of bluetooth to operate bluez is designed to asynchronous, and all result is returned by signal. Other interface to get adapter/device informations will return immediately, because it was cached.
Index ¶
- Constants
- func GetTimerNotifyInstance() *timerNotify
- type AdapterInfo
- type AdapterInfos
- type Bluetooth
- func (b *Bluetooth) CancelTransferSession(sessionPath dbus.ObjectPath) *dbus.Error
- func (b *Bluetooth) ClearUnpairedDevice() *dbus.Error
- func (b *Bluetooth) Confirm(device dbus.ObjectPath, accept bool) *dbus.Error
- func (b *Bluetooth) ConnectDevice(device dbus.ObjectPath, apath dbus.ObjectPath) *dbus.Error
- func (b *Bluetooth) DebugInfo() (info string, busErr *dbus.Error)
- func (b *Bluetooth) DisconnectDevice(device dbus.ObjectPath) *dbus.Error
- func (b *Bluetooth) FeedPasskey(device dbus.ObjectPath, accept bool, passkey uint32) *dbus.Error
- func (b *Bluetooth) FeedPinCode(device dbus.ObjectPath, accept bool, pinCode string) *dbus.Error
- func (b *Bluetooth) GetAdapters() (adaptersJSON string, busErr *dbus.Error)
- func (b *Bluetooth) GetDevices(adapter dbus.ObjectPath) (devicesJSON string, busErr *dbus.Error)
- func (v *Bluetooth) GetExportedMethods() dbusutil.ExportedMethods
- func (*Bluetooth) GetInterfaceName() string
- func (b *Bluetooth) RemoveDevice(adapter, device dbus.ObjectPath) *dbus.Error
- func (b *Bluetooth) RequestDiscovery(adapter dbus.ObjectPath) *dbus.Error
- func (b *Bluetooth) SendFiles(devAddress string, files []string) (sessionPath dbus.ObjectPath, busErr *dbus.Error)
- func (b *Bluetooth) SetAdapterAlias(adapter dbus.ObjectPath, alias string) *dbus.Error
- func (b *Bluetooth) SetAdapterDiscoverable(adapter dbus.ObjectPath, discoverable bool) *dbus.Error
- func (b *Bluetooth) SetAdapterDiscoverableTimeout(adapter dbus.ObjectPath, discoverableTimeout uint32) *dbus.Error
- func (b *Bluetooth) SetAdapterDiscovering(adapter dbus.ObjectPath, discovering bool) *dbus.Error
- func (b *Bluetooth) SetAdapterPowered(adapter dbus.ObjectPath, powered bool) *dbus.Error
- func (b *Bluetooth) SetDeviceAlias(device dbus.ObjectPath, alias string) *dbus.Error
- func (b *Bluetooth) SetDeviceTrusted(device dbus.ObjectPath, trusted bool) *dbus.Error
- type DeviceInfo
- type DeviceInfoMap
- type DeviceInfos
Constants ¶
const ( GENERIC_AUDIO_UUID = "00001203-0000-1000-8000-00805f9b34fb" HSP_HS_UUID = "00001108-0000-1000-8000-00805f9b34fb" HSP_AG_UUID = "00001112-0000-1000-8000-00805f9b34fb" HFP_HS_UUID = "0000111e-0000-1000-8000-00805f9b34fb" HFP_AG_UUID = "0000111f-0000-1000-8000-00805f9b34fb" ADVANCED_AUDIO_UUID = "0000110d-0000-1000-8000-00805f9b34fb" A2DP_SOURCE_UUID = "0000110a-0000-1000-8000-00805f9b34fb" A2DP_SINK_UUID = "0000110b-0000-1000-8000-00805f9b34fb" AVRCP_REMOTE_UUID = "0000110e-0000-1000-8000-00805f9b34fb" AVRCP_TARGET_UUID = "0000110c-0000-1000-8000-00805f9b34fb" PANU_UUID = "00001115-0000-1000-8000-00805f9b34fb" NAP_UUID = "00001116-0000-1000-8000-00805f9b34fb" GN_UUID = "00001117-0000-1000-8000-00805f9b34fb" BNEP_SVC_UUID = "0000000f-0000-1000-8000-00805f9b34fb" PNPID_UUID = "00002a50-0000-1000-8000-00805f9b34fb" DEVICE_INFORMATION_UUID = "0000180a-0000-1000-8000-00805f9b34fb" GATT_UUID = "00001801-0000-1000-8000-00805f9b34fb" IMMEDIATE_ALERT_UUID = "00001802-0000-1000-8000-00805f9b34fb" LINK_LOSS_UUID = "00001803-0000-1000-8000-00805f9b34fb" TX_POWER_UUID = "00001804-0000-1000-8000-00805f9b34fb" SAP_UUID = "0000112D-0000-1000-8000-00805f9b34fb" HEART_RATE_UUID = "0000180d-0000-1000-8000-00805f9b34fb" HEART_RATE_MEASUREMENT_UUID = "00002a37-0000-1000-8000-00805f9b34fb" BODY_SENSOR_LOCATION_UUID = "00002a38-0000-1000-8000-00805f9b34fb" HEART_RATE_CONTROL_POINT_UUID = "00002a39-0000-1000-8000-00805f9b34fb" HEALTH_THERMOMETER_UUID = "00001809-0000-1000-8000-00805f9b34fb" TEMPERATURE_MEASUREMENT_UUID = "00002a1c-0000-1000-8000-00805f9b34fb" TEMPERATURE_TYPE_UUID = "00002a1d-0000-1000-8000-00805f9b34fb" INTERMEDIATE_TEMPERATURE_UUID = "00002a1e-0000-1000-8000-00805f9b34fb" MEASUREMENT_INTERVAL_UUID = "00002a21-0000-1000-8000-00805f9b34fb" CYCLING_SC_UUID = "00001816-0000-1000-8000-00805f9b34fb" CSC_MEASUREMENT_UUID = "00002a5b-0000-1000-8000-00805f9b34fb" CSC_FEATURE_UUID = "00002a5c-0000-1000-8000-00805f9b34fb" SENSOR_LOCATION_UUID = "00002a5d-0000-1000-8000-00805f9b34fb" SC_CONTROL_POINT_UUID = "00002a55-0000-1000-8000-00805f9b34fb" RFCOMM_UUID_STR = "00000003-0000-1000-8000-00805f9b34fb" HDP_UUID = "00001400-0000-1000-8000-00805f9b34fb" HDP_SOURCE_UUID = "00001401-0000-1000-8000-00805f9b34fb" HDP_SINK_UUID = "00001402-0000-1000-8000-00805f9b34fb" HID_UUID = "00001124-0000-1000-8000-00805f9b34fb" DUN_GW_UUID = "00001103-0000-1000-8000-00805f9b34fb" GAP_UUID = "00001800-0000-1000-8000-00805f9b34fb" PNP_UUID = "00001200-0000-1000-8000-00805f9b34fb" SPP_UUID = "00001101-0000-1000-8000-00805f9b34fb" OBEX_SYNC_UUID = "00001104-0000-1000-8000-00805f9b34fb" OBEX_OPP_UUID = "00001105-0000-1000-8000-00805f9b34fb" OBEX_FTP_UUID = "00001106-0000-1000-8000-00805f9b34fb" OBEX_PCE_UUID = "0000112e-0000-1000-8000-00805f9b34fb" OBEX_PSE_UUID = "0000112f-0000-1000-8000-00805f9b34fb" OBEX_PBAP_UUID = "00001130-0000-1000-8000-00805f9b34fb" OBEX_MAS_UUID = "00001132-0000-1000-8000-00805f9b34fb" OBEX_MNS_UUID = "00001133-0000-1000-8000-00805f9b34fb" OBEX_MAP_UUID = "00001134-0000-1000-8000-00805f9b34fb" /* GATT UUIDs section */ GATT_PRIM_SVC_UUID = 0x2800 GATT_SND_SVC_UUID = 0x2801 GATT_INCLUDE_UUID = 0x2802 GATT_CHARAC_UUID = 0x2803 /* GATT Characteristic Types */ GATT_CHARAC_DEVICE_NAME = 0x2A00 GATT_CHARAC_APPEARANCE = 0x2A01 GATT_CHARAC_PERIPHERAL_PRIV_FLAG = 0x2A02 GATT_CHARAC_RECONNECTION_ADDRESS = 0x2A03 GATT_CHARAC_PERIPHERAL_PREF_CONN = 0x2A04 GATT_CHARAC_SERVICE_CHANGED = 0x2A05 /* GATT Characteristic Descriptors */ GATT_CHARAC_EXT_PROPER_UUID = 0x2900 GATT_CHARAC_USER_DESC_UUID = 0x2901 GATT_CLIENT_CHARAC_CFG_UUID = 0x2902 GATT_SERVER_CHARAC_CFG_UUID = 0x2903 GATT_CHARAC_FMT_UUID = 0x2904 GATT_CHARAC_AGREG_FMT_UUID = 0x2905 GATT_CHARAC_VALID_RANGE_UUID = 0x2906 GATT_EXTERNAL_REPORT_REFERENCE = 0x2907 GATT_REPORT_REFERENCE = 0x2908 )
Variables ¶
This section is empty.
Functions ¶
func GetTimerNotifyInstance ¶
func GetTimerNotifyInstance() *timerNotify
GetTimerNotifyInstance get timer instance
Types ¶
type AdapterInfo ¶
type AdapterInfos ¶
type AdapterInfos struct {
// contains filtered or unexported fields
}
type Bluetooth ¶
type Bluetooth struct { PropsMu sync.RWMutex State uint32 // StateUnavailable/StateAvailable/StateConnected Transportable bool //能否传输 True可以传输 false不能传输 CanSendFile bool //dbusutil-gen: ignore DisplaySwitch gsprop.Bool `prop:"access:rw"` // contains filtered or unexported fields }
func (*Bluetooth) CancelTransferSession ¶
func (b *Bluetooth) CancelTransferSession(sessionPath dbus.ObjectPath) *dbus.Error
CancelTransferSession 用来取消发送的会话,将会终止会话中所有的传送任务
func (*Bluetooth) ClearUnpairedDevice ¶
ClearUnpairedDevice will remove all device in unpaired list
func (*Bluetooth) ConnectDevice ¶
func (b *Bluetooth) ConnectDevice(device dbus.ObjectPath, apath dbus.ObjectPath) *dbus.Error
func (*Bluetooth) DisconnectDevice ¶
func (b *Bluetooth) DisconnectDevice(device dbus.ObjectPath) *dbus.Error
func (*Bluetooth) FeedPasskey ¶
FeedPasskey should call when you receive RequestPasskey signal, notice that accept must true if you accept connect request. If accept is false, passkey will be ignored. passkey must be range in 0~999999.
func (*Bluetooth) FeedPinCode ¶
FeedPinCode should call when you receive RequestPinCode signal, notice that accept must true if you accept connect request. If accept is false, pinCode will be ignored.
func (*Bluetooth) GetAdapters ¶
GetAdapters return all adapter objects that marshaled by json.
func (*Bluetooth) GetDevices ¶
GetDevices return all device objects that marshaled by json.
func (*Bluetooth) GetExportedMethods ¶
func (v *Bluetooth) GetExportedMethods() dbusutil.ExportedMethods
func (*Bluetooth) GetInterfaceName ¶
func (*Bluetooth) RemoveDevice ¶
func (b *Bluetooth) RemoveDevice(adapter, device dbus.ObjectPath) *dbus.Error
func (*Bluetooth) RequestDiscovery ¶
func (b *Bluetooth) RequestDiscovery(adapter dbus.ObjectPath) *dbus.Error
func (*Bluetooth) SendFiles ¶
func (b *Bluetooth) SendFiles(devAddress string, files []string) (sessionPath dbus.ObjectPath, busErr *dbus.Error)
SendFiles 用来发送文件给蓝牙设备,仅支持发送给已连接设备
func (*Bluetooth) SetAdapterAlias ¶
func (*Bluetooth) SetAdapterDiscoverable ¶
func (*Bluetooth) SetAdapterDiscoverableTimeout ¶
func (*Bluetooth) SetAdapterDiscovering ¶
func (*Bluetooth) SetAdapterPowered ¶
func (*Bluetooth) SetDeviceAlias ¶
func (*Bluetooth) SetDeviceTrusted ¶
type DeviceInfo ¶
type DeviceInfoMap ¶
type DeviceInfoMap struct {
// contains filtered or unexported fields
}
type DeviceInfos ¶
type DeviceInfos []DeviceInfo