Documentation ¶
Index ¶
- type Client
- func (cln *Client) Addr() ble.Addr
- func (cln *Client) CancelConnection() error
- func (cln *Client) ClearSubscriptions() error
- func (cln *Client) Disconnected() <-chan struct{}
- func (cln *Client) DiscoverCharacteristics(cs []ble.UUID, s *ble.Service) ([]*ble.Characteristic, error)
- func (cln *Client) DiscoverDescriptors(ds []ble.UUID, c *ble.Characteristic) ([]*ble.Descriptor, error)
- func (cln *Client) DiscoverIncludedServices(ss []ble.UUID, s *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(mtu 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, ind bool, fn ble.NotificationHandler) error
- func (cln *Client) Unsubscribe(c *ble.Characteristic, ind 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(s *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, md []byte) error
- func (d *Device) AdvertiseMfgData(ctx context.Context, id uint16, md []byte) error
- func (d *Device) AdvertiseNameAndServices(ctx context.Context, name string, ss ...ble.UUID) error
- func (d *Device) AdvertiseServiceData16(ctx context.Context, id uint16, b []byte) error
- func (d *Device) Dial(ctx context.Context, a ble.Addr) (ble.Client, error)
- func (d *Device) HandleXpcEvent(event xpc.Dict, err error)
- func (d *Device) Init() error
- func (d *Device) Option(opts ...Option) error
- func (d *Device) RemoveAllServices() error
- func (d *Device) Scan(ctx context.Context, allowDup bool, h ble.AdvHandler) error
- func (d *Device) SetServices(ss []*ble.Service) error
- func (d *Device) Stop() error
- type Option
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// 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) 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(ds []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, ind 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, ind 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 {
// contains filtered or unexported fields
}
Device is either a Peripheral or Central device.
func (*Device) AddService ¶
AddService adds a service to device's database. The following services are ignored as they are provided by OS X.
0x1800 (Generic Access) 0x1801 (Generic Attribute) 0x1805 (Current Time Service) 0x180A (Device Information) 0x180F (Battery Service) 0x1812 (Human Interface Device)
func (*Device) AdvertiseIBeacon ¶
func (d *Device) AdvertiseIBeacon(ctx context.Context, u ble.UUID, major, minor uint16, pwr int8) error
AdvertiseIBeacon advertises iBeacon packet.
func (*Device) AdvertiseIBeaconData ¶
AdvertiseIBeaconData advertises iBeacon packet with specified manufacturer data.
func (*Device) AdvertiseMfgData ¶
AdvertiseMfgData ...
func (*Device) AdvertiseNameAndServices ¶
AdvertiseNameAndServices advertises name and specifid service UUIDs.
func (*Device) AdvertiseServiceData16 ¶
AdvertiseServiceData16 advertises data associated with a 16bit service uuid
func (*Device) HandleXpcEvent ¶
HandleXpcEvent process Device events and asynchronous errors.
func (*Device) RemoveAllServices ¶
RemoveAllServices removes all services of device's
type Option ¶
An Option is a configuration function, which configures the device.
func OptCentralRole ¶
func OptCentralRole() Option
OptCentralRole configures the device to perform Central tasks.
func OptPeripheralRole ¶
func OptPeripheralRole() Option
OptPeripheralRole configures the device to perform Peripheral tasks.