Documentation ¶
Index ¶
- Variables
- type Client
- func (cln *Client) Address() ble.Addr
- func (cln *Client) CancelConnection(_ context.Context) error
- func (cln *Client) ClearSubscriptions() error
- func (cln *Client) Conn() ble.Conn
- func (cln *Client) Connection() ble.Conn
- func (cln *Client) DidDiscoverCharacteristics(_ cbgo.Peripheral, _ cbgo.Service, err error)
- func (cln *Client) DidDiscoverDescriptors(_ cbgo.Peripheral, _ cbgo.Characteristic, err error)
- func (cln *Client) DidDiscoverServices(_ cbgo.Peripheral, err error)
- func (cln *Client) DidReadRSSI(_ cbgo.Peripheral, rssi int, err error)
- func (cln *Client) DidUpdateNotificationState(_ cbgo.Peripheral, _ cbgo.Characteristic, err error)
- func (cln *Client) DidUpdateValueForCharacteristic(_ cbgo.Peripheral, chr cbgo.Characteristic, err error)
- func (cln *Client) DidUpdateValueForDescriptor(_ cbgo.Peripheral, _ cbgo.Descriptor, err error)
- func (cln *Client) DidWriteValueForCharacteristic(_ cbgo.Peripheral, _ cbgo.Characteristic, err error)
- func (cln *Client) DidWriteValueForDescriptor(_ cbgo.Peripheral, _ cbgo.Descriptor, err error)
- func (cln *Client) Disconnected() <-chan struct{}
- func (cln *Client) DiscoverCharacteristics(cs []ble.UUID, s *ble.Service) ([]*ble.Characteristic, error)
- func (cln *Client) DiscoverDescriptors(_ []ble.UUID, c *ble.Characteristic) ([]*ble.Descriptor, error)
- func (cln *Client) DiscoverIncludedServices(_ []ble.UUID, _ *ble.Service) ([]*ble.Service, error)
- func (cln *Client) DiscoverProfile(force bool) (*ble.Profile, error)
- func (cln *Client) DiscoverServices(ss []ble.UUID) ([]*ble.Service, error)
- func (cln *Client) ExchangeMTU(_ int) (int, error)
- func (cln *Client) Name() string
- func (cln *Client) Profile() *ble.Profile
- func (cln *Client) ReadCharacteristic(c *ble.Characteristic) ([]byte, error)
- func (cln *Client) ReadDescriptor(d *ble.Descriptor) ([]byte, error)
- func (cln *Client) ReadLongCharacteristic(c *ble.Characteristic) ([]byte, error)
- func (cln *Client) ReadRSSI() int
- func (cln *Client) Subscribe(c *ble.Characteristic, _ bool, fn ble.NotificationHandler) error
- func (cln *Client) Unsubscribe(c *ble.Characteristic, _ bool) error
- func (cln *Client) WriteCharacteristic(c *ble.Characteristic, b []byte, noRsp bool) error
- func (cln *Client) WriteDescriptor(d *ble.Descriptor, b []byte) error
- type Device
- func (d *Device) AddService(svc *ble.Service) error
- func (d *Device) Advertise(ctx context.Context, adv ble.Advertisement) error
- func (d *Device) AdvertiseIBeacon(ctx context.Context, u ble.UUID, major, minor uint16, pwr int8) error
- func (d *Device) AdvertiseIBeaconData(ctx context.Context, b []byte) error
- func (d *Device) AdvertiseMfgData(ctx context.Context, id uint16, b []byte) error
- func (d *Device) AdvertiseNameAndServices(ctx context.Context, name string, uuids ...ble.UUID) error
- func (d *Device) AdvertiseServiceData16(ctx context.Context, id uint16, b []byte) error
- func (d *Device) CentralDidSubscribe(pmgr cbgo.PeripheralManager, cent cbgo.Central, cbchr cbgo.Characteristic)
- func (d *Device) CentralDidUnsubscribe(pmgr cbgo.PeripheralManager, cent cbgo.Central, chr cbgo.Characteristic)
- func (d *Device) CentralManagerDidUpdateState(cmgr cbgo.CentralManager)
- func (d *Device) Close() error
- func (d *Device) Closed() <-chan struct{}
- func (d *Device) DialBLE(ctx context.Context, addr ble.Addr, addrType ble.AddressType) (ble.ClientBLE, error)
- func (d *Device) DialRFCOMM(ctx context.Context, a ble.Addr, clockOffset uint16, ...) (ble.ClientRFCOMM, error)
- func (d *Device) DidAddService(pmgr cbgo.PeripheralManager, svc cbgo.Service, err error)
- func (d *Device) DidConnectPeripheral(_ cbgo.CentralManager, prph cbgo.Peripheral)
- func (d *Device) DidDisconnectPeripheral(cmgr cbgo.CentralManager, prph cbgo.Peripheral, err error)
- func (d *Device) DidDiscoverPeripheral(cmgr cbgo.CentralManager, prph cbgo.Peripheral, advFields cbgo.AdvFields, ...)
- func (d *Device) DidReceiveReadRequest(pmgr cbgo.PeripheralManager, cbreq cbgo.ATTRequest)
- func (d *Device) DidReceiveWriteRequests(pmgr cbgo.PeripheralManager, cbreqs []cbgo.ATTRequest)
- func (d *Device) DidStartAdvertising(pmgr cbgo.PeripheralManager, err error)
- func (d *Device) Initialize(ctx context.Context) error
- func (d *Device) Inquire(ctx context.Context, interval time.Duration, numResponses int, ...) error
- func (d *Device) PeripheralManagerDidUpdateState(pmgr cbgo.PeripheralManager)
- func (d *Device) RemoveAllServices() error
- func (d *Device) RequestRemoteName(ctx context.Context, a ble.Addr) (string, error)
- func (d *Device) Scan(ctx context.Context, allowDup bool, h ble.AdvHandler) (err error)
- func (d *Device) SetAdvParams(param cmd.LESetAdvertisingParameters) error
- func (d *Device) SetCentralRole() error
- func (d *Device) SetConnParams(param cmd.LECreateConnection) error
- func (d *Device) SetConnectedHandler(f func(evt.LEConnectionComplete)) error
- func (d *Device) SetDeviceID(id int) error
- func (d *Device) SetDialerTimeout(dur time.Duration) error
- func (d *Device) SetDisconnectedHandler(f func(ble.Conn)) error
- func (d *Device) SetListenerTimeout(dur time.Duration) error
- func (d *Device) SetPeripheralRole() error
- func (d *Device) SetScanParams(param cmd.LESetScanParameters) error
- func (d *Device) SetServices(svcs []*ble.Service) error
- func (d *Device) Stop() error
- type State
Constants ¶
This section is empty.
Variables ¶
var ( ErrClosed = errors.New("closed") ErrNotSupported = errors.New("not supported") )
var ErrDisconnected = errors.New("disconnected")
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { cbgo.PeripheralDelegateBase // contains filtered or unexported fields }
A Client is a GATT client.
func (*Client) CancelConnection ¶
CancelConnection disconnects the connection.
func (*Client) ClearSubscriptions ¶
ClearSubscriptions clears all subscriptions to notifications and indications.
func (*Client) Connection ¶
func (*Client) DidDiscoverCharacteristics ¶ added in v0.0.9
func (*Client) DidDiscoverDescriptors ¶ added in v0.0.9
func (cln *Client) DidDiscoverDescriptors(_ cbgo.Peripheral, _ cbgo.Characteristic, err error)
func (*Client) DidDiscoverServices ¶ added in v0.0.9
func (cln *Client) DidDiscoverServices(_ cbgo.Peripheral, err error)
func (*Client) DidReadRSSI ¶ added in v0.0.9
func (cln *Client) DidReadRSSI(_ cbgo.Peripheral, rssi int, err error)
func (*Client) DidUpdateNotificationState ¶ added in v0.0.9
func (cln *Client) DidUpdateNotificationState(_ cbgo.Peripheral, _ cbgo.Characteristic, err error)
func (*Client) DidUpdateValueForCharacteristic ¶ added in v0.0.9
func (cln *Client) DidUpdateValueForCharacteristic(_ cbgo.Peripheral, chr cbgo.Characteristic, err error)
func (*Client) DidUpdateValueForDescriptor ¶ added in v0.0.9
func (cln *Client) DidUpdateValueForDescriptor(_ cbgo.Peripheral, _ cbgo.Descriptor, err error)
func (*Client) DidWriteValueForCharacteristic ¶ added in v0.0.9
func (cln *Client) DidWriteValueForCharacteristic(_ cbgo.Peripheral, _ cbgo.Characteristic, err error)
func (*Client) DidWriteValueForDescriptor ¶ added in v0.0.9
func (cln *Client) DidWriteValueForDescriptor(_ cbgo.Peripheral, _ cbgo.Descriptor, err error)
func (*Client) Disconnected ¶
func (cln *Client) Disconnected() <-chan struct{}
Disconnected returns a receiving channel, which is closed when the client disconnects.
func (*Client) DiscoverCharacteristics ¶
func (cln *Client) DiscoverCharacteristics(cs []ble.UUID, s *ble.Service) ([]*ble.Characteristic, error)
DiscoverCharacteristics finds all the characteristics within a service. [Vol 3, Part G, 4.6.1] If filter is specified, only filtered characteristics are returned.
func (*Client) DiscoverDescriptors ¶
func (cln *Client) DiscoverDescriptors(_ []ble.UUID, c *ble.Characteristic) ([]*ble.Descriptor, error)
DiscoverDescriptors finds all the descriptors within a characteristic. [Vol 3, Part G, 4.7.1] If filter is specified, only filtered descriptors are returned.
func (*Client) DiscoverIncludedServices ¶
DiscoverIncludedServices finds the included services of a service. [Vol 3, Part G, 4.5.1] If filter is specified, only filtered services are returned.
func (*Client) DiscoverProfile ¶
DiscoverProfile discovers the whole hierarchy of a server.
func (*Client) DiscoverServices ¶
DiscoverServices finds all the primary services on a server. [Vol 3, Part G, 4.4.1] If filter is specified, only filtered services are returned.
func (*Client) ExchangeMTU ¶
ExchangeMTU set the ATT_MTU to the maximum possible value that can be supported by both devices [Vol 3, Part G, 4.3.1]
func (*Client) Name ¶
Name returns the name of the remote peripheral. This can be the advertised name, if exists, or the GAP device name, which takes priority.
func (*Client) ReadCharacteristic ¶
func (cln *Client) ReadCharacteristic(c *ble.Characteristic) ([]byte, error)
ReadCharacteristic reads a characteristic value from a server. [Vol 3, Part G, 4.8.1]
func (*Client) ReadDescriptor ¶
func (cln *Client) ReadDescriptor(d *ble.Descriptor) ([]byte, error)
ReadDescriptor reads a characteristic descriptor from a server. [Vol 3, Part G, 4.12.1]
func (*Client) ReadLongCharacteristic ¶
func (cln *Client) ReadLongCharacteristic(c *ble.Characteristic) ([]byte, error)
ReadLongCharacteristic reads a characteristic value which is longer than the MTU. [Vol 3, Part G, 4.8.3]
func (*Client) ReadRSSI ¶
ReadRSSI retrieves the current RSSI value of remote peripheral. [Vol 2, Part E, 7.5.4]
func (*Client) Subscribe ¶
func (cln *Client) Subscribe(c *ble.Characteristic, _ bool, fn ble.NotificationHandler) error
Subscribe subscribes to indication (if ind is set true), or notification of a characteristic value. [Vol 3, Part G, 4.10 & 4.11]
func (*Client) Unsubscribe ¶
func (cln *Client) Unsubscribe(c *ble.Characteristic, _ bool) error
Unsubscribe unsubscribes to indication (if ind is set true), or notification of a specified characteristic value. [Vol 3, Part G, 4.10 & 4.11]
func (*Client) WriteCharacteristic ¶
WriteCharacteristic writes a characteristic value to a server. [Vol 3, Part G, 4.9.3]
func (*Client) WriteDescriptor ¶
func (cln *Client) WriteDescriptor(d *ble.Descriptor, b []byte) error
WriteDescriptor writes a characteristic descriptor to a server. [Vol 3, Part G, 4.12.3]
type Device ¶
type Device struct { // Embed these two bases so we don't have to override all the esoteric // functions defined by CoreBluetooth delegate interfaces. cbgo.CentralManagerDelegateBase cbgo.PeripheralManagerDelegateBase // contains filtered or unexported fields }
Device is either a Peripheral or Central device.
func (*Device) AdvertiseIBeacon ¶
func (*Device) AdvertiseIBeaconData ¶
func (*Device) AdvertiseMfgData ¶
func (*Device) AdvertiseNameAndServices ¶
func (*Device) AdvertiseServiceData16 ¶
func (*Device) CentralDidSubscribe ¶ added in v0.0.9
func (d *Device) CentralDidSubscribe(pmgr cbgo.PeripheralManager, cent cbgo.Central, cbchr cbgo.Characteristic)
func (*Device) CentralDidUnsubscribe ¶ added in v0.0.9
func (d *Device) CentralDidUnsubscribe(pmgr cbgo.PeripheralManager, cent cbgo.Central, chr cbgo.Characteristic)
func (*Device) CentralManagerDidUpdateState ¶ added in v0.0.9
func (d *Device) CentralManagerDidUpdateState(cmgr cbgo.CentralManager)
func (*Device) DialBLE ¶ added in v0.0.9
func (d *Device) DialBLE(ctx context.Context, addr ble.Addr, addrType ble.AddressType) (ble.ClientBLE, error)
Dial ...
func (*Device) DialRFCOMM ¶
func (*Device) DidAddService ¶ added in v0.0.9
func (*Device) DidConnectPeripheral ¶ added in v0.0.9
func (d *Device) DidConnectPeripheral(_ cbgo.CentralManager, prph cbgo.Peripheral)
func (*Device) DidDisconnectPeripheral ¶ added in v0.0.9
func (d *Device) DidDisconnectPeripheral(cmgr cbgo.CentralManager, prph cbgo.Peripheral, err error)
func (*Device) DidDiscoverPeripheral ¶ added in v0.0.9
func (d *Device) DidDiscoverPeripheral(cmgr cbgo.CentralManager, prph cbgo.Peripheral, advFields cbgo.AdvFields, rssi int)
func (*Device) DidReceiveReadRequest ¶ added in v0.0.9
func (d *Device) DidReceiveReadRequest(pmgr cbgo.PeripheralManager, cbreq cbgo.ATTRequest)
func (*Device) DidReceiveWriteRequests ¶ added in v0.0.9
func (d *Device) DidReceiveWriteRequests(pmgr cbgo.PeripheralManager, cbreqs []cbgo.ATTRequest)
func (*Device) DidStartAdvertising ¶ added in v0.0.9
func (d *Device) DidStartAdvertising(pmgr cbgo.PeripheralManager, err error)
func (*Device) PeripheralManagerDidUpdateState ¶ added in v0.0.9
func (d *Device) PeripheralManagerDidUpdateState(pmgr cbgo.PeripheralManager)
func (*Device) RemoveAllServices ¶
func (*Device) RequestRemoteName ¶
func (*Device) SetAdvParams ¶ added in v0.0.6
func (d *Device) SetAdvParams(param cmd.LESetAdvertisingParameters) error
SetAdvParams overrides default advertising parameters.
func (*Device) SetCentralRole ¶ added in v0.0.6
SetCentralRole configures the device to perform Central tasks.
func (*Device) SetConnParams ¶ added in v0.0.6
func (d *Device) SetConnParams(param cmd.LECreateConnection) error
SetConnParams overrides default connection parameters.
func (*Device) SetConnectedHandler ¶ added in v0.0.6
func (d *Device) SetConnectedHandler(f func(evt.LEConnectionComplete)) error
SetConnectedHandler sets handler to be called when new connection is established.
func (*Device) SetDeviceID ¶ added in v0.0.6
SetDeviceID sets HCI device ID.
func (*Device) SetDialerTimeout ¶ added in v0.0.6
SetDialerTimeout sets dialing timeout for Dialer.
func (*Device) SetDisconnectedHandler ¶ added in v0.0.6
SetDisconnectedHandler sets handler to be called on disconnect.
func (*Device) SetListenerTimeout ¶ added in v0.0.6
SetListenerTimeout sets dialing timeout for Listener.
func (*Device) SetPeripheralRole ¶ added in v0.0.6
SetPeripheralRole configures the device to perform Peripheral tasks.
func (*Device) SetScanParams ¶ added in v0.0.6
func (d *Device) SetScanParams(param cmd.LESetScanParameters) error
SetScanParams overrides default scanning parameters.