Documentation
¶
Index ¶
- Constants
- type AdStructure
- type AdType
- type AdvAddressType
- type AdvChannelMap
- type AdvFilterPolicy
- type AdvType
- type AdvertisingParameters
- type AdvertisingReport
- type BtAddress
- func (ba BtAddress) HasPrefix(buf []byte) bool
- func (ba BtAddress) IsNonResolvable() bool
- func (ba BtAddress) IsResolvable() bool
- func (ba BtAddress) IsStatic() bool
- func (ba BtAddress) MarshalJSON() ([]byte, error)
- func (ba BtAddress) Put(buf []byte)
- func (ba BtAddress) Resolve(irk []byte) bool
- func (ba BtAddress) String() string
- func (ba *BtAddress) UnmarshalJSON(b []byte) error
- type BtAddressType
- type CommandCompleteEvent
- func (cc *CommandCompleteEvent) GetCommandOpcode() CommandOpCode
- func (cc *CommandCompleteEvent) GetNumHciCommandPackets() byte
- func (cc *CommandCompleteEvent) GetReturnParameters() []byte
- func (cc *CommandCompleteEvent) GetStatusParameter() ErrorCode
- func (cc *CommandCompleteEvent) HasReturnParameters() bool
- type CommandOpCode
- type CommandPacket
- type ErrReadAgain
- type ErrorCode
- type Event
- type EventCode
- type LeMetaEvent
- type SubeventCode
- type Transport
Constants ¶
const ( // LE Limited Discoverable Mode AdFlagLimitedDisc = 0x01 // LE General Discoverable Mode AdFlagGeneralDisc = (0x01 << 1) // BR/EDR Not Supported. AdFlagNoBrEdr = (0x01 << 2) // Simultaneous LE and BR/EDR to Same Device Capable (Controller) AdFlagLeBrEdrController = (0x01 << 3) // Simultaneous LE and BR/EDR to Same Device Capable (Host) AdFlagLeBrEdrHost = (0x01 << 4) )
AD Flags bitmap values. Specified in Supplement to the Bluetooth Core Specification (CSS version 7), Part A, ch 1.3.1
const ( //IrkLength defines the required length for IRK IrkLength int = 16 //PrandLength defines the required length for PRAND PrandLength int = 3 )
const ( // HciEventPacket indicates that data from transport contains HCI Event HciEventPacket byte = 0x04 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdStructure ¶
AdStructure defines advertising data See Bluetooth 5.0, vol 3, part C, ch 11
func (*AdStructure) EncodeTo ¶
func (ad *AdStructure) EncodeTo(buf []byte) (int, error)
EncodeTo encodes AdStructure into given byte buffer. The buffer should be big enough to hold the data or error is returned. On success, returns the number of bytes written. See Bluetooth v5.0 vol 3, part C, ch 11
func (*AdStructure) String ¶
func (ad *AdStructure) String() string
type AdType ¶
type AdType byte
AdType is the type for advertising data See Bluetooth 5.0, vol 3, part C, ch 11
const ( AdFlags AdType = 0x01 AdMore16BitService AdType = 0x02 AdComplete16BitService AdType = 0x03 AdMore32BitService AdType = 0x04 AdComplete32BitService AdType = 0x05 AdMore128BitService AdType = 0x06 AdComplete128BitService AdType = 0x07 AdShortenedLocalName AdType = 0x08 AdCompleteLocalName AdType = 0x09 AdTxPower AdType = 0x0a AdClassOfdevice AdType = 0x0d AdPairingHash AdType = 0x0e AdPairingRandomizer AdType = 0x0f AdSmTk AdType = 0x10 AdSmOobFlags AdType = 0x11 AdSlaveConnInterval AdType = 0x12 Ad16bitServiceSol AdType = 0x14 Ad128bitServiceSol AdType = 0x15 AdServiceData AdType = 0x16 AdPublicTargetAddr AdType = 0x17 AdRandomTargetAddr AdType = 0x18 AdAppearance AdType = 0x19 AdAdvInterval AdType = 0x1a AdDeviceAddress AdType = 0x1b AdLeRole AdType = 0x1c AdPairingHash256 AdType = 0x1d AdPairingRandomizer256 AdType = 0x1e Ad32BitServiceSol AdType = 0x1f AdServiceData32 AdType = 0x20 AdServiceData128 AdType = 0x21 AdSecureConnConfirm AdType = 0x22 AdSecureConnRandom AdType = 0x23 AdURI AdType = 0x24 AdIndoorPosit AdType = 0x25 AdTransportDiscoveryData AdType = 0x26 AdLeSupportedFeatures AdType = 0x27 AdChannelMapUpdate AdType = 0x28 AdMeshPbAdv AdType = 0x29 AdMeshMessage AdType = 0x2a AdMeshBeacon AdType = 0x2b Ad3dData AdType = 0x3d AdManufacturerSpecific AdType = 0xff )
AD type values See https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile
type AdvAddressType ¶
type AdvAddressType byte
AdvAddressType defines values for 'Own Address Type' advertising parameter. See Bluetooth 5.0, vol 2, part E, ch 7.8.5
const ( AdvAddressPublic AdvAddressType = 0x00 AdvAddressRandom AdvAddressType = 0x01 AdvAddressGenerateOrPublic AdvAddressType = 0x02 AdvAddressGenerateOrRandom AdvAddressType = 0x03 )
Allowed values for AdvAddressType
type AdvChannelMap ¶
type AdvChannelMap int
AdvChannelMap defines the advertising channel(s) to use See Bluetooth 5.0, vol 2, parth E, ch 7.8.5
const ( AdvChannel37 AdvChannelMap = 0x01 AdvChannel38 AdvChannelMap = 0x01 << 1 AdvChannel39 AdvChannelMap = 0x01 << 2 AdvChannelAll AdvChannelMap = (AdvChannel37 | AdvChannel38 | AdvChannel39) )
Values for AdvChannelMap
type AdvFilterPolicy ¶
type AdvFilterPolicy byte
AdvFilterPolicy defines what scan and connection requests are accepted
const ( //Scan and connection requests from all ScanConnAll AdvFilterPolicy = 0x00 //Scan requests from all connection requests from white list ScanAllConnWhite AdvFilterPolicy = 0x01 //Scan requests from white list and connect requests from all ScanWhiteConnAll AdvFilterPolicy = 0x02 // Scan and connection requests from white list ScanConnWhite = 0x03 )
Values for AdvFilterPolicy
type AdvType ¶
type AdvType byte
AdvType defines the Advertising Event Type See Bluetooth 5.0, vol 2, part E, ch 7.7.65.2
const ( AdvInd AdvType = 0x00 AdvDirectInd AdvType = 0x01 AdvScanInd AdvType = 0x02 AdvNonconnInd AdvType = 0x03 ScanRsp AdvType = 0x04 AdvDirectIndLow AdvType = 0x04 // DIRECT_IND, low duty cycle, when advertising )
Advertising type values
func (AdvType) MarshalJSON ¶
MarshalJSON marshals AdvType into JSON
func (*AdvType) UnmarshalJSON ¶
UnmarshalJSON decodes the JSON encoded AdvertisingType
type AdvertisingParameters ¶
type AdvertisingParameters struct {
IntervalMin uint16
IntervalMax uint16
Type AdvType
OwnAddrType AdvAddressType
PeerAddress BtAddress
ChannelMap AdvChannelMap
FilterPolicy AdvFilterPolicy
}
AdvertisingParameters can be used to set advertising parameters for controller See Bluetooth 5.0 vol 2, part E, ch 7.8.5
func DefaultAdvParameters ¶
func DefaultAdvParameters() AdvertisingParameters
DefaultAdvParameters returns AdvertisingParameters struct with all values set to defaults.
type AdvertisingReport ¶
type AdvertisingReport struct {
EventType AdvType
Address BtAddress
Data []*AdStructure
Rssi int8
}
AdvertisingReport represents data parsed from LE Advertising Report Event received from controller See Bluetooth 5.0, vol 2, part E, ch 7.7.65.2
func DecodeAdvertisingReport ¶
func DecodeAdvertisingReport(buf []byte) ([]*AdvertisingReport, error)
DecodeAdvertisingReport can be used to decode data received in Advertising Report Event. Returns all reports contained in event.
func (*AdvertisingReport) String ¶
func (r *AdvertisingReport) String() string
type BtAddress ¶
type BtAddress struct {
Atype BtAddressType
// contains filtered or unexported fields
}
BtAddress defines the Bluetooth address
func BtAddressFromString ¶
BtAddressFromString creates BtAddress struct from given string the string should contain Bluetooth address in canonical form the returned address has address type set to default (LE Public)
func ToBtAddress ¶
ToBtAddress returns BtAddress with data from given slice the bytes are copied from the slice
func (BtAddress) IsNonResolvable ¶
IsNonResolvable returns true if address is non-resolvable private random address See Bluetooth 5.0, vol6, part B, ch 1.3.2.2
func (BtAddress) IsResolvable ¶
IsResolvable returns true if address is resolvable private random address See Bluetooth 5.0, vol6, part B, ch 1.3.2.2
func (BtAddress) IsStatic ¶
IsStatic returns true if address is static random address See Bluetooth 5.0, vol6, part B, ch 1.3.2.1
func (BtAddress) MarshalJSON ¶
MarshalJSON marshals BtAddress into JSON
func (BtAddress) Resolve ¶
Resolve tries to resolve the address with given Identity Resolving Key. Returns true if identity is resolved. NOTE: The IRK here is treated as opaque value, the positon 0 should contain the most significant byte. The address needs to be resolvable private address. See Bluetooth 5.0, vol 6, part B, ch 1.3.2.3
func (*BtAddress) UnmarshalJSON ¶
UnmarshalJSON parses the JSON encoded Bluetooth Address (as returned by ba.MarshalJSON()) and sets values of this address as those parsed
type BtAddressType ¶
type BtAddressType byte
BtAddressType defines address type for bluetooth address
const ( LePublicAddress BtAddressType = 0x00 LeRandomAddress BtAddressType = 0x01 BrEdrAddress BtAddressType = 0x02 )
Contstants for Bluetooth address type
func (BtAddressType) String ¶
func (t BtAddressType) String() string
type CommandCompleteEvent ¶
type CommandCompleteEvent struct {
Event
}
CommandCompleteEvent represents Command Complete HCI Event see Bluetooth v5.0, vol2, part E, ch 7.7.14
func DecodeCommandComplete ¶
func DecodeCommandComplete(evt *Event) (*CommandCompleteEvent, error)
DecodeCommandComplete returns given event as CommandCompleteEvent caller should check that the event is CommandCompleteEvent
func (*CommandCompleteEvent) GetCommandOpcode ¶
func (cc *CommandCompleteEvent) GetCommandOpcode() CommandOpCode
GetCommandOpcode returns the opcode this command complete event was for
func (*CommandCompleteEvent) GetNumHciCommandPackets ¶
func (cc *CommandCompleteEvent) GetNumHciCommandPackets() byte
GetNumHciCommandPackets returns the number of Hci commands parameter value
func (*CommandCompleteEvent) GetReturnParameters ¶
func (cc *CommandCompleteEvent) GetReturnParameters() []byte
GetReturnParameters returns the return parameters for this event
func (*CommandCompleteEvent) GetStatusParameter ¶
func (cc *CommandCompleteEvent) GetStatusParameter() ErrorCode
GetStatusParameter returns the first parameter as status code. XXX bounds check
func (*CommandCompleteEvent) HasReturnParameters ¶
func (cc *CommandCompleteEvent) HasReturnParameters() bool
HasReturnParameters returns true if this command complete event contains return parameters
type CommandOpCode ¶
type CommandOpCode uint16
CommandOpCode represents the Operation code for HCI command See Bluetooth 5.0 vol 2, part E, ch 5.4.1
const ( CommandReset CommandOpCode = 0x0c03 CommandSetEventMask CommandOpCode = 0x0c01 CommandWriteLeHostSupported CommandOpCode = 0x0c6d CommandLeSetEventMask CommandOpCode = 0x2001 CommandLeSetRandomAddress CommandOpCode = 0x2005 CommandLeSetAdvParameters CommandOpCode = 0x2006 CommandLeSetAdvData CommandOpCode = 0x2008 CommandLeSetScanResponse CommandOpCode = 0x2009 CommandLeSetAdvEnable CommandOpCode = 0x200a CommandLeSetScanParameters CommandOpCode = 0x200b CommandLeSetScanEnable CommandOpCode = 0x200c )
Opcodes for HCI Commands
func (CommandOpCode) String ¶
func (op CommandOpCode) String() string
type CommandPacket ¶
type CommandPacket struct {
// OpCode for this command
OpCode CommandOpCode
// contains filtered or unexported fields
}
CommandPacket defines HCI Command packet
func (*CommandPacket) Encode ¶
func (pkt *CommandPacket) Encode() []byte
Encode encodes the command into properly formed byte array See Bluetooth 5.0 vol 2, part E, ch 5.4.1
func (*CommandPacket) Parameters ¶
func (pkt *CommandPacket) Parameters(params []byte)
Parameters add parameters for command packets the given byte slice is not copied, do not modify it
type ErrReadAgain ¶
type ErrReadAgain struct {
// contains filtered or unexported fields
}
ErrReadAgain is returned by Transport.Read() if the read was interrupted (by EINTR or by timeout) and should be tried again. ErrReadAgain wraps the original error.
func (ErrReadAgain) Error ¶
func (err ErrReadAgain) Error() string
func (ErrReadAgain) Unwrap ¶
func (err ErrReadAgain) Unwrap() error
type ErrorCode ¶
type ErrorCode byte
ErrorCode defines the error codes returned by controller See Bluetooth 5.0, vol 2, part D
type Event ¶
type Event struct {
Code EventCode
// contains filtered or unexported fields
}
Event structure represents received HCI Event See Bluetooth 5.0, vol 2, Part E, ch 5.4.4
func DecodeEvent ¶
DecodeEvent decodes HCI Event from given buffer, error is received if event can not be decoded
type EventCode ¶
type EventCode byte
EventCode identifies the HCI Event received
type LeMetaEvent ¶
type LeMetaEvent struct {
Event
}
LeMetaEvent represents LE Meta Event HCI Event See Bluetooth 5.0, vol 2, part E, ch 7.7.65
func DecodeLeMeta ¶
func DecodeLeMeta(evt *Event) (*LeMetaEvent, error)
DecodeLeMeta returns given event as Le Meta Event
func (*LeMetaEvent) GetParameters ¶
func (le *LeMetaEvent) GetParameters() []byte
GetParameters returns parameters in this event, subevent code is not included
func (*LeMetaEvent) GetSubeventCode ¶
func (le *LeMetaEvent) GetSubeventCode() SubeventCode
GetSubeventCode return subevent code parameter value
type SubeventCode ¶
type SubeventCode byte
SubeventCode for LE Meta Events
const (
SubeventAdvertisingReport SubeventCode = 0x02
)
Subevent types for LE Meta Event