Versions in this module Expand all Collapse all v1 v1.0.1 Apr 13, 2020 v1.0.0 Apr 13, 2020 Changes in this version + const CentralManager — darwin/amd64 + const MaxEIRPacketLength + const PeripheralManager — darwin/amd64 + const StatusInvalidOffset + const StatusSuccess + const StatusUnexpectedError + var ErrEIRPacketTooLong = errors.New("max packet length is 31") + var ErrInvalidLength = errors.New("invalid length") + type AdvPacket struct + func (a *AdvPacket) AppendField(typ byte, b []byte) *AdvPacket + func (a *AdvPacket) AppendFlags(f byte) *AdvPacket + func (a *AdvPacket) AppendManufacturerData(id uint16, b []byte) *AdvPacket + func (a *AdvPacket) AppendName(n string) *AdvPacket + func (a *AdvPacket) AppendUUIDFit(uu []UUID) bool + func (a *AdvPacket) Bytes() [31]byte + func (a *AdvPacket) Len() int + type Advertisement struct + Connectable bool + LocalName string + ManufacturerData []byte + OverflowService []UUID + ServiceData []ServiceData + Services []UUID + SolicitedService []UUID + TxPowerLevel int + type Central interface + Close func() error + ID func() string + MTU func() int + type Characteristic struct + func NewCharacteristic(u UUID, s *Service, props Property, h uint16, vh uint16) *Characteristic + func (c *Characteristic) AddDescriptor(u UUID) *Descriptor + func (c *Characteristic) Descriptor() *Descriptor + func (c *Characteristic) Descriptors() []*Descriptor + func (c *Characteristic) EndHandle() uint16 + func (c *Characteristic) Handle() uint16 + func (c *Characteristic) HandleNotify(h NotifyHandler) + func (c *Characteristic) HandleNotifyFunc(f func(r Request, n Notifier)) + func (c *Characteristic) HandleRead(h ReadHandler) + func (c *Characteristic) HandleReadFunc(f func(rsp ResponseWriter, req *ReadRequest)) + func (c *Characteristic) HandleWrite(h WriteHandler) + func (c *Characteristic) HandleWriteFunc(f func(r Request, data []byte) (status byte)) + func (c *Characteristic) Name() string + func (c *Characteristic) Properties() Property + func (c *Characteristic) Service() *Service + func (c *Characteristic) SetDescriptor(cccd *Descriptor) + func (c *Characteristic) SetDescriptors(descs []*Descriptor) + func (c *Characteristic) SetEndHandle(endh uint16) + func (c *Characteristic) SetHandle(h uint16) + func (c *Characteristic) SetVHandle(vh uint16) + func (c *Characteristic) SetValue(b []byte) + func (c *Characteristic) UUID() UUID + func (c *Characteristic) VHandle() uint16 + type Descriptor struct + func NewDescriptor(u UUID, h uint16, char *Characteristic) *Descriptor + func (d *Descriptor) Characteristic() *Characteristic + func (d *Descriptor) Handle() uint16 + func (d *Descriptor) HandleRead(h ReadHandler) + func (d *Descriptor) HandleReadFunc(f func(rsp ResponseWriter, req *ReadRequest)) + func (d *Descriptor) HandleWrite(h WriteHandler) + func (d *Descriptor) HandleWriteFunc(f func(r Request, data []byte) (status byte)) + func (d *Descriptor) Name() string + func (d *Descriptor) SetHandle(h uint16) + func (d *Descriptor) SetValue(b []byte) + func (d *Descriptor) UUID() UUID + type Device interface + AddService func(s *Service) error + Advertise func(a *AdvPacket) error + AdvertiseIBeacon func(u UUID, major, minor uint16, pwr int8) error + AdvertiseIBeaconData func(b []byte) error + AdvertiseNameAndServices func(name string, ss []UUID) error + CancelConnection func(p Peripheral) + Connect func(p Peripheral) + Handle func(h ...Handler) + Init func(stateChanged func(Device, State)) error + Option func(o ...Option) error + RemoveAllServices func() error + Scan func(ss []UUID, dup bool) + SetServices func(ss []*Service) error + StopAdvertising func() error + StopScanning func() + func NewDevice(opts ...Option) (Device, error) + type Handler func(Device) + func CentralConnected(f func(Central)) Handler + func CentralDisconnected(f func(Central)) Handler + func PeripheralConnected(f func(Peripheral, error)) Handler + func PeripheralDisconnected(f func(Peripheral, error)) Handler + func PeripheralDiscovered(f func(Peripheral, *Advertisement, int)) Handler + type Notifier interface + Cap func() int + Done func() bool + Write func(data []byte) (int, error) + type NotifyHandler interface + ServeNotify func(r Request, n Notifier) + type NotifyHandlerFunc func(r Request, n Notifier) + func (f NotifyHandlerFunc) ServeNotify(r Request, n Notifier) + type Option func(Device) error + func LnxDeviceID(n int, chk bool) Option + func LnxMaxConnections(n int) Option + func LnxSendHCIRawCommand(c cmd.CmdParam, rsp io.Writer) Option + func LnxSetAdvertisingData(c *cmd.LESetAdvertisingData) Option + func LnxSetAdvertisingEnable(en bool) Option + func LnxSetAdvertisingParameters(c *cmd.LESetAdvertisingParameters) Option + func LnxSetScanResponseData(c *cmd.LESetScanResponseData) Option + func MacDeviceRole(r int) Option + type Peripheral interface + Device func() Device + DiscoverCharacteristics func(c []UUID, s *Service) ([]*Characteristic, error) + DiscoverDescriptors func(d []UUID, c *Characteristic) ([]*Descriptor, error) + DiscoverIncludedServices func(ss []UUID, s *Service) ([]*Service, error) + DiscoverServices func(s []UUID) ([]*Service, error) + ID func() string + Name func() string + ReadCharacteristic func(c *Characteristic) ([]byte, error) + ReadDescriptor func(d *Descriptor) ([]byte, error) + ReadLongCharacteristic func(c *Characteristic) ([]byte, error) + ReadRSSI func() int + Services func() []*Service + SetIndicateValue func(c *Characteristic, f func(*Characteristic, []byte, error)) error + SetMTU func(mtu uint16) error + SetNotifyValue func(c *Characteristic, f func(*Characteristic, []byte, error)) error + WriteCharacteristic func(c *Characteristic, b []byte, noRsp bool) error + WriteDescriptor func(d *Descriptor, b []byte) error + func NewPeripheral(u UUID) Peripheral + type Property int + const CharBroadcast + const CharExtended + const CharIndicate + const CharNotify + const CharRead + const CharSignedWrite + const CharWrite + const CharWriteNR + func (p Property) String() (result string) + type ReadHandler interface + ServeRead func(resp ResponseWriter, req *ReadRequest) + type ReadHandlerFunc func(resp ResponseWriter, req *ReadRequest) + func (f ReadHandlerFunc) ServeRead(resp ResponseWriter, req *ReadRequest) + type ReadRequest struct + Cap int + Offset int + type Request struct + Central Central + type ResponseWriter interface + SetStatus func(byte) + Write func([]byte) (int, error) + type Service struct + func NewService(u UUID) *Service + func (s *Service) AddCharacteristic(u UUID) *Characteristic + func (s *Service) Characteristics() []*Characteristic + func (s *Service) EndHandle() uint16 + func (s *Service) Handle() uint16 + func (s *Service) Name() string + func (s *Service) SetCharacteristics(chars []*Characteristic) + func (s *Service) SetEndHandle(endh uint16) + func (s *Service) SetHandle(h uint16) + func (s *Service) UUID() UUID + type ServiceData struct + Data []byte + UUID UUID + type State int + const StatePoweredOff + const StatePoweredOn + const StateResetting + const StateUnauthorized + const StateUnknown + const StateUnsupported + func (s State) String() string + type UUID struct + func MustParseUUID(s string) UUID + func ParseUUID(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(r Request, data []byte) (status byte) + type WriteHandlerFunc func(r Request, data []byte) byte + func (f WriteHandlerFunc) ServeWrite(r Request, data []byte) byte