adv

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2020 License: Apache-2.0, BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagLimitedDiscoverable = 0x01 // LE Limited Discoverable Mode
	FlagGeneralDiscoverable = 0x02 // LE General Discoverable Mode
	FlagLEOnly              = 0x04 // BR/EDR Not Supported. Bit 37 of LMP Feature Mask Definitions (Page 0)
	FlagBothController      = 0x08 // Simultaneous LE and BR/EDR to Same Device Capable (Controller).
	FlagBothHost            = 0x10 // Simultaneous LE and BR/EDR to Same Device Capable (Host).
)

Advertising flags

View Source
const MaxEIRPacketLength = 31

MaxEIRPacketLength is the maximum allowed AdvertisingPacket and ScanResponsePacket length.

Variables

View Source
var (
	ErrInvalid = errors.New("invalid argument")
	ErrNotFit  = errors.New("data not fit")
)

ErrNotFit ...

Functions

This section is empty.

Types

type Field

type Field func(p *Packet) error

Field is an advertising field which can be appended to a packet.

func AllUUID

func AllUUID(u ble.UUID) Field

AllUUID is one of the complete service UUID list.

func CompleteName

func CompleteName(n string) Field

CompleteName is a compelete local name.

func Flags

func Flags(f byte) Field

Flags is a flags.

func IBeacon

func IBeacon(u ble.UUID, major, minor uint16, pwr int8) Field

IBeacon returns an iBeacon advertising packet with specified parameters.

func IBeaconData

func IBeaconData(md []byte) Field

IBeaconData returns an iBeacon advertising packet with specified parameters.

func ManufacturerData

func ManufacturerData(id uint16, b []byte) Field

ManufacturerData is manufacturer specific data.

func Raw

func Raw(b []byte) Field

Raw appends the bytes to the current packet. This is helpful for creating new packet from existing packets.

func ServiceData16

func ServiceData16(id uint16, b []byte) Field

ServiceData16 is service data for a 16bit service uuid

func ShortName

func ShortName(n string) Field

ShortName is a short local name.

func SomeUUID

func SomeUUID(u ble.UUID) Field

SomeUUID is one of the incomplete service UUID list.

type Packet

type Packet struct {
	// contains filtered or unexported fields
}

Packet is an implemntation of ble.AdvPacket for crafting or parsing an advertising packet or scan response. Refer to Supplement to Bluetooth Core Specification | CSSv6, Part A.

func NewPacket

func NewPacket(fields ...Field) (*Packet, error)

NewPacket returns a new advertising Packet.

func NewRawPacket

func NewRawPacket(bytes ...[]byte) *Packet

NewRawPacket returns a new advertising Packet.

func (*Packet) Append

func (p *Packet) Append(f Field) error

Append appends a field to the packet. It returns ErrNotFit if the field doesn't fit into the packet, and leaves the packet intact.

func (*Packet) Bytes

func (p *Packet) Bytes() []byte

Bytes returns the bytes of the packet.

func (*Packet) Field

func (p *Packet) Field(typ byte) []byte

Field returns the field data (excluding the initial length and typ byte). It returns nil, if the specified field is not found.

func (*Packet) Flags

func (p *Packet) Flags() (flags byte, present bool)

Flags returns the flags of the packet.

func (*Packet) Len

func (p *Packet) Len() int

Len returns the length of the packet.

func (*Packet) LocalName

func (p *Packet) LocalName() string

LocalName returns the ShortName or CompleteName if it presents.

func (*Packet) ManufacturerData

func (p *Packet) ManufacturerData() []byte

ManufacturerData returns the ManufacturerData field if it presents.

func (*Packet) ServiceData

func (p *Packet) ServiceData() []ble.ServiceData

ServiceData ...

func (*Packet) ServiceSol

func (p *Packet) ServiceSol() []ble.UUID

ServiceSol ...

func (*Packet) TxPower

func (p *Packet) TxPower() (power int, present bool)

TxPower returns the TxPower, if it presents.

func (*Packet) UUIDs

func (p *Packet) UUIDs() []ble.UUID

UUIDs returns a list of service UUIDs.

Jump to

Keyboard shortcuts

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