gatt

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2019 License: BSD-3-Clause Imports: 6 Imported by: 0

README

Generic Attribute Profile (GATT)

This package implement Generic Attribute Profile (GATT) [Vol 3, Part G]

Check list for ATT Client implementation.

Server Configuration [4.3]
  • Exchange MTU [4.3.1]
Primary Service Discovery [4.4]
  • Discover All Primary Service [4.4.1]
  • Discover Primary Service by Service UUID [4.4.2]
Relationship Discovery [4.5]
  • Find Included Services [4.5.1]
Characteristic Discovery [4.6]
  • Discover All Characteristics of a Service [4.6.1]
  • Discover Characteristics by UUID [4.6.2]
Characteristic Descriptors Discovery [4.7]
  • Discover All Characteristic Descriptors [4.7.1]
Characteristic Value Read [4.8]
  • Read Characteristic Value [4.8.1]
  • Read Using Characteristic UUID [4.8.2]
  • Read Long Characteristic Values [4.8.3]
  • Read Multiple Characteristic Values [4.8.4]
Characteristic Value Write [4.9]
  • Write Without Response [4.9.1]
  • Signed Write Without Response [4.9.2]
  • Write Characteristic Value [4.9.3]
  • Write Long Characteristic Values [4.9.4]
  • Reliable Writes [4.9.5]
Characteristic Value Notifications [4.10]
  • Notifications [4.10.1]
Characteristic Indications [4.11]
  • Indications [4.11.1]
Characteristic Descriptors [4.12]
  • Read Characteristic Descriptors [4.12.1]
  • Read Long Characteristic Descriptors [4.12.2]
  • Write Characteristic Descriptors [4.12.3]
  • Write Long Characteristic Descriptors [4.12.4]

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

A Client is a GATT Client.

func NewClient

func NewClient(conn ble.Conn) (*Client, error)

NewClient returns a GATT Client.

func (*Client) Address

func (p *Client) Address() ble.Addr

Address returns the address of the client.

func (*Client) CancelConnection

func (p *Client) CancelConnection() error

CancelConnection disconnects the connection.

func (*Client) ClearSubscriptions

func (p *Client) ClearSubscriptions() error

ClearSubscriptions clears all subscriptions to notifications and indications.

func (*Client) Connection

func (p *Client) Connection() ble.Conn

func (*Client) Disconnected

func (p *Client) Disconnected() <-chan struct{}

Disconnected returns a receiving channel, which is closed when the client disconnects.

func (*Client) DiscoverCharacteristics

func (p *Client) DiscoverCharacteristics(filter []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 (p *Client) DiscoverDescriptors(filter []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

func (p *Client) DiscoverIncludedServices(ss []ble.UUID, s *ble.Service) ([]*ble.Service, error)

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

func (p *Client) DiscoverProfile(force bool) (*ble.Profile, error)

DiscoverProfile discovers the whole hierachy of a server.

func (*Client) DiscoverServices

func (p *Client) DiscoverServices(filter []ble.UUID) ([]*ble.Service, error)

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

func (p *Client) ExchangeMTU(mtu int) (int, error)

ExchangeMTU informs the server of the client’s maximum receive MTU size and request the server to respond with its maximum receive MTU size. [Vol 3, Part F, 3.4.2.1]

func (*Client) HandleNotification

func (p *Client) HandleNotification(req []byte)

HandleNotification ...

func (*Client) Name

func (p *Client) Name() string

Name returns the name of the client.

func (*Client) Profile

func (p *Client) Profile() *ble.Profile

Profile returns the discovered profile.

func (*Client) ReadCharacteristic

func (p *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 (p *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 (p *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

func (p *Client) ReadRSSI() int

ReadRSSI retrieves the current RSSI value of remote peripheral. [Vol 2, Part E, 7.5.4]

func (*Client) Subscribe

func (p *Client) Subscribe(c *ble.Characteristic, ind bool, h 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 (p *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

func (p *Client) WriteCharacteristic(c *ble.Characteristic, v []byte, noRsp bool) error

WriteCharacteristic writes a characteristic value to a server. [Vol 3, Part G, 4.9.3]

func (*Client) WriteDescriptor

func (p *Client) WriteDescriptor(d *ble.Descriptor, v []byte) error

WriteDescriptor writes a characteristic descriptor to a server. [Vol 3, Part G, 4.12.3]

type Server

type Server struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Server ...

func NewServer

func NewServer() (*Server, error)

NewServer ...

func (*Server) AddService

func (s *Server) AddService(svc *ble.Service) error

AddService ...

func (*Server) DB

func (s *Server) DB() *att.DB

DB ...

func (*Server) RemoveAllServices

func (s *Server) RemoveAllServices() error

RemoveAllServices ...

func (*Server) SetServices

func (s *Server) SetServices(svcs []*ble.Service) error

SetServices ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL