Versions in this module Expand all Collapse all v0 v0.0.2 Mar 5, 2020 v0.0.1 May 13, 2019 Changes in this version + const DefaultMTU + const MaxMTU + var AppearanceUUID = UUID16(0x2A01) + var BatteryUUID = UUID16(0x180F) + var CharacteristicUUID = UUID16(0x2803) + var ClientCharacteristicConfigUUID = UUID16(0x2902) + var ContextKeyCCC = ContextKey("ccc") + var ContextKeySig = ContextKey("sig") + var CurrentTimeUUID = UUID16(0x1805) + var DeviceInfoUUID = UUID16(0x180A) + var DeviceNameUUID = UUID16(0x2A00) + var ErrDefaultDevice = errors.New("default device is not set") + var ErrEIRPacketTooLong = errors.New("max packet length is 31") + var ErrNotImplemented = errors.New("not implemented") + var GAPUUID = UUID16(0x1800) + var GATTUUID = UUID16(0x1801) + var HIDUUID = UUID16(0x1812) + var IncludeUUID = UUID16(0x2802) + var PeferredParamsUUID = UUID16(0x2A04) + var PeripheralPrivacyUUID = UUID16(0x2A02) + var PrimaryServiceUUID = UUID16(0x2800) + var ReconnectionAddrUUID = UUID16(0x2A03) + var SecondaryServiceUUID = UUID16(0x2801) + var ServerCharacteristicConfigUUID = UUID16(0x2903) + var ServiceChangedUUID = UUID16(0x2A05) + func AddService(svc *Service) error + func AdvertiseIBeacon(ctx context.Context, u UUID, major, minor uint16, pwr int8) error + func AdvertiseIBeaconData(ctx context.Context, b []byte) error + func AdvertiseNameAndServices(ctx context.Context, name string, uuids ...UUID) error + func Contains(s []UUID, u UUID) bool + func Name(u UUID) string + func RemoveAllServices() error + func Reverse(u []byte) []byte + func Scan(ctx context.Context, allowDup bool, h AdvHandler, f AdvFilter) error + func SetDefaultDevice(d Device) + func SetServices(svcs []*Service) error + func Stop() error + func WithSigHandler(ctx context.Context, cancel func()) context.Context + type ATTError byte + const ErrAttrNotFound + const ErrAttrNotLong + const ErrAuthentication + const ErrAuthorization + const ErrInsuffEnc + const ErrInsuffEncrKeySize + const ErrInsuffResources + const ErrInvalAttrValueLen + const ErrInvalidHandle + const ErrInvalidOffset + const ErrInvalidPDU + const ErrPrepQueueFull + const ErrReadNotPerm + const ErrReqNotSupp + const ErrSuccess + const ErrUnlikely + const ErrUnsuppGrpType + const ErrWriteNotPerm + func (e ATTError) Error() string + type Addr interface + String func() string + func NewAddr(s string) Addr + type AdvFilter func(a Advertisement) bool + type AdvHandler func(a Advertisement) + type Advertisement interface + Addr func() Addr + Connectable func() bool + LocalName func() string + ManufacturerData func() []byte + OverflowService func() []UUID + RSSI func() int + ServiceData func() []ServiceData + Services func() []UUID + SolicitedService func() []UUID + TxPowerLevel func() int + func Find(ctx context.Context, allowDup bool, f AdvFilter) ([]Advertisement, error) + type Characteristic struct + CCCD *Descriptor + Descriptors []*Descriptor + EndHandle uint16 + Handle uint16 + IndicateHandler NotifyHandler + NotifyHandler NotifyHandler + Property Property + ReadHandler ReadHandler + Secure Property + UUID UUID + Value []byte + ValueHandle uint16 + WriteHandler WriteHandler + func NewCharacteristic(u UUID) *Characteristic + func (c *Characteristic) AddDescriptor(d *Descriptor) *Descriptor + func (c *Characteristic) HandleIndicate(h NotifyHandler) + func (c *Characteristic) HandleNotify(h NotifyHandler) + func (c *Characteristic) HandleRead(h ReadHandler) + func (c *Characteristic) HandleWrite(h WriteHandler) + func (c *Characteristic) NewDescriptor(u UUID) *Descriptor + func (c *Characteristic) SetValue(b []byte) + type Client interface + Addr func() Addr + CancelConnection func() error + ClearSubscriptions func() error + Conn func() Conn + Disconnected func() <-chan struct{} + DiscoverCharacteristics func(filter []UUID, s *Service) ([]*Characteristic, error) + DiscoverDescriptors func(filter []UUID, c *Characteristic) ([]*Descriptor, error) + DiscoverIncludedServices func(filter []UUID, s *Service) ([]*Service, error) + DiscoverProfile func(force bool) (*Profile, error) + DiscoverServices func(filter []UUID) ([]*Service, error) + ExchangeMTU func(rxMTU int) (txMTU int, err error) + Name func() string + Profile func() *Profile + ReadCharacteristic func(c *Characteristic) ([]byte, error) + ReadDescriptor func(d *Descriptor) ([]byte, error) + ReadLongCharacteristic func(c *Characteristic) ([]byte, error) + ReadRSSI func() int + Subscribe func(c *Characteristic, ind bool, h NotificationHandler) error + Unsubscribe func(c *Characteristic, ind bool) error + WriteCharacteristic func(c *Characteristic, value []byte, noRsp bool) error + WriteDescriptor func(d *Descriptor, v []byte) error + func Connect(ctx context.Context, f AdvFilter) (Client, error) + func Dial(ctx context.Context, a Addr) (Client, error) + type Conn interface + Context func() context.Context + Disconnected func() <-chan struct{} + LocalAddr func() Addr + RemoteAddr func() Addr + RxMTU func() int + SetContext func(ctx context.Context) + SetRxMTU func(mtu int) + SetTxMTU func(mtu int) + TxMTU func() int + type ContextKey string + type Descriptor struct + Handle uint16 + Property Property + ReadHandler ReadHandler + UUID UUID + Value []byte + WriteHandler WriteHandler + func NewDescriptor(u UUID) *Descriptor + func (d *Descriptor) HandleRead(h ReadHandler) + func (d *Descriptor) HandleWrite(h WriteHandler) + func (d *Descriptor) SetValue(b []byte) + type Device interface + AddService func(svc *Service) error + Advertise func(ctx context.Context, adv Advertisement) error + AdvertiseIBeacon func(ctx context.Context, u UUID, major, minor uint16, pwr int8) error + AdvertiseIBeaconData func(ctx context.Context, b []byte) error + AdvertiseMfgData func(ctx context.Context, id uint16, b []byte) error + AdvertiseNameAndServices func(ctx context.Context, name string, uuids ...UUID) error + AdvertiseServiceData16 func(ctx context.Context, id uint16, b []byte) error + Dial func(ctx context.Context, a Addr) (Client, error) + RemoveAllServices func() error + Scan func(ctx context.Context, allowDup bool, h AdvHandler) error + SetServices func(svcs []*Service) error + Stop func() error + type DeviceOption interface + SetAdvParams func(cmd.LESetAdvertisingParameters) error + SetCentralRole func() error + SetConnParams func(cmd.LECreateConnection) error + SetDeviceID func(int) error + SetDialerTimeout func(time.Duration) error + SetListenerTimeout func(time.Duration) error + SetPeripheralRole func() error + SetScanParams func(cmd.LESetScanParameters) error + type NotificationHandler func(req []byte) + type Notifier interface + Cap func() int + Close func() error + Context func() context.Context + Write func(b []byte) (int, error) + func NewNotifier(send func([]byte) (int, error)) Notifier + type NotifyHandler interface + ServeNotify func(req Request, n Notifier) + type NotifyHandlerFunc func(req Request, n Notifier) + func (f NotifyHandlerFunc) ServeNotify(req Request, n Notifier) + type Option func(DeviceOption) error + func OptAdvParams(param cmd.LESetAdvertisingParameters) Option + func OptCentralRole() Option + func OptConnParams(param cmd.LECreateConnection) Option + func OptDeviceID(id int) Option + func OptDialerTimeout(d time.Duration) Option + func OptListenerTimeout(d time.Duration) Option + func OptPeripheralRole() Option + func OptScanParams(param cmd.LESetScanParameters) Option + type Profile struct + Services []*Service + func (p *Profile) Find(target interface{}) interface{} + func (p *Profile) FindCharacteristic(char *Characteristic) *Characteristic + func (p *Profile) FindDescriptor(desc *Descriptor) *Descriptor + func (p *Profile) FindService(service *Service) *Service + type Property int + const CharBroadcast + const CharExtended + const CharIndicate + const CharNotify + const CharRead + const CharSignedWrite + const CharWrite + const CharWriteNR + type ReadHandler interface + ServeRead func(req Request, rsp ResponseWriter) + type ReadHandlerFunc func(req Request, rsp ResponseWriter) + func (f ReadHandlerFunc) ServeRead(req Request, rsp ResponseWriter) + type Request interface + Conn func() Conn + Data func() []byte + Offset func() int + func NewRequest(conn Conn, data []byte, offset int) Request + type ResponseWriter interface + Cap func() int + Len func() int + SetStatus func(status ATTError) + Status func() ATTError + Write func(b []byte) (int, error) + func NewResponseWriter(buf *bytes.Buffer) ResponseWriter + type Service struct + Characteristics []*Characteristic + EndHandle uint16 + Handle uint16 + UUID UUID + func NewService(u UUID) *Service + func (s *Service) AddCharacteristic(c *Characteristic) *Characteristic + func (s *Service) NewCharacteristic(u UUID) *Characteristic + type ServiceData struct + Data []byte + UUID UUID + type UUID []byte + func MustParse(s string) UUID + func Parse(s string) (UUID, error) + func UUID16(i uint16) UUID + func (u UUID) Equal(v UUID) bool + func (u UUID) Len() int + func (u UUID) String() string + type WriteHandler interface + ServeWrite func(req Request, rsp ResponseWriter) + type WriteHandlerFunc func(req Request, rsp ResponseWriter) + func (f WriteHandlerFunc) ServeWrite(req Request, rsp ResponseWriter)