gap

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EvtBase = 0x10
	EvtLast = 0x2F
)
View Source
const (
	EvtConnected              = EvtBase + 0  // connected to peer
	EvtDisconnected           = EvtBase + 1  // disconnected from peer
	EvtConnParamUpdate        = EvtBase + 2  // connection parameters updated
	EvtSecParamsReq           = EvtBase + 3  // req. to provide security param
	EvtSecInfoReq             = EvtBase + 4  // req. to provide security info
	EvtPasskeyDisplay         = EvtBase + 5  // req. to display a passkey
	EvtKeyPressed             = EvtBase + 6  // keypress on the remote device
	EvtAuthKeyReq             = EvtBase + 7  // req. to provide an auth. key
	EvtLESCDHKeyReq           = EvtBase + 8  // req. to calculate LESConn DHKey
	EvtAuthStatus             = EvtBase + 9  // auth. procedure completed
	EvtConnSecUpdate          = EvtBase + 10 // connection security update
	EvtTimeout                = EvtBase + 11 // timeout expire
	EvtRSSIChanged            = EvtBase + 12 // RSSI repor
	EvtAdvReport              = EvtBase + 13 // advertising repor
	EvtSecReq                 = EvtBase + 14 // security reques
	EvtConnParamUpdateReq     = EvtBase + 15 // connection param. update req.
	EvtScanReqReport          = EvtBase + 16 // scan request report
	EvtPHYUpdateReq           = EvtBase + 17 // PHY update request
	EvtPHYUpdate              = EvtBase + 18 // PHY update procedure completed
	EvtDataLengthUpdateReq    = EvtBase + 19 // data length update request
	EvtDataLengthUpdate       = EvtBase + 20 // LL data ch. PDU pay.len. update
	EvtQOSChannelSurveyReport = EvtBase + 21 // channel survey report
	EvtADVSetTerminated       = EvtBase + 22 // advertising set terminated
)
View Source
const (
	MaxAdvSetDataSize         = 31
	MaxExtendedAdvSetDataSize = 255
)
View Source
const ErrorBase = ble.ErrorBase + 0x200

Variables

This section is empty.

Functions

func SetConnCfg

func SetConnCfg(cfg *ConnCfg, ramBase uintptr) error

func SetDeviceName

func SetDeviceName(writePerm ConnSecMode, devName string) error

SetDeviceName sets device name and security mode.

func SetPPCP

func SetPPCP(connParams *ConnParams) error

SetPPCP sets Peripheral Preferred Connection Parameters.

func SetRoleCountCfg

func SetRoleCountCfg(cfg *RoleCountCfg, ramBase uintptr) error

SetRoleCountCfg sets the role count configuration.

func StartAdv

func StartAdv(advHandle AdvSetHandle, connCfgTag uint8) error

StartAdv starts advertising.

func StopAdv

func StopAdv(advHandle AdvSetHandle) error

StopAdv stops advertising.

func UpdateConnParam

func UpdateConnParam(connHandle ble.Handle, connParams *ConnParams) error

UpdateConnParam updates connection parameters.

func UpdateDataLength added in v0.3.0

func UpdateDataLength(connHandle ble.Handle, dlParams *DataLengthParams, dlLimitation *DataLengthLimitation) error

UpdateDataLength initiated or respondd to a Data Length Update Procedure.

Types

type Addr

type Addr struct {
	Type  AddrType
	Value [6]byte
}

type AddrType

type AddrType uint8
const (
	PeerID                     AddrType = 1 << 0
	AddrKind                   AddrType = 0x7F << 1
	Public                     AddrType = 0x00 << 1
	RandomStatic               AddrType = 0x01 << 1
	RandomPrivateResolvable    AddrType = 0x02 << 1
	RandomPrivateNonresolvable AddrType = 0x03 << 1
	Anonymous                  AddrType = 0x7F << 1
)

type AdvData

type AdvData struct {
	Data        ble.Data // advertising data
	ScanRspData ble.Data // scan response data
}

type AdvDataType

type AdvDataType uint8
const (

	// Flags for discoverability.
	Flags AdvDataType = 0x01

	// Partial list of 16-bit service UUIDs.
	PartialServiceUUID16 AdvDataType = 0x02

	// Complete list of 16-bit service UUIDs.
	CompleteServiceUUID16 AdvDataType = 0x03

	// Partial list of 32-bit service UUIDs.
	PartialServiceUUID32 AdvDataType = 0x04

	// Complete list of 32-bit service UUIDs.
	CompleteServiceUUID32 AdvDataType = 0x05

	// Partial list of 128-bit service UUIDs.
	PartialServiceUUID128 AdvDataType = 0x06

	// Complete list of 128-bit service UUIDs.
	CompleteServiceUUID128 AdvDataType = 0x07

	// Short local device name.
	ShortLocalName AdvDataType = 0x08

	// Complete local device name.
	CompleteLocalName AdvDataType = 0x09

	// Transmit power level.
	TxPowerLevel AdvDataType = 0x0A

	// Class of device.
	ClassOfDevice AdvDataType = 0x0D

	// Simple Pairing Hash C.
	SimplePairingHashC AdvDataType = 0x0E

	// Simple Pairing Randomizer R.
	SimplePairingRandomizerR AdvDataType = 0x0F

	// Security Manager TK Value.
	SecurityManagerTKValue AdvDataType = 0x10

	// Security Manager Out Of Band Flags.
	SecurityManagerOOBFlags AdvDataType = 0x11

	// Slave Connection Interval Range
	SlaveConnectionIntervalRange AdvDataType = 0x12

	// List of 16-bit Service Solicitation UUIDs.
	SolicitedServiceUUID16 AdvDataType = 0x14

	// List of 128-bit Service Solicitation UUIDs.
	SolicitedServiceUUID128 AdvDataType = 0x15

	// Service Data - 16-bit UUID.
	ServiceData AdvDataType = 0x16

	// Public Target Address.
	PublicTargetAddress AdvDataType = 0x17

	// Random Target Address.
	RandomTargetAddress AdvDataType = 0x18

	// Appearance.
	Appearance AdvDataType = 0x19

	// Advertising Interval.
	AdvertisingInterval AdvDataType = 0x1A

	// LE Bluetooth Device Address.
	LEBluetoothDeviceAddress AdvDataType = 0x1B

	// LE Role.
	LERole AdvDataType = 0x1C

	// Simple Pairing Hash C-256.
	SimplePairingHashC256 AdvDataType = 0x1D

	// Simple Pairing Randomizer R-256.
	SimplePairingRandomizerR256 AdvDataType = 0x1E

	// Service Data - 32-bit UUID.
	ServiceDataUUID32 AdvDataType = 0x20

	// Service Data - 128-bit UUID.
	ServiceDataUUID128 AdvDataType = 0x21

	// LE Secure Connections Confirmation Value.
	LESC_ConfirmationValue AdvDataType = 0x22

	// LE Secure Connections Random Value.
	LESCRandomValue AdvDataType = 0x23

	// URI
	URI AdvDataType = 0x24

	// 3D Information Data.
	InformationData3D AdvDataType = 0x3D

	// Manufacturer Specific Data.
	ManufacturerSpecificData AdvDataType = 0xFF
)

type AdvFlags

type AdvFlags uint8
const (
	LimitedDiscMode    AdvFlags = 1 << 0 // LE limited discoverable mode
	GeneralDiscMode    AdvFlags = 1 << 1 // LE general discoverable mode
	LEOnly             AdvFlags = 1 << 2 // BR/EDR not supported. */
	DualModeController AdvFlags = 1 << 3 // simultaneous LE and BR/EDR, controller
	DualModeHost       AdvFlags = 1 << 4 // simultaneous LE and BR/EDR, host
)

type AdvOptions

type AdvOptions uint8
const (
	AdvAnonymous      AdvOptions = 1 << 0 // omit advertiser's address
	AdvIncludeTxPower AdvOptions = 1 << 1 // not supported on this SoftDevice
)

type AdvParams

type AdvParams struct {
	Props        AdvProps     // properties of the advertising events
	PeerAddr     *Addr        // address of a known peer or special pseudo-address
	Interval     uint32       // advertising interval in 625 us units
	Duration     uint16       // advertising duration in 10 ms units
	MaxEvts      uint8        // maximum advertising events that can be sent
	ChanMask     ChanMask     // channel mask for primary and secondary adv. channels
	Policy       FilterPolicy // filter policy
	PrimaryPHY   PHY          // for primary advertising channel packets
	SecondaryPHY PHY          // for secondary advertising channel packets
	Set          AdvSet
}

type AdvProps

type AdvProps struct {
	Type    AdvType
	Options AdvOptions
}

type AdvSet

type AdvSet uint8
const (
	AdvSetID      AdvSet = 0x0F << 0
	NotifyScanReq AdvSet = 1 << 4
)

type AdvSetHandle

type AdvSetHandle uint8
const NewAdvSet AdvSetHandle = 0xFF

func ConfigureAdvSet

func ConfigureAdvSet(handle AdvSetHandle, data *AdvData, params *AdvParams) (AdvSetHandle, error)

ConfigureAdvSet configures an advertising set.

type AdvType

type AdvType uint8
const (
	// Connectable and scannable undirected advertising events.
	ConnectableScannableUndirected AdvType = 1

	// Connectable non-scannable directed advertising events. Advertising
	// interval is less that 3.75 ms. Use this type for fast reconnections.
	// Advertising data is not supported.
	ConnectableNonscannableDirectedHighDutyCycle AdvType = 2

	// Connectable non-scannable directed advertising events. Advertising data
	// is not supported.
	ConnectableNonscannableDirected AdvType = 3

	// Non-connectable scannable undirected advertising events.
	NonconnectableScannableUndirected AdvType = 4

	// Non-connectable non-scannable undirected advertising events.
	NonconnectableNonscannableUndirected AdvType = 5

	// Connectable non-scannable undirected advertising events using extended
	// advertising PDUs.
	ExtendedConnectableNonscannableUndirected AdvType = 6

	// Connectable non-scannable directed advertising events using extended
	// advertising PDUs.
	ExtendedConnectableNonscannableDirected AdvType = 7

	// Non-connectable scannable undirected advertising events using extended
	// advertising PDUs. Only scan response data is supported.
	ExtendedNonconnectableScannableUndirected AdvType = 8

	// Non-connectable scannable directed advertising events using extended
	// advertising PDUs. Only scan response data is supported.
	ExtendedNonconnectableScannableDirected AdvType = 9

	// Non-connectable non-scannable undirected advertising events using
	// extended advertising PDUs.
	ExtendedNonconnectableNonscannableUndirected AdvType = 10

	// Non-connectable non-scannable directed advertising events using extended
	// advertising PDUs.
	ExtendedNonconnectableNonscannableDirected AdvType = 11
)

type ChanMask

type ChanMask [5]byte

type ConnCfg

type ConnCfg struct {
	Tag uint8

	ConnCount   uint8  // max. number of concurrent connections
	EventLength uint16 // time used on every connection interval in 1.25 ms uints
	// contains filtered or unexported fields
}

type ConnParamUpdate

type ConnParamUpdate struct {
	ble.EvtHdr

	ConnParams ConnParams // GAP connection parameters
	// contains filtered or unexported fields
}

type ConnParams

type ConnParams struct {
	MinConnInterval uint16 // min. connection interval in 1.25 ms units
	MaxConnInterval uint16 // max. connection interval in 1.25 ms units
	SlaveLatency    uint16 // slave latency in number of connection events
	ConnSupTimeout  uint16 // connection supervision timeout in 10 ms units
}

type ConnSecMode

type ConnSecMode uint8
const (
	// No access.
	SecModeNoAccess ConnSecMode = 0x00 // level=0, mode=0

	// No protection required (open link).
	SecModeOpen ConnSecMode = 0x11 // level=1, mode=1

	// Encryption required, but no MITM protection.
	SecModeEncNoMTIM ConnSecMode = 0x21 // level=2, mode=1

	// Encryption rand MITM protection required.
	SecModeEncWithMTIM ConnSecMode = 0x31 // level=3, mode=1

	// LESC encryption and MITM protection required.
	SecModeLESCWithMTIM_MITM ConnSecMode = 0x41 // level=4, mode1

	// Signing or encryption required, no MITM protection.
	SecModeSignedNoMTIM ConnSecMode = 0x12 // level=1, mode=2

	// Signing or encryption with MITM protection required.
	SecModeSignedWithMTIM ConnSecMode = 0x22 // level=2, mode=2
)

type Connected

type Connected struct {
	ble.EvtHdr

	PeerAddr   Addr       // bluetooth address of the peer device
	Role       Role       // BLE role for this connection
	ConnParams ConnParams // GAP connection parameters
	AdvHandle  uint8      // advertising handle in which advertising has ended
	AdvData    AdvData    // buffers corresponding to the terminated advert. set
	// contains filtered or unexported fields
}

type DataLengthLimitation added in v0.3.0

type DataLengthLimitation struct {
	TxPayloadLimitedOctets uint16 // If > 0, the requested TX packet length is too long by this many octets.
	RxPayloadLimitedOctets uint16 // If > 0, the requested RX packet length is too long by this many octets.
	TxRxTimeLimitedUs      uint16 // If > 0, the requested combination of TX and RX packet lengths is too long by this many microseconds.
}

type DataLengthParams added in v0.3.0

type DataLengthParams struct {
	MaxTxOctets uint16
	MaxRxOctets uint16
	MaxTxTimeUs uint16
	MaxRxTimeUs uint16
}

DataLengthParams contains maximum length/time that a Controller supports for single Link Layer Data Channel PDU.

type DataLengthUpdate added in v0.3.0

type DataLengthUpdate struct {
	ble.EvtHdr

	EffectiveParams DataLengthParams // The effective data length parameters
	// contains filtered or unexported fields
}

type DataLengthUpdateReq added in v0.3.0

type DataLengthUpdateReq struct {
	ble.EvtHdr

	PeerParams DataLengthParams // Peer data length parameters
	// contains filtered or unexported fields
}

type Disconnected

type Disconnected struct {
	ble.EvtHdr

	Reason ble.HCIStatus // HCI error code
	// contains filtered or unexported fields
}

type Error

type Error uint32
const (
	// UUID list does not contain an integral number of UUIDs
	ErrUUIDListMismatch Error = ErrorBase + 0

	// Use of whitelist not permitted with discoverable advertising.
	ErrDiscoverableWithWhitelist Error = ErrorBase + 1

	// The upper two bits of the address do not correspond to the specified
	// address type.
	ErrInvalidBLEAddr Error = ErrorBase + 2

	// Attempt to modify the whitelist while already in use by another
	// operation.
	ErrWhitelistInUse Error = ErrorBase + 3

	// Attempt to modify the device identity list while already in use by
	// another operation.
	ErrDeviceIdentitiesInUse Error = ErrorBase + 4

	// The device identity list contains entries with duplicate identity
	// addresses.
	ErrDeviceIdentitiesDuplicate Error = ErrorBase + 5
)

func (Error) Error

func (e Error) Error() string

type FilterPolicy

type FilterPolicy uint8
const (
	PolicyAny     FilterPolicy = 0 // allow scan/connect requests from any dev.
	PolicyScanReq FilterPolicy = 1 // filter scan requests with whitelist
	PolicyConnReq FilterPolicy = 2 // filter connect requests with whitelist
	PolicyBoth    FilterPolicy = 3 // filter both scan andconnect requests with whitelist
)

type PHY

type PHY uint8
const (
	PHYAuto   PHY = 0
	PHY1Mbps  PHY = 1
	PHY2Mbps  PHY = 2
	PHYCoded  PHY = 4
	PHYNotSet PHY = 255
)

type Role

type Role uint8
const (
	RoleInvalid Role = 0 // invalid role
	RolePeriph  Role = 1 // peripheral role
	RoleCentral Role = 2 // central
)

type RoleCountCfg

type RoleCountCfg struct {
	AdvSetCount                   uint8 // max. number of advertising sets
	PeriphRoleCount               uint8 // max. number of connections acting as a peripheral
	CentralRoleCount              uint8 // max. number of connections acting as a central
	CentralSecCount               uint8 // number of SMP instances shared between connections acting as a central
	QoSChannelSurveyRoleAvailable bool
}

Jump to

Keyboard shortcuts

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