Versions in this module Expand all Collapse all v0 v0.6.17 Aug 17, 2024 Changes in this version + const DefaultMTU + const MaxMTU + var AdvertisementMapKeys = struct{ ... } + var AppearanceUUID = UUID16(0x2A01) + var BatteryUUID = UUID16(0x180F) + var CentralAddressResolutionUUID = UUID16(0x2AA6) + 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 ErrEncryptionAlreadyEnabled = errors.New("encryption already enabled") + var ErrNotImplemented = errors.New("not implemented") + var FirmwareRevisionStringUUID = UUID16(0x2A26) + var GAPUUID = UUID16(0x1800) + var GATTUUID = UUID16(0x1801) + var HIDUUID = UUID16(0x1812) + var HardwareRevisionUUID = UUID16(0x2A27) + var IEEE1107320601RegulatoryCertificationDataListUUID = UUID16(0x2A2A) + var IncludeUUID = UUID16(0x2802) + var ManufacturerNameUUID = UUID16(0x2A29) + var ModelNumberUUID = UUID16(0x2A24) + var PeferredParamsUUID = UUID16(0x2A04) + var PeripheralPrivacyUUID = UUID16(0x2A02) + var PnPIDUUID = UUID16(0x2A50) + var PrimaryServiceUUID = UUID16(0x2800) + var ReconnectionAddrUUID = UUID16(0x2A03) + var SecondaryServiceUUID = UUID16(0x2801) + var SerialNumberUUID = UUID16(0x2A25) + var ServerCharacteristicConfigUUID = UUID16(0x2903) + var ServiceChangedUUID = UUID16(0x2A05) + var SoftwareRevisionStringUUID = UUID16(0x2A28) + var SystemIDUUID = UUID16(0x2A23) + 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 SetLogLevelMax() + func SetLogger(l Logger) + 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 + Bytes func() []byte + 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 + AddrType func() uint8 + Connectable func() bool + Data func() []byte + LocalName func() string + ManufacturerData func() []byte + OverflowService func() []UUID + RSSI func() int + ServiceData func() []ServiceData + Services func() []UUID + SolicitedService func() []UUID + SrData func() []byte + Timestamp func() int64 + ToMap func() (map[string]interface{}, error) + TxPowerLevel func() int + func Find(ctx context.Context, allowDup bool, f AdvFilter) ([]Advertisement, error) + type AdvertisingParameters struct + AdvertisingChannelMap uint8 + AdvertisingFilterPolicy uint8 + AdvertisingIntervalMax uint16 + AdvertisingIntervalMin uint16 + AdvertisingType uint8 + DirectAddress [6]byte + DirectAddressType uint8 + OwnAddressType uint8 + type AuthData struct + OOBData []byte + Passkey int + 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 + ConnectionHandle func() uint8 + Disconnected func() <-chan struct{} + DiscoverAndCacheProfile func(force bool) (*Profile, error) + 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 + OpenLECreditBasedConnection func(psm uint16) (LECreditBasedConnection, error) + Pair func(AuthData, time.Duration) error + Profile func() *Profile + ReadCharacteristic func(c *Characteristic) ([]byte, error) + ReadDescriptor func(d *Descriptor) ([]byte, error) + ReadLongCharacteristic func(c *Characteristic) ([]byte, error) + ReadRSSI func() (int8, error) + SetConnectionParameters func(minInterval, maxInterval, latency, timeout, minCeLength, maxCeLength uint16) error + StartEncryption func(c chan EncryptionChangedInfo) error + 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 + ConnectionHandle func() uint8 + Context func() context.Context + Disconnected func() <-chan struct{} + LocalAddr func() Addr + OpenLECreditBasedConnection func(psm uint16) (LECreditBasedConnection, error) + Pair func(AuthData, time.Duration) error + ReadRSSI func() (int8, error) + RemoteAddr func() Addr + RxMTU func() int + SetContext func(ctx context.Context) + SetRxMTU func(mtu int) + SetTxMTU func(mtu int) + StartEncryption func(change chan EncryptionChangedInfo) error + 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 + Address func() Addr + 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 + AdvertiseRaw func(ad, sr []byte, params AdvertisingParameters) error + AdvertiseServiceData16 func(ctx context.Context, id uint16, b []byte) error + Dial func(ctx context.Context, a Addr) (Client, error) + NonblockingScan func(allowDup bool, h AdvHandler) error + RemoveAllServices func() error + Scan func(ctx context.Context, allowDup bool, h AdvHandler) error + SendVendorSpecificCommand func(opcode uint16, length uint8, v interface{}) error + SetServices func(svcs []*Service) error + Stop func() error + StopAdvertising func() error + StopScan func() error + type DeviceOption interface + EnableSecurity func(interface{}) error + SetAdvHandlerSync func(bool) error + SetAdvParams func(cmd.LESetAdvertisingParameters) error + SetCentralRole func() error + SetConnParams func(cmd.LECreateConnection) error + SetDialerTimeout func(time.Duration) error + SetErrorHandler func(handler func(error)) error + SetGattCacheFile func(filename string) + SetListenerTimeout func(time.Duration) error + SetPeripheralRole func() error + SetScanParams func(cmd.LESetScanParameters) error + SetTransportH4Socket func(addr string, timeout time.Duration) error + SetTransportH4Uart func(path string, baud int) error + SetTransportHCISocket func(id int) error + type EncryptionChangedInfo struct + Enabled bool + Err error + Status int + type GattCache interface + Clear func() error + Load func(Addr) (Profile, error) + Store func(Addr, Profile, bool) error + type LECreditBasedConnection interface + Close func() error + Info func() LECreditBasedConnectionInfo + Send func(bb []byte) error + Subscribe func() (<-chan []byte, error) + Unsubscribe func() error + type LECreditBasedConnectionInfo struct + LocalCID uint16 + MPS uint16 + MTU uint16 + RemoteCID uint16 + type Logger interface + ChildLogger func(tags map[string]interface{}) Logger + Debug func(...interface{}) + Debugf func(string, ...interface{}) + Error func(...interface{}) + Errorf func(string, ...interface{}) + Info func(...interface{}) + Infof func(string, ...interface{}) + Warn func(...interface{}) + Warnf func(string, ...interface{}) + func GetLogger() Logger + type NotificationHandler func(id uint, bb []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 OptAdvHandlerSync(sync bool) Option + 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 OptEnableSecurity(bondManager interface{}) Option + func OptErrorHandler(handler func(error)) Option + func OptGattCacheFile(filename string) Option + func OptListenerTimeout(d time.Duration) Option + func OptPeripheralRole() Option + func OptScanParams(param cmd.LESetScanParameters) Option + func OptTransportH4Socket(addr string, timeout time.Duration) Option + func OptTransportH4Uart(path string, baud int) Option + func OptTransportHCISocket(id int) 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)