hci

package
v0.6.17 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: BSD-3-Clause Imports: 21 Imported by: 3

README

LE Command Requirements

List of the commands and events that a Controller supporting LE shall implement. [Vol 2 Part A.3.19]

  • Mandatory

    • Vol 2, Part E, 7.7.14 - Command Complete Event (0x0E)
    • Vol 2, Part E, 7.7.15 - Command Status Event (0x0F)
    • Vol 2, Part E, 7.8.16 - LE Add Device To White List Command (0x08|0x0011)
    • Vol 2, Part E, 7.8.15 - LE Clear White List Command (0x08|0x0010)
    • Vol 2, Part E, 7.8.2 - LE Read Buffer Size Command (0x08|0x0002)
    • Vol 2, Part E, 7.4.3 - Read Local Supported Features Command (0x04|0x0003)
    • Vol 2, Part E, 7.8.27 - LE Read Supported States Command (0x08|0x001C)
    • Vol 2, Part E, 7.8.14 - LE Read White List Size Command (0x08|0x000F)
    • Vol 2, Part E, 7.8.17 - LE Remove Device From White List Command (0x08|0x0012)
    • Vol 2, Part E, 7.8.1 - LE Set Event Mask Command (0x08|0x0001)
    • Vol 2, Part E, 7.8.30 - LE Test End Command (0x08|0x001F)
    • Vol 2, Part E, 7.4.6 - Read BD_ADDR Command (0x04|0x0009)
    • Vol 2, Part E, 7.8.3 - LE Read Local Supported Features Command (0x08|0x0003)
    • Vol 2, Part E, 7.4.1 - Read Local Version Information Command (0x04|0x0001)
    • Vol 2, Part E, 7.3.2 - Reset Command (0x03|0x003)
    • Vol 2, Part E, 7.4.2 - Read Local Supported Commands Command (0x04|0x0002)
    • Vol 2, Part E, 7.3.1 - Set Event Mask Command (0x03|0x0001)
  • C1: Mandatory if Controller supports transmitting packets, otherwise optional.

    • Vol 2, Part E, 7.8.6 - LE Read Advertising Channel Tx Power Command (0x08|0x0007)
    • Vol 2, Part E, 7.8.29 - LE Transmitter Test Command (0x08|0x001E)
    • Vol 2, Part E, 7.8.9 - LE Set Advertise Enable Command (0x08|0x000A)
    • Vol 2, Part E, 7.8.7 - LE Set Advertising Data Command (0x08|0x0008)
    • Vol 2, Part E, 7.8.5 - LE Set Advertising Parameters Command (0x08|0x0006)
    • Vol 2, Part E, 7.8.4 - LE Set Random Address Command (0x08|0x0005)
  • C2: Mandatory if Controller supports receiving packets, otherwise optional.

    • Vol 2, Part E, 7.7.65.2 - LE Advertising Report Event (0x3E)
    • Vol 2, Part E, 7.8.28 - LE Receiver Test Command (0x08|0x001D)
    • Vol 2, Part E, 7.8.11 - LE Set Scan Enable Command (0x08|0x000C)
    • Vol 2, Part E, 7.8.10 - LE Set Scan Parameters Command (0x08|0x000B)
  • C3: Mandatory if Controller supports transmitting and receiving packets, otherwise optional.

    • Vol 2, Part E, 7.1.6 - Disconnect Command (0x01|0x0006)
    • Vol 2, Part E, 7.7.5 - Disconnection Complete Event (0x05)
    • Vol 2, Part E, 7.7.65.1 - LE Connection Complete Event (0x3E)
    • Vol 2, Part E, 7.8.18 - LE Connection Update Command (0x08|0x0013)
    • Vol 2, Part E, 7.7.65.3 - LE Connection Update Complete Event (0x0E)
    • Vol 2, Part E, 7.8.12 - LE Create Connection Command (0x08|0x000D)
    • Vol 2, Part E, 7.8.13 - LE Create Connection Cancel Command (0x08|0x000E)
    • Vol 2, Part E, 7.8.20 - LE Read Channel Map Command (0x08|0x0015)
    • Vol 2, Part E, 7.8.21 - LE Read Remote Used Features Command (0x08|0x0016)
    • Vol 2, Part E, 7.7.65.4 - LE Read Remote Used Features Complete Event (0x3E)
    • Vol 2, Part E, 7.8.19 - LE Set Host Channel Classification Command (0x08|0x0014)
    • Vol 2, Part E, 7.8.8 - LE Set Scan Response Data Command (0x08|0x0009)
    • Vol 2, Part E, 7.3.40 - Host Number Of Completed Packets Command (0x03|0x0035)
    • Vol 2, Part E, 7.3.35 - Read Transmit Power Level Command (0x03|0x002D)
    • Vol 2, Part E, 7.1.23 - Read Remote Version Information Command (0x01|0x001D)
    • Vol 2, Part E, 7.7.12 - Read Remote Version Information Complete Event (0x0C)
    • Vol 2, Part E, 7.5.4 - Read RSSI Command (0x05|0x0005)
  • C4: Mandatory if LE Feature (LL Encryption) is supported otherwise optional.

    • Vol 2, Part E, 7.7.8 - Encryption Change Event (0x08)
    • Vol 2, Part E, 7.7.39 - Encryption Key Refresh Complete Event (0x30)
    • Vol 2, Part E, 7.8.22 - LE Encrypt Command (0x08|0x0017)
    • Vol 2, Part E, 7.7.65.5 - LE Long Term Key Request Event (0x3E)
    • Vol 2, Part E, 7.8.25 - LE Long Term Key Request Reply Command (0x08|0x001A)
    • Vol 2, Part E, 7.8.26 - LE Long Term Key Request Negative Reply Command (0x08|0x001B)
    • Vol 2, Part E, 7.8.23 - LE Rand Command (0x08|0x0018)
    • Vol 2, Part E, 7.8.24 - LE Start Encryption Command (0x08|0x0019)
  • C5: Mandatory if BR/EDR is supported otherwise optional. [Won't supported]

    • Vol 2, Part E, 7.4.5 - Read Buffer Size Command
    • Vol 2, Part E, 7.3.78 - Read LE Host Support
    • Vol 2, Part E, 7.3.79 - Write LE Host Support Command (0x03|0x006D)
  • C6: Mandatory if LE Feature (Connection Parameters Request procedure) is supported, otherwise optional.

    • Vol 2, Part E, 7.8.31 - LE Remote Connection Parameter Request Reply Command (0x08|0x0020)
    • Vol 2, Part E, 7.8.32 - LE Remote Connection Parameter Request Negative Reply Command (0x08|0x0021)
    • Vol 2, Part E, 7.7.65.6 - LE Remote Connection Parameter Request Event (0x3E)
  • C7: Mandatory if LE Ping is supported otherwise excluded

    • Vol 2, Part E, 7.3.94 - Write Authenticated Payload Timeout Command (0x01|0x007C)
    • Vol 2, Part E, 7.3.93 - Read Authenticated Payload Timeout Command (0x03|0x007B)
    • Vol 2, Part E, 7.7.75 - Authenticated Payload Timeout Expired Event (0x57)
    • Vol 2, Part E, 7.3.69 - Set Event Mask Page 2 Command (0x03|0x0063)
  • Optional support

    • Vol 2, Part E, 7.7.26 - Data Buffer Overflow Event (0x1A)
    • Vol 2, Part E, 7.7.16 - Hardware Error Event (0x10)
    • Vol 2, Part E, 7.3.39 - Host Buffer Size Command (0x03|0x0033)
    • Vol 2, Part E, 7.7.19 - Number Of Completed Packets Event (0x13)
    • Vol 2, Part E, 7.3.38 - Set Controller To Host Flow Control Command

    Vol 3, Part A, 4 L2CAP Signaling mandatory for LE-U

    • Vol 3, Part A, 4.1 - Command Reject (0x01)
    • Vol 3, Part A, 4.6 - Disconnect Request (0x06)
    • Vol 3, Part A, 4.7 - Disconnect Response (0x07)
    • Vol 3, Part A, 4.20 - Connection Parameter Update Request (0x12)
    • Vol 3, Part A, 4.21 - Connection Parameter Update Response (0x13)
    • Vol 3, Part A, 4.22 - LE Credit Based Connection Request (0x14)
    • Vol 3, Part A, 4.23 - LE Credit Based Connection Response (0x15)
    • Vol 3, Part A, 4.24 - LE Flow Control Credit (0x16)

Documentation

Index

Constants

View Source
const (
	AddressTypePublic           = 0
	AddressTypeRandom           = 1
	FilterPolicyAcceptAll       = 0
	FilterPolicyAcceptWhitelist = 1
	LEScanTypePassive           = 0
	LEScanTypeActive            = 1

	LEScanIntervalMin = 0x0004
	LEScanIntervalMax = 0x4000
	LEScanWindowMin   = 0x0004
	LEScanWindowMax   = 0x4000

	ConnIntervalMin = 0x0006
	ConnIntervalMax = 0x0c80
	ConnLatencyMin  = 0x0000
	ConnLatencyMax  = 0x01f3

	SupervisionTimeoutMin = 0x000a
	SupervisionTimeoutMax = 0x0c80

	CELengthMin = 0x0000
	CELengthMax = 0xffff
)
View Source
const (
	IoCapsDisplayOnly     = 0x00
	IoCapsDisplayYesNo    = 0x01
	IoCapsKeyboardOnly    = 0x02
	IoCapsNone            = 0x03
	IoCapsKeyboardDisplay = 0x04
	IoCapsReservedStart   = 0x05
)
View Source
const (
	CidSMP uint16 = 0x06 // SecurityManager Protocol [Vol 3, Part H].
)

L2CAP Channel Identifier namespace for LE-U logical link [Vol 3, Part A, 2.1].

View Source
const SignalCommandReject = 0x01

SignalCommandReject is the code of Command Reject signaling packet.

View Source
const SignalConnectionParameterUpdateRequest = 0x12

SignalConnectionParameterUpdateRequest is the code of Connection Parameter Update Request signaling packet.

View Source
const SignalConnectionParameterUpdateResponse = 0x13

SignalConnectionParameterUpdateResponse is the code of Connection Parameter Update Response signaling packet.

View Source
const SignalDisconnectRequest = 0x06

SignalDisconnectRequest is the code of Disconnect Request signaling packet.

View Source
const SignalDisconnectResponse = 0x07

SignalDisconnectResponse is the code of Disconnect Response signaling packet.

View Source
const SignalL2CAPConnectionRequest = 0x02

SignalL2CAPConnectionRequest is the code of L2CAP Connection Request signaling packet.

View Source
const SignalL2CAPConnectionResponse = 0x03

SignalL2CAPConnectionResponse is the code of L2CAP Connection Response signaling packet.

View Source
const SignalL2CAPCreditBasedConnectionRequest = 0x17

SignalL2CAPCreditBasedConnectionRequest is the code of L2CAP Credit Based Connection Request signaling packet.

View Source
const SignalL2CAPCreditBasedConnectionResponse = 0x18

SignalL2CAPCreditBasedConnectionResponse is the code of L2CAP Credit Based Connection Response signaling packet.

View Source
const SignalLECreditBasedConnectionRequest = 0x14

SignalLECreditBasedConnectionRequest is the code of LE Credit Based Connection Request signaling packet.

View Source
const SignalLECreditBasedConnectionResponse = 0x15

SignalLECreditBasedConnectionResponse is the code of LE Credit Based Connection Response signaling packet.

View Source
const SignalLEFlowControlCredit = 0x16

SignalLEFlowControlCredit is the code of LE Flow Control Credit signaling packet.

Variables

View Source
var (
	ErrBusyScanning    = errors.New("busy scanning")
	ErrBusyAdvertising = errors.New("busy advertising")
	ErrBusyDialing     = errors.New("busy dialing")
	ErrBusyListening   = errors.New("busy listening")
	ErrInvalidAddr     = errors.New("invalid address")
)

errors

Functions

func NewCoc added in v0.6.17

func NewCoc(c *Conn, l ble.Logger) *coc

func ValidateConnParams added in v0.5.7

func ValidateConnParams(p cmd.LECreateConnection) error

func ValidateScanParams added in v0.5.7

func ValidateScanParams(p cmd.LESetScanParameters) error

Types

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

Advertisement implements ble.Advertisement and other functions that are only available on Linux.

func (*Advertisement) Addr

func (a *Advertisement) Addr() ble.Addr

Addr returns the address of the remote peripheral.

func (*Advertisement) AddrType added in v0.5.6

func (a *Advertisement) AddrType() uint8

AddressType returns the address type of the Advertisement. This is linux specific.

func (*Advertisement) Connectable

func (a *Advertisement) Connectable() bool

Connectable indicates weather the remote peripheral is connectable.

func (*Advertisement) Data

func (a *Advertisement) Data() []byte

Data returns the advertising data of the packet. This is linux specific.

func (*Advertisement) EventType

func (a *Advertisement) EventType() uint8

EventType returns the event type of Advertisement. This is linux specific.

func (*Advertisement) LocalName

func (a *Advertisement) LocalName() string

LocalName returns the LocalName of the remote peripheral.

func (*Advertisement) ManufacturerData

func (a *Advertisement) ManufacturerData() []byte

ManufacturerData returns the ManufacturerData of the advertisement.

func (*Advertisement) OverflowService

func (a *Advertisement) OverflowService() []ble.UUID

OverflowService returns the UUIDs of overflowed service.

func (*Advertisement) RSSI

func (a *Advertisement) RSSI() int

RSSI returns RSSI signal strength.

func (*Advertisement) ScanResponse

func (a *Advertisement) ScanResponse() []byte

ScanResponse returns the scan response of the packet, if it presents. This is linux specific.

func (*Advertisement) ServiceData

func (a *Advertisement) ServiceData() []ble.ServiceData

ServiceData returns the service data of the advertisement.

func (*Advertisement) Services

func (a *Advertisement) Services() []ble.UUID

Services returns the service UUIDs of the advertisement.

func (*Advertisement) SolicitedService

func (a *Advertisement) SolicitedService() []ble.UUID

SolicitedService returns UUIDs of solicited services.

func (*Advertisement) SrData added in v0.6.11

func (a *Advertisement) SrData() []byte

SrData returns the scan response data of the packet. This is linux specific

func (*Advertisement) Timestamp added in v0.5.7

func (a *Advertisement) Timestamp() int64

func (*Advertisement) ToMap

func (a *Advertisement) ToMap() (map[string]interface{}, error)

func (*Advertisement) TxPowerLevel

func (a *Advertisement) TxPowerLevel() int

TxPowerLevel returns the tx power level of the remote peripheral.

type BondInfo

type BondInfo interface {
	LongTermKey() []byte
	EDiv() uint16
	Random() uint64
	Legacy() bool
}

func NewBondInfo

func NewBondInfo(longTermKey []byte, ediv uint16, random uint64, legacy bool) BondInfo

type BondManager

type BondManager interface {
	Find(addr string) (BondInfo, error)
	Save(string, BondInfo) error
	Exists(addr string) bool
	Delete(addr string) error
}

type Client

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

Client ...

func NewClient

func NewClient(p *Pool) *Client

NewClient ...

func (*Client) Get

func (c *Client) Get() *bytes.Buffer

Get returns a buffer from the shared buffer pool.

func (*Client) LockPool added in v0.5.0

func (c *Client) LockPool()

LockPool ...

func (*Client) Put

func (c *Client) Put()

Put puts the oldest sent buffer back to the shared pool.

func (*Client) PutAll

func (c *Client) PutAll()

PutAll puts all the sent buffers back to the shared pool.

func (*Client) UnlockPool added in v0.5.0

func (c *Client) UnlockPool()

UnlockPool ...

type Command

type Command interface {
	OpCode() int
	Len() int
	Marshal([]byte) error
	String() string
}

Command ...

type CommandRP

type CommandRP interface {
	Unmarshal(b []byte) error
}

CommandRP ...

type CommandReject

type CommandReject struct {
	Reason uint16
	Data   []byte
}

CommandReject implements Command Reject (0x01) [Vol 3, Part A, 4.1].

func (CommandReject) Code

func (s CommandReject) Code() int

Code returns the event code of the command.

func (*CommandReject) Marshal

func (s *CommandReject) Marshal() []byte

Marshal serializes the command parameters into binary form.

func (*CommandReject) Unmarshal

func (s *CommandReject) Unmarshal(b []byte) error

Unmarshal de-serializes the binary data and stores the result in the receiver.

type Conn added in v0.5.0

type Conn struct {
	ble.Logger
	// contains filtered or unexported fields
}

Conn ...

func (*Conn) Close added in v0.5.0

func (c *Conn) Close() error

Close disconnects the connection by sending hci disconnect command to the device.

func (*Conn) ConnectionHandle added in v0.6.17

func (c *Conn) ConnectionHandle() uint8

func (*Conn) Context added in v0.5.0

func (c *Conn) Context() context.Context

Context returns the context that is used by this Conn.

func (*Conn) Disconnected added in v0.5.0

func (c *Conn) Disconnected() <-chan struct{}

Disconnected returns a receiving channel, which is closed when the connection disconnects.

func (*Conn) LECreditBasedConnectionRequest added in v0.5.0

func (c *Conn) LECreditBasedConnectionRequest(s sigCmd)

LECreditBasedConnectionRequest ...

func (*Conn) LEFlowControlCredit added in v0.5.0

func (c *Conn) LEFlowControlCredit(s sigCmd)

LEFlowControlCredit ...

func (*Conn) LocalAddr added in v0.5.0

func (c *Conn) LocalAddr() ble.Addr

LocalAddr returns local device's MAC address.

func (*Conn) OpenLECreditBasedConnection added in v0.6.17

func (c *Conn) OpenLECreditBasedConnection(psm uint16) (ble.LECreditBasedConnection, error)

func (*Conn) Pair added in v0.5.0

func (c *Conn) Pair(authData ble.AuthData, to time.Duration) error

func (*Conn) Read added in v0.5.0

func (c *Conn) Read(sdu []byte) (n int, err error)

Read copies re-assembled L2CAP PDUs into sdu.

func (*Conn) ReadRSSI added in v0.6.13

func (c *Conn) ReadRSSI() (int8, error)

func (*Conn) RemoteAddr added in v0.5.0

func (c *Conn) RemoteAddr() ble.Addr

RemoteAddr returns remote device's MAC address.

func (*Conn) RxMTU added in v0.5.0

func (c *Conn) RxMTU() int

RxMTU returns the MTU which the upper layer is capable of accepting.

func (*Conn) SetContext added in v0.5.0

func (c *Conn) SetContext(ctx context.Context)

SetContext sets the context that is used by this Conn.

func (*Conn) SetRxMTU added in v0.5.0

func (c *Conn) SetRxMTU(mtu int)

SetRxMTU sets the MTU which the upper layer is capable of accepting.

func (*Conn) SetTxMTU added in v0.5.0

func (c *Conn) SetTxMTU(mtu int)

SetTxMTU sets the MTU which the remote device is capable of accepting.

func (*Conn) Signal added in v0.5.0

func (c *Conn) Signal(req, rsp Signal) error

Signal ...

func (*Conn) StartEncryption added in v0.5.0

func (c *Conn) StartEncryption(ch chan ble.EncryptionChangedInfo) error

func (*Conn) TxMTU added in v0.5.0

func (c *Conn) TxMTU() int

TxMTU returns the MTU which the remote device is capable of accepting.

func (*Conn) Write added in v0.5.0

func (c *Conn) Write(sdu []byte) (int, error)

Write breaks down a L2CAP SDU into segmants [Vol 3, Part A, 7.3.1]

type ConnectionParameterUpdateRequest

type ConnectionParameterUpdateRequest struct {
	IntervalMin       uint16
	IntervalMax       uint16
	SlaveLatency      uint16
	TimeoutMultiplier uint16
}

ConnectionParameterUpdateRequest implements Connection Parameter Update Request (0x12) [Vol 3, Part A, 4.20].

func (ConnectionParameterUpdateRequest) Code

Code returns the event code of the command.

func (*ConnectionParameterUpdateRequest) Marshal

func (s *ConnectionParameterUpdateRequest) Marshal() []byte

Marshal serializes the command parameters into binary form.

func (*ConnectionParameterUpdateRequest) Unmarshal

func (s *ConnectionParameterUpdateRequest) Unmarshal(b []byte) error

Unmarshal de-serializes the binary data and stores the result in the receiver.

type ConnectionParameterUpdateResponse

type ConnectionParameterUpdateResponse struct {
	Result uint16
}

ConnectionParameterUpdateResponse implements Connection Parameter Update Response (0x13) [Vol 3, Part A, 4.21].

func (ConnectionParameterUpdateResponse) Code

Code returns the event code of the command.

func (*ConnectionParameterUpdateResponse) Marshal

func (s *ConnectionParameterUpdateResponse) Marshal() []byte

Marshal serializes the command parameters into binary form.

func (*ConnectionParameterUpdateResponse) Unmarshal

func (s *ConnectionParameterUpdateResponse) Unmarshal(b []byte) error

Unmarshal de-serializes the binary data and stores the result in the receiver.

type CustomCommand added in v0.6.3

type CustomCommand struct {
	Payload interface{}
	// contains filtered or unexported fields
}

func (*CustomCommand) Len added in v0.6.3

func (c *CustomCommand) Len() int

func (*CustomCommand) Marshal added in v0.6.3

func (c *CustomCommand) Marshal(b []byte) error

func (*CustomCommand) OpCode added in v0.6.3

func (c *CustomCommand) OpCode() int

func (*CustomCommand) String added in v0.6.3

func (c *CustomCommand) String() string

type DisconnectRequest

type DisconnectRequest struct {
	DestinationCID uint16
	SourceCID      uint16
}

DisconnectRequest implements Disconnect Request (0x06) [Vol 3, Part A, 4.6].

func (DisconnectRequest) Code

func (s DisconnectRequest) Code() int

Code returns the event code of the command.

func (*DisconnectRequest) Marshal

func (s *DisconnectRequest) Marshal() []byte

Marshal serializes the command parameters into binary form.

func (*DisconnectRequest) Unmarshal

func (s *DisconnectRequest) Unmarshal(b []byte) error

Unmarshal de-serializes the binary data and stores the result in the receiver.

type DisconnectResponse

type DisconnectResponse struct {
	DestinationCID uint16
	SourceCID      uint16
}

DisconnectResponse implements Disconnect Response (0x07) [Vol 3, Part A, 4.7].

func (DisconnectResponse) Code

func (s DisconnectResponse) Code() int

Code returns the event code of the command.

func (*DisconnectResponse) Marshal

func (s *DisconnectResponse) Marshal() []byte

Marshal serializes the command parameters into binary form.

func (*DisconnectResponse) Unmarshal

func (s *DisconnectResponse) Unmarshal(b []byte) error

Unmarshal de-serializes the binary data and stores the result in the receiver.

type Encrypter added in v0.5.0

type Encrypter interface {
	Encrypt() error
}

type ErrCommand

type ErrCommand byte

ErrCommand [Vol2, Part D, 1.3 ]

const (
	ErrUnknownCommand       ErrCommand = 0x01 // Unknown HCI Command
	ErrConnID               ErrCommand = 0x02 // Unknown Connection Identifier
	ErrHardware             ErrCommand = 0x03 // Hardware Failure
	ErrPageTimeout          ErrCommand = 0x04 // Page Timeout
	ErrAuth                 ErrCommand = 0x05 // Authentication Failure
	ErrPINMissing           ErrCommand = 0x06 // PIN or Key Missing
	ErrMemoryCapacity       ErrCommand = 0x07 // Memory Capacity Exceeded
	ErrConnTimeout          ErrCommand = 0x08 // Connection Timeout
	ErrConnLimit            ErrCommand = 0x09 // Connection Limit Exceeded
	ErrSCOConnLimit         ErrCommand = 0x0A // Synchronous Connection Limit To A Device Exceeded
	ErrACLConnExists        ErrCommand = 0x0B // ACL Connection Already Exists
	ErrDisallowed           ErrCommand = 0x0C // Command Disallowed
	ErrLimitedResource      ErrCommand = 0x0D // Connection Rejected due to Limited Resources
	ErrSecurity             ErrCommand = 0x0E // Connection Rejected Due To Security Reasons
	ErrBDADDR               ErrCommand = 0x0F // Connection Rejected due to Unacceptable BD_ADDR
	ErrConnAcceptTimeout    ErrCommand = 0x10 // Connection Accept Timeout Exceeded
	ErrUnsupportedParams    ErrCommand = 0x11 // Unsupported Feature or Parameter Value
	ErrInvalidParams        ErrCommand = 0x12 // Invalid HCI Command Parameters
	ErrRemoteUser           ErrCommand = 0x13 // Remote User Terminated Connection
	ErrRemoteLowResources   ErrCommand = 0x14 // Remote Device Terminated Connection due to Low Resources
	ErrRemotePowerOff       ErrCommand = 0x15 // Remote Device Terminated Connection due to Power Off
	ErrLocalHost            ErrCommand = 0x16 // Connection Terminated By Local Host
	ErrRepeatedAttempts     ErrCommand = 0x17 // Repeated Attempts
	ErrPairingNotAllowed    ErrCommand = 0x18 // Pairing Not Allowed
	ErrUnknownLMP           ErrCommand = 0x19 // Unknown LMP PDU
	ErrUnsupportedLMP       ErrCommand = 0x1A // Unsupported Remote Feature / Unsupported LMP Feature
	ErrSCOOffset            ErrCommand = 0x1B // SCO Offset Rejected
	ErrSCOInterval          ErrCommand = 0x1C // SCO Interval Rejected
	ErrSCOAirMode           ErrCommand = 0x1D // SCO Air Mode Rejected
	ErrInvalidLLParams      ErrCommand = 0x1E // Invalid LMP Parameters / Invalid LL Parameters
	ErrUnspecified          ErrCommand = 0x1F // Unspecified Error
	ErrUnsupportedLLParams  ErrCommand = 0x20 // Unsupported LMP Parameter Value / Unsupported LL Parameter Value
	ErrRoleChangeNotAllowed ErrCommand = 0x21 // Role Change Not Allowed
	ErrLLResponseTimeout    ErrCommand = 0x22 // LMP Response Timeout / LL Response Timeout
	ErrLMPTransColl         ErrCommand = 0x23 // LMP Error Transaction Collision
	ErrLMPPDU               ErrCommand = 0x24 // LMP PDU Not Allowed
	ErrEncNotAccepted       ErrCommand = 0x25 // Encryption Mode Not Acceptable
	ErrLinkKey              ErrCommand = 0x26 // Link Key cannot be Changed
	ErrQoSNotSupported      ErrCommand = 0x27 // Requested QoS Not Supported
	ErrInstantPassed        ErrCommand = 0x28 // Instant Passed
	ErrUnitKeyNotSupported  ErrCommand = 0x29 // Pairing With Unit Key Not Supported
	ErrDifferentTransColl   ErrCommand = 0x2A // Different Transaction Collision
	ErrQOSParameter         ErrCommand = 0x2C // QoS Unacceptable Parameter
	ErrQOSReject            ErrCommand = 0x2D // QoS Rejected
	ErrChannelClass         ErrCommand = 0x2E // Channel Classification Not Supported
	ErrInsufficientSecurity ErrCommand = 0x2F // Insufficient Security
	ErrOutOfRange           ErrCommand = 0x30 // Parameter Out Of Mandatory Range
	ErrRoleSwitchPending    ErrCommand = 0x32 // Role Switch Pending
	ErrReservedSlot         ErrCommand = 0x34 // Reserved Slot Violation
	ErrRoleSwitch           ErrCommand = 0x35 // Role Switch Failed
	ErrEIRTooLarge          ErrCommand = 0x36 // Extended Inquiry Response Too Large
	ErrSecureSimplePairing  ErrCommand = 0x37 // Secure Simple Pairing Not Supported By Host
	ErrHostBusy             ErrCommand = 0x38 // Host Busy - Pairing
	ErrNoChannel            ErrCommand = 0x39 // Connection Rejected due to No Suitable Channel Found
	ErrControllerBusy       ErrCommand = 0x3A // Controller Busy
	ErrConnParams           ErrCommand = 0x3B // Unacceptable Connection Parameters
	ErrDirAdvTimeout        ErrCommand = 0x3C // Directed Advertising Timeout
	ErrMIC                  ErrCommand = 0x3D // Connection Terminated due to MIC Failure
	ErrEstablished          ErrCommand = 0x3E // Connection Failed to be Established
	ErrMACConn              ErrCommand = 0x3F // MAC Connection Failed
	ErrCoarseClock          ErrCommand = 0x40 // Coarse Clock Adjustment Rejected but Will Try to Adjust Using Clock Dragging

)

HCI Command Errors [Vol2, Part D, 1.3 ] FIXME: Terrible shorthand. Name them properly.

func (ErrCommand) Error

func (e ErrCommand) Error() string

type HCI added in v0.5.0

type HCI struct {
	sync.Mutex

	ble.Logger
	// contains filtered or unexported fields
}

HCI ...

func NewHCI added in v0.5.0

func NewHCI(smp SmpManagerFactory, opts ...ble.Option) (*HCI, error)

NewHCI returns a hci device.

func (*HCI) Accept added in v0.5.0

func (h *HCI) Accept() (ble.Conn, error)

Accept starts advertising and accepts connection.

func (*HCI) Addr added in v0.5.0

func (h *HCI) Addr() ble.Addr

Addr ...

func (*HCI) Advertise added in v0.5.0

func (h *HCI) Advertise() error

Advertise starts advertising.

func (*HCI) AdvertiseAdv added in v0.5.0

func (h *HCI) AdvertiseAdv(a ble.Advertisement) error

AdvertiseAdv advertises a given Advertisement

func (*HCI) AdvertiseIBeacon added in v0.5.0

func (h *HCI) AdvertiseIBeacon(u ble.UUID, major, minor uint16, pwr int8) error

AdvertiseIBeacon advertises iBeacon with specified parameters.

func (*HCI) AdvertiseIBeaconData added in v0.5.0

func (h *HCI) AdvertiseIBeaconData(md []byte) error

AdvertiseIBeaconData advertise iBeacon with given manufacturer data.

func (*HCI) AdvertiseMfgData added in v0.5.0

func (h *HCI) AdvertiseMfgData(id uint16, md []byte) error

AdvertiseMfgData avertises the given manufacturer data.

func (*HCI) AdvertiseNameAndServices added in v0.5.0

func (h *HCI) AdvertiseNameAndServices(name string, uuids ...ble.UUID) error

AdvertiseNameAndServices advertises device name, and specified service UUIDs. It tries to fit the UUIDs in the advertising data as much as possible. If name doesn't fit in the advertising data, it will be put in scan response.

func (*HCI) AdvertiseServiceData16 added in v0.5.0

func (h *HCI) AdvertiseServiceData16(id uint16, b []byte) error

AdvertiseServiceData16 advertises data associated with a 16bit service uuid

func (*HCI) Bytes added in v0.5.0

func (h *HCI) Bytes() []byte

func (*HCI) Close added in v0.5.0

func (h *HCI) Close() error

Close ...

func (*HCI) Dial added in v0.5.0

func (h *HCI) Dial(ctx context.Context, a ble.Addr) (ble.Client, error)

Dial ...

func (*HCI) EnableSecurity added in v0.5.0

func (h *HCI) EnableSecurity(bm interface{}) error

func (*HCI) Error added in v0.5.0

func (h *HCI) Error() error

Error ...

func (*HCI) Init added in v0.5.0

func (h *HCI) Init() error

Init ...

func (*HCI) Option added in v0.5.0

func (h *HCI) Option(opts ...ble.Option) error

Option sets the options specified.

func (*HCI) Scan added in v0.5.0

func (h *HCI) Scan(allowDup bool) error

Scan starts scanning.

func (*HCI) Send added in v0.5.0

func (h *HCI) Send(c Command, r CommandRP) error

Send ...

func (*HCI) SendVendorSpecificCommand added in v0.6.3

func (h *HCI) SendVendorSpecificCommand(op uint16, length uint8, v interface{}) error

func (*HCI) SetAdvHandler added in v0.5.0

func (h *HCI) SetAdvHandler(ah ble.AdvHandler) error

SetAdvHandler ...

func (*HCI) SetAdvHandlerSync added in v0.5.0

func (h *HCI) SetAdvHandlerSync(sync bool) error

SetAdvHandlerSync overrides default advertising handler behavior (async)

func (*HCI) SetAdvParams added in v0.5.0

func (h *HCI) SetAdvParams(param cmd.LESetAdvertisingParameters) error

SetAdvParams overrides default advertising parameters.

func (*HCI) SetAdvertisement added in v0.5.0

func (h *HCI) SetAdvertisement(ad []byte, sr []byte) error

SetAdvertisement sets advertising data and scanResp.

func (*HCI) SetCentralRole added in v0.5.0

func (h *HCI) SetCentralRole() error

SetCentralRole is not supported

func (*HCI) SetConnParams added in v0.5.0

func (h *HCI) SetConnParams(param cmd.LECreateConnection) error

SetConnParams overrides default connection parameters.

func (*HCI) SetDialerTimeout added in v0.5.0

func (h *HCI) SetDialerTimeout(d time.Duration) error

SetDialerTimeout sets dialing timeout for Dialer.

func (*HCI) SetErrorHandler added in v0.5.0

func (h *HCI) SetErrorHandler(handler func(error)) error

SetErrorHandler ...

func (*HCI) SetGattCacheFile added in v0.5.5

func (h *HCI) SetGattCacheFile(filename string)

func (*HCI) SetListenerTimeout added in v0.5.0

func (h *HCI) SetListenerTimeout(d time.Duration) error

SetListenerTimeout sets dialing timeout for Listener.

func (*HCI) SetPeripheralRole added in v0.5.0

func (h *HCI) SetPeripheralRole() error

SetPeripheralRole is not supported

func (*HCI) SetScanParams added in v0.5.0

func (h *HCI) SetScanParams(param cmd.LESetScanParameters) error

SetScanParams overrides default scanning parameters.

func (*HCI) SetTransportH4Socket added in v0.5.4

func (h *HCI) SetTransportH4Socket(addr string, timeout time.Duration) error

SetTransportH4Socket sets h4 socket server

func (*HCI) SetTransportH4Uart added in v0.5.4

func (h *HCI) SetTransportH4Uart(path string, baud int) error

SetTransportH4Uart sets h4 uart path

func (*HCI) SetTransportHCISocket added in v0.5.4

func (h *HCI) SetTransportHCISocket(id int) error

SetTransportHCISocket sets HCI device for hci socket

func (*HCI) StopAdvertising added in v0.5.0

func (h *HCI) StopAdvertising() error

StopAdvertising stops advertising.

func (*HCI) StopScanning added in v0.5.0

func (h *HCI) StopScanning() error

StopScanning stops scanning.

type L2CAPConnectionRequest added in v0.6.17

type L2CAPConnectionRequest struct {
	PSM       uint16
	SourceCID uint16
}

L2CAPConnectionRequest implements L2CAP Connection Request (0x02) [Vol 3, Part A, 4.2].

func (L2CAPConnectionRequest) Code added in v0.6.17

func (s L2CAPConnectionRequest) Code() int

Code returns the event code of the command.

func (*L2CAPConnectionRequest) Marshal added in v0.6.17

func (s *L2CAPConnectionRequest) Marshal() []byte

Marshal serializes the command parameters into binary form.

func (*L2CAPConnectionRequest) Unmarshal added in v0.6.17

func (s *L2CAPConnectionRequest) Unmarshal(b []byte) error

Unmarshal de-serializes the binary data and stores the result in the receiver.

type L2CAPConnectionResponse added in v0.6.17

type L2CAPConnectionResponse struct {
	DestinationCID uint16
	SourceCID      uint16
	MTU            uint16
	Result         uint16
	Status         uint16
}

L2CAPConnectionResponse implements L2CAP Connection Response (0x03) [Vol 3, Part A, 4.3].

func (L2CAPConnectionResponse) Code added in v0.6.17

func (s L2CAPConnectionResponse) Code() int

Code returns the event code of the command.

func (*L2CAPConnectionResponse) Marshal added in v0.6.17

func (s *L2CAPConnectionResponse) Marshal() []byte

Marshal serializes the command parameters into binary form.

func (*L2CAPConnectionResponse) Unmarshal added in v0.6.17

func (s *L2CAPConnectionResponse) Unmarshal(b []byte) error

Unmarshal de-serializes the binary data and stores the result in the receiver.

type L2CAPCreditBasedConnectionRequest added in v0.6.17

type L2CAPCreditBasedConnectionRequest struct {
	SPSM           uint16
	MTU            uint16
	MPS            uint16
	InitialCredits uint16
	SourceCID      uint16
}

L2CAPCreditBasedConnectionRequest implements L2CAP Credit Based Connection Request (0x17) [Vol 3, Part A, 4.25].

func (L2CAPCreditBasedConnectionRequest) Code added in v0.6.17

Code returns the event code of the command.

func (*L2CAPCreditBasedConnectionRequest) Marshal added in v0.6.17

func (s *L2CAPCreditBasedConnectionRequest) Marshal() []byte

Marshal serializes the command parameters into binary form.

func (*L2CAPCreditBasedConnectionRequest) Unmarshal added in v0.6.17

func (s *L2CAPCreditBasedConnectionRequest) Unmarshal(b []byte) error

Unmarshal de-serializes the binary data and stores the result in the receiver.

type L2CAPCreditBasedConnectionResponse added in v0.6.17

type L2CAPCreditBasedConnectionResponse struct {
	MTU               uint16
	MPS               uint16
	InitialCreditsCID uint16
	Result            uint16
	DestinationCID    uint16
}

L2CAPCreditBasedConnectionResponse implements L2CAP Credit Based Connection Response (0x18) [Vol 3, Part A, 4.26].

func (L2CAPCreditBasedConnectionResponse) Code added in v0.6.17

Code returns the event code of the command.

func (*L2CAPCreditBasedConnectionResponse) Marshal added in v0.6.17

Marshal serializes the command parameters into binary form.

func (*L2CAPCreditBasedConnectionResponse) Unmarshal added in v0.6.17

func (s *L2CAPCreditBasedConnectionResponse) Unmarshal(b []byte) error

Unmarshal de-serializes the binary data and stores the result in the receiver.

type LECreditBasedConnectionRequest

type LECreditBasedConnectionRequest struct {
	LEPSM          uint16
	SourceCID      uint16
	MTU            uint16
	MPS            uint16
	InitialCredits uint16
}

LECreditBasedConnectionRequest implements LE Credit Based Connection Request (0x14) [Vol 3, Part A, 4.22].

func (LECreditBasedConnectionRequest) Code

Code returns the event code of the command.

func (*LECreditBasedConnectionRequest) Marshal

func (s *LECreditBasedConnectionRequest) Marshal() []byte

Marshal serializes the command parameters into binary form.

func (*LECreditBasedConnectionRequest) Unmarshal

func (s *LECreditBasedConnectionRequest) Unmarshal(b []byte) error

Unmarshal de-serializes the binary data and stores the result in the receiver.

type LECreditBasedConnectionResponse

type LECreditBasedConnectionResponse struct {
	DestinationCID    uint16
	MTU               uint16
	MPS               uint16
	InitialCreditsCID uint16
	Result            uint16
}

LECreditBasedConnectionResponse implements LE Credit Based Connection Response (0x15) [Vol 3, Part A, 4.23].

func (LECreditBasedConnectionResponse) Code

Code returns the event code of the command.

func (*LECreditBasedConnectionResponse) Marshal

func (s *LECreditBasedConnectionResponse) Marshal() []byte

Marshal serializes the command parameters into binary form.

func (*LECreditBasedConnectionResponse) Unmarshal

func (s *LECreditBasedConnectionResponse) Unmarshal(b []byte) error

Unmarshal de-serializes the binary data and stores the result in the receiver.

type LEFlowControlCredit

type LEFlowControlCredit struct {
	CID     uint16
	Credits uint16
}

LEFlowControlCredit implements LE Flow Control Credit (0x16) [Vol 3, Part A, 4.24].

func (LEFlowControlCredit) Code

func (s LEFlowControlCredit) Code() int

Code returns the event code of the command.

func (*LEFlowControlCredit) Marshal

func (s *LEFlowControlCredit) Marshal() []byte

Marshal serializes the command parameters into binary form.

func (*LEFlowControlCredit) Unmarshal

func (s *LEFlowControlCredit) Unmarshal(b []byte) error

Unmarshal de-serializes the binary data and stores the result in the receiver.

type OobDataFlag

type OobDataFlag byte
const (
	OobNotPresent OobDataFlag = iota
	OobPreset
)

type Pool

type Pool struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Pool ...

func NewPool

func NewPool(sz int, cnt int) (*Pool, error)

NewPool ...

type RandomAddress

type RandomAddress struct {
	ble.Addr
}

RandomAddress is a Random Device Address.

type Signal added in v0.5.0

type Signal interface {
	Code() int
	Marshal() []byte
	Unmarshal([]byte) error
}

Signal ...

type SmpConfig

type SmpConfig struct {
	IoCap, OobFlag, AuthReq, MaxKeySize, InitKeyDist, RespKeyDist byte
}

type SmpManager

type SmpManager interface {
	InitContext(localAddr, remoteAddr []byte,
		localAddrType, remoteAddrType uint8)
	Handle(data []byte) error
	Pair(authData ble.AuthData, to time.Duration) error
	BondInfoFor(addr string) BondInfo
	DeleteBondInfo() error
	StartEncryption() error
	SetWritePDUFunc(func([]byte) (int, error))
	SetEncryptFunc(func(BondInfo) error)
	LegacyPairingInfo() (bool, []byte)
}

type SmpManagerFactory

type SmpManagerFactory interface {
	Create(SmpConfig, ble.Logger) SmpManager
	SetBondManager(BondManager)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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