bledefs

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BLE_ADDR_TYPE_PUBLIC  BleAddrType = 0
	BLE_ADDR_TYPE_RANDOM              = 1
	BLE_ADDR_TYPE_RPA_PUB             = 2
	BLE_ADDR_TYPE_RPA_RND             = 3
)
View Source
const (
	BLE_SCAN_FILT_NO_WL        BleScanFilterPolicy = 0
	BLE_SCAN_FILT_USE_WL                           = 1
	BLE_SCAN_FILT_NO_WL_INITA                      = 2
	BLE_SCAN_FILT_USE_WL_INITA                     = 3
)
View Source
const (
	BLE_ADV_EVENT_IND           BleAdvEventType = 0
	BLE_ADV_EVENT_DIRECT_IND_HD                 = 1
	BLE_ADV_EVENT_SCAN_IND                      = 2
	BLE_ADV_EVENT_NONCONN_IND                   = 3
	BLE_ADV_EVENT_DIRECT_IND_LD                 = 4
)
View Source
const (
	BLE_GATT_ACCESS_OP_READ_CHR  BleGattOp = 0
	BLE_GATT_ACCESS_OP_WRITE_CHR           = 1
	BLE_GATT_ACCESS_OP_READ_DSC            = 2
	BLE_GATT_ACCESS_OP_WRITE_DSC           = 3
)
View Source
const (
	BLE_GATT_F_BROADCAST       BleChrFlags = 0x0001
	BLE_GATT_F_READ                        = 0x0002
	BLE_GATT_F_WRITE_NO_RSP                = 0x0004
	BLE_GATT_F_WRITE                       = 0x0008
	BLE_GATT_F_NOTIFY                      = 0x0010
	BLE_GATT_F_INDICATE                    = 0x0020
	BLE_GATT_F_AUTH_SIGN_WRITE             = 0x0040
	BLE_GATT_F_RELIABLE_WRITE              = 0x0080
	BLE_GATT_F_AUX_WRITE                   = 0x0100
	BLE_GATT_F_READ_ENC                    = 0x0200
	BLE_GATT_F_READ_AUTHEN                 = 0x0400
	BLE_GATT_F_READ_AUTHOR                 = 0x0800
	BLE_GATT_F_WRITE_ENC                   = 0x1000
	BLE_GATT_F_WRITE_AUTHEN                = 0x2000
	BLE_GATT_F_WRITE_AUTHOR                = 0x4000
)
View Source
const (
	BLE_ATT_F_READ         BleAttFlags = 0x01
	BLE_ATT_F_WRITE                    = 0x02
	BLE_ATT_F_READ_ENC                 = 0x04
	BLE_ATT_F_READ_AUTHEN              = 0x08
	BLE_ATT_F_READ_AUTHOR              = 0x10
	BLE_ATT_F_WRITE_ENC                = 0x20
	BLE_ATT_F_WRITE_AUTHEN             = 0x40
	BLE_ATT_F_WRITE_AUTHOR             = 0x80
)
View Source
const (
	BLE_DISC_CHR_PROP_BROADCAST       BleDiscChrProperties = 0x01
	BLE_DISC_CHR_PROP_READ                                 = 0x02
	BLE_DISC_CHR_PROP_WRITE_NO_RSP                         = 0x04
	BLE_DISC_CHR_PROP_WRITE                                = 0x08
	BLE_DISC_CHR_PROP_NOTIFY                               = 0x10
	BLE_DISC_CHR_PROP_INDICATE                             = 0x20
	BLE_DISC_CHR_PROP_AUTH_SIGN_WRITE                      = 0x40
	BLE_DISC_CHR_PROP_EXTENDED                             = 0x80
)
View Source
const BLE_ATT_ATTR_MAX_LEN = 512
View Source
const BLE_ATT_MTU_DFLT = 23
View Source
const CccdUuid = 0x2902
View Source
const IotivityReqChrUuid = "ad7b334f-4637-4b86-90b6-9d787f03d218"
View Source
const IotivityRspChrUuid = "e9241982-4580-42c4-8831-95048216b256"
View Source
const IotivitySvcUuid = "ade3d529-c784-4f63-a987-eb69f70ee816"
View Source
const NmpPlainChrUuid = "da2e7828-fbce-4e01-ae9e-261174997c48"
View Source
const NmpPlainSvcUuid = "8d53dc1d-1db7-4cd3-868b-8a527460aa84"
View Source
const OmpSecReqChrUuid = SecureReqChrUuid
View Source
const OmpSecRspChrUuid = SecureRspChrUuid
View Source
const OmpSecSvcUuid = SecureSvcUuid
View Source
const OmpUnsecReqChrUuid = "ad7b334f-4637-4b86-90b6-9d787f03d218"
View Source
const OmpUnsecRspChrUuid = "e9241982-4580-42c4-8831-95048216b256"
View Source
const OmpUnsecSvcUuid = "ade3d529-c784-4f63-a987-eb69f70ee816"
View Source
const SecureReqChrUuid = 0x1000
View Source
const SecureRspChrUuid = 0x1001
View Source
const SecureSvcUuid = 0xfe18
View Source
const UnauthReqChrUuid = "69b8a928-2ab2-487b-923e-54ce53a18bc1"
View Source
const UnauthRspChrUuid = "bca10aea-5df1-4248-b72b-f52955ad9c88"
View Source
const UnauthSvcUuid = "0c08c213-98ed-4e43-a499-7e1137c39567"

Variables

View Source
var BleAddrTypeStringMap = map[BleAddrType]string{
	BLE_ADDR_TYPE_PUBLIC:  "public",
	BLE_ADDR_TYPE_RANDOM:  "random",
	BLE_ADDR_TYPE_RPA_PUB: "rpa_pub",
	BLE_ADDR_TYPE_RPA_RND: "rpa_rnd",
}
View Source
var BleAdvConnModeStringMap = map[BleAdvConnMode]string{
	BLE_ADV_CONN_MODE_NON: "non",
	BLE_ADV_CONN_MODE_DIR: "dir",
	BLE_ADV_CONN_MODE_UND: "und",
}
View Source
var BleAdvDiscModeStringMap = map[BleAdvDiscMode]string{
	BLE_ADV_DISC_MODE_NON: "non",
	BLE_ADV_DISC_MODE_LTD: "ltd",
	BLE_ADV_DISC_MODE_GEN: "gen",
}
View Source
var BleAdvEventTypeStringMap = map[BleAdvEventType]string{
	BLE_ADV_EVENT_IND:           "ind",
	BLE_ADV_EVENT_DIRECT_IND_HD: "direct_ind_hd",
	BLE_ADV_EVENT_SCAN_IND:      "scan_ind",
	BLE_ADV_EVENT_NONCONN_IND:   "nonconn_ind",
	BLE_ADV_EVENT_DIRECT_IND_LD: "direct_ind_ld",
}
View Source
var BleGattOpStringMap = map[BleGattOp]string{
	BLE_GATT_ACCESS_OP_READ_CHR:  "read_chr",
	BLE_GATT_ACCESS_OP_WRITE_CHR: "write_chr",
	BLE_GATT_ACCESS_OP_READ_DSC:  "read_dsc",
	BLE_GATT_ACCESS_OP_WRITE_DSC: "write_dsc",
}
View Source
var BleScanFilterPolicyStringMap = map[BleScanFilterPolicy]string{
	BLE_SCAN_FILT_NO_WL:        "no_wl",
	BLE_SCAN_FILT_USE_WL:       "use_wl",
	BLE_SCAN_FILT_NO_WL_INITA:  "no_wl_inita",
	BLE_SCAN_FILT_USE_WL_INITA: "use_wl_inita",
}
View Source
var BleSmActionStringMap = map[BleSmAction]string{
	BLE_SM_ACTION_OOB:    "oob",
	BLE_SM_ACTION_INPUT:  "input",
	BLE_SM_ACTION_DISP:   "disp",
	BLE_SM_ACTION_NUMCMP: "numcmp",
}
View Source
var BleSmAuthReqStringMap = map[BleSmAuthReq]string{
	BLE_SM_AUTHREQ_BOND:     "bond",
	BLE_SM_AUTHREQ_MITM:     "mitm",
	BLE_SM_AUTHREQ_SC:       "sc",
	BLE_SM_AUTHREQ_KEYPRESS: "keypress",
}
View Source
var BleSmIoCapStringMap = map[BleSmIoCap]string{
	BLE_SM_IO_CAP_DISP_ONLY:     "disp_only",
	BLE_SM_IO_CAP_DISP_YES_NO:   "disp_yes_no",
	BLE_SM_IO_CAP_KEYBOARD_ONLY: "keyboard_only",
	BLE_SM_IO_CAP_NO_IO:         "no_io",
	BLE_SM_IO_CAP_KEYBOARD_DISP: "keyboard_disp",
}
View Source
var BleSmKeyDistStringMap = map[BleSmKeyDist]string{
	BLE_SM_KEY_DIST_ENC:  "enc",
	BLE_SM_KEY_DIST_ID:   "id",
	BLE_SM_KEY_DIST_SIGN: "sign",
	BLE_SM_KEY_DIST_LINK: "link",
}
View Source
var BleSvcTypeStringMap = map[BleSvcType]string{
	BLE_SVC_TYPE_PRIMARY:   "primary",
	BLE_SVC_TYPE_SECONDARY: "secondary",
}

Functions

func BleAddrTypeToString

func BleAddrTypeToString(addrType BleAddrType) string

func BleAdvConnModeToString

func BleAdvConnModeToString(connMode BleAdvConnMode) string

func BleAdvDiscModeToString

func BleAdvDiscModeToString(discMode BleAdvDiscMode) string

func BleAdvEventTypeToString

func BleAdvEventTypeToString(advEventType BleAdvEventType) string

func BleAdvFilterPolicyToString

func BleAdvFilterPolicyToString(discMode BleAdvFilterPolicy) string

func BleGattOpToString

func BleGattOpToString(op BleGattOp) string

func BleScanFilterPolicyToString

func BleScanFilterPolicyToString(filtPolicy BleScanFilterPolicy) string

func BleSmActionToString

func BleSmActionToString(smAction BleSmAction) string

func BleSmAuthReqToString

func BleSmAuthReqToString(smAction BleSmAuthReq) string

func BleSmIoCapToString

func BleSmIoCapToString(smAction BleSmIoCap) string

func BleSmKeyDistToString

func BleSmKeyDistToString(smAction BleSmKeyDist) string

func BleSvcTypeToString

func BleSvcTypeToString(svcType BleSvcType) string

func CompareChrIds

func CompareChrIds(a BleChrId, b BleChrId) int

func CompareUuids

func CompareUuids(a BleUuid, b BleUuid) int

Types

type BleAddr

type BleAddr struct {
	Bytes [6]byte
}

func ParseBleAddr

func ParseBleAddr(s string) (BleAddr, error)

func (*BleAddr) MarshalJSON

func (ba *BleAddr) MarshalJSON() ([]byte, error)

func (*BleAddr) String

func (ba *BleAddr) String() string

func (*BleAddr) UnmarshalJSON

func (ba *BleAddr) UnmarshalJSON(data []byte) error

type BleAddrType

type BleAddrType int

func BleAddrTypeFromString

func BleAddrTypeFromString(s string) (BleAddrType, error)

func (BleAddrType) MarshalJSON

func (a BleAddrType) MarshalJSON() ([]byte, error)

func (*BleAddrType) UnmarshalJSON

func (a *BleAddrType) UnmarshalJSON(data []byte) error

type BleAdvConnMode

type BleAdvConnMode int
const (
	BLE_ADV_CONN_MODE_NON BleAdvConnMode = iota
	BLE_ADV_CONN_MODE_DIR
	BLE_ADV_CONN_MODE_UND
)

func BleAdvConnModeFromString

func BleAdvConnModeFromString(s string) (BleAdvConnMode, error)

func (BleAdvConnMode) MarshalJSON

func (a BleAdvConnMode) MarshalJSON() ([]byte, error)

func (*BleAdvConnMode) UnmarshalJSON

func (a *BleAdvConnMode) UnmarshalJSON(data []byte) error

type BleAdvDiscMode

type BleAdvDiscMode int
const (
	BLE_ADV_DISC_MODE_NON BleAdvDiscMode = iota
	BLE_ADV_DISC_MODE_LTD
	BLE_ADV_DISC_MODE_GEN
)

func BleAdvDiscModeFromString

func BleAdvDiscModeFromString(s string) (BleAdvDiscMode, error)

func (BleAdvDiscMode) MarshalJSON

func (a BleAdvDiscMode) MarshalJSON() ([]byte, error)

func (*BleAdvDiscMode) UnmarshalJSON

func (a *BleAdvDiscMode) UnmarshalJSON(data []byte) error

type BleAdvEventType

type BleAdvEventType int

func BleAdvEventTypeFromString

func BleAdvEventTypeFromString(s string) (BleAdvEventType, error)

func (BleAdvEventType) MarshalJSON

func (a BleAdvEventType) MarshalJSON() ([]byte, error)

func (*BleAdvEventType) UnmarshalJSON

func (a *BleAdvEventType) UnmarshalJSON(data []byte) error

type BleAdvFields

type BleAdvFields struct {
	Data []byte

	// Each field is only present if the sender included it in its
	// advertisement.
	Flags              *uint8
	Uuids16            []BleUuid16
	Uuids16IsComplete  bool
	Uuids32            []uint32
	Uuids32IsComplete  bool
	Uuids128           []BleUuid128
	Uuids128IsComplete bool
	Name               *string
	NameIsComplete     bool
	TxPwrLvl           *int8
	SlaveItvlMin       *uint16
	SlaveItvlMax       *uint16
	SvcDataUuid16      []byte
	PublicTgtAddrs     []BleAddr
	Appearance         *uint16
	AdvItvl            *uint16
	SvcDataUuid32      []byte
	SvcDataUuid128     []byte
	Uri                *string
	MfgData            []byte
}

type BleAdvFilterPolicy

type BleAdvFilterPolicy int
const (
	BLE_ADV_FILTER_POLICY_NONE BleAdvFilterPolicy = iota
	BLE_ADV_FILTER_POLICY_SCAN
	BLE_ADV_FILTER_POLICY_CONN
	BLE_ADV_FILTER_POLICY_BOTH
)

func BleAdvFilterPolicyFromString

func BleAdvFilterPolicyFromString(s string) (BleAdvFilterPolicy, error)

func (BleAdvFilterPolicy) MarshalJSON

func (a BleAdvFilterPolicy) MarshalJSON() ([]byte, error)

func (*BleAdvFilterPolicy) UnmarshalJSON

func (a *BleAdvFilterPolicy) UnmarshalJSON(data []byte) error

type BleAdvPredicate

type BleAdvPredicate func(adv BleAdvReport) bool

type BleAdvReport

type BleAdvReport struct {
	// These fields are always present.
	EventType BleAdvEventType
	Sender    BleDev
	Rssi      int8

	Fields BleAdvFields
}

type BleAdvRptFn

type BleAdvRptFn func(r BleAdvReport)

type BleAttFlags

type BleAttFlags int

type BleChr

type BleChr struct {
	Uuid       BleUuid
	Flags      BleChrFlags
	MinKeySize int
	AccessCb   BleGattAccessFn
	Dscs       []BleDsc
}

type BleChrFlags

type BleChrFlags int

type BleChrId

type BleChrId struct {
	SvcUuid BleUuid
	ChrUuid BleUuid
}

func (*BleChrId) String

func (b *BleChrId) String() string

type BleConnDesc

type BleConnDesc struct {
	ConnHandle      uint16
	OwnIdAddrType   BleAddrType
	OwnIdAddr       BleAddr
	OwnOtaAddrType  BleAddrType
	OwnOtaAddr      BleAddr
	PeerIdAddrType  BleAddrType
	PeerIdAddr      BleAddr
	PeerOtaAddrType BleAddrType
	PeerOtaAddr     BleAddr
	Role            BleRole
	Encrypted       bool
	Authenticated   bool
	Bonded          bool
	KeySize         int
}

func (*BleConnDesc) String

func (d *BleConnDesc) String() string

type BleDev

type BleDev struct {
	AddrType BleAddrType
	Addr     BleAddr
}

func (*BleDev) String

func (bd *BleDev) String() string

type BleDiscChrProperties

type BleDiscChrProperties int

type BleDsc

type BleDsc struct {
	Uuid       BleUuid
	AttFlags   BleAttFlags
	MinKeySize int
}

type BleEncryptWhen

type BleEncryptWhen int
const (
	BLE_ENCRYPT_NEVER BleEncryptWhen = iota
	BLE_ENCRYPT_AS_REQD
	BLE_ENCRYPT_ALWAYS
)

type BleGattAccess

type BleGattAccess struct {
	Op         BleGattOp
	ConnHandle uint16
	SvcUuid    BleUuid
	ChrUuid    BleUuid
	Data       []byte
}

type BleGattAccessFn

type BleGattAccessFn func(access BleGattAccess) (uint8, []byte)

type BleGattOp

type BleGattOp int

func BleGattOpFromString

func BleGattOpFromString(s string) (BleGattOp, error)

type BleMgmtChrs

type BleMgmtChrs struct {
	NmpReqChr *BleChrId
	NmpRspChr *BleChrId
	ResReqChr *BleChrId
	ResRspChr *BleChrId
}

type BlePairCfg

type BlePairCfg struct {
	IoCap        BleSmIoCap
	Oob          bool
	Bonding      bool
	Mitm         bool
	Sc           bool
	Keypress     bool
	OurKeyDist   BleSmKeyDist
	TheirKeyDist BleSmKeyDist
}

type BleRole

type BleRole int
const (
	BLE_ROLE_MASTER BleRole = iota
	BLE_ROLE_SLAVE
)

type BleScanFilterPolicy

type BleScanFilterPolicy int

func BleScanFilterPolicyFromString

func BleScanFilterPolicyFromString(s string) (BleScanFilterPolicy, error)

func (BleScanFilterPolicy) MarshalJSON

func (a BleScanFilterPolicy) MarshalJSON() ([]byte, error)

func (*BleScanFilterPolicy) UnmarshalJSON

func (a *BleScanFilterPolicy) UnmarshalJSON(data []byte) error

type BleSmAction

type BleSmAction int
const (
	BLE_SM_ACTION_OOB BleSmAction = iota
	BLE_SM_ACTION_INPUT
	BLE_SM_ACTION_DISP
	BLE_SM_ACTION_NUMCMP
)

func BleSmActionFromString

func BleSmActionFromString(s string) (BleSmAction, error)

func (BleSmAction) MarshalJSON

func (a BleSmAction) MarshalJSON() ([]byte, error)

func (BleSmAction) String

func (io BleSmAction) String() string

func (*BleSmAction) UnmarshalJSON

func (a *BleSmAction) UnmarshalJSON(data []byte) error

type BleSmAuthReq

type BleSmAuthReq int
const (
	BLE_SM_AUTHREQ_BOND BleSmAuthReq = iota
	BLE_SM_AUTHREQ_MITM
	BLE_SM_AUTHREQ_SC
	BLE_SM_AUTHREQ_KEYPRESS
)

func BleSmAuthReqFromString

func BleSmAuthReqFromString(s string) (BleSmAuthReq, error)

func (BleSmAuthReq) MarshalJSON

func (a BleSmAuthReq) MarshalJSON() ([]byte, error)

func (BleSmAuthReq) String

func (io BleSmAuthReq) String() string

func (*BleSmAuthReq) UnmarshalJSON

func (a *BleSmAuthReq) UnmarshalJSON(data []byte) error

type BleSmIoCap

type BleSmIoCap int
const (
	BLE_SM_IO_CAP_DISP_ONLY BleSmIoCap = iota
	BLE_SM_IO_CAP_DISP_YES_NO
	BLE_SM_IO_CAP_KEYBOARD_ONLY
	BLE_SM_IO_CAP_NO_IO
	BLE_SM_IO_CAP_KEYBOARD_DISP
)

func BleSmIoCapFromString

func BleSmIoCapFromString(s string) (BleSmIoCap, error)

func (BleSmIoCap) MarshalJSON

func (a BleSmIoCap) MarshalJSON() ([]byte, error)

func (BleSmIoCap) String

func (io BleSmIoCap) String() string

func (*BleSmIoCap) UnmarshalJSON

func (a *BleSmIoCap) UnmarshalJSON(data []byte) error

type BleSmKeyDist

type BleSmKeyDist int
const (
	BLE_SM_KEY_DIST_ENC BleSmKeyDist = iota
	BLE_SM_KEY_DIST_ID
	BLE_SM_KEY_DIST_SIGN
	BLE_SM_KEY_DIST_LINK
)

func BleSmKeyDistFromString

func BleSmKeyDistFromString(s string) (BleSmKeyDist, error)

func (BleSmKeyDist) MarshalJSON

func (a BleSmKeyDist) MarshalJSON() ([]byte, error)

func (BleSmKeyDist) String

func (io BleSmKeyDist) String() string

func (*BleSmKeyDist) UnmarshalJSON

func (a *BleSmKeyDist) UnmarshalJSON(data []byte) error

type BleSvc

type BleSvc struct {
	Uuid    BleUuid
	SvcType BleSvcType
	Chrs    []BleChr
}

type BleSvcType

type BleSvcType int
const (
	BLE_SVC_TYPE_PRIMARY BleSvcType = iota
	BLE_SVC_TYPE_SECONDARY
)

func BleSvcTypeFromString

func BleSvcTypeFromString(s string) (BleSvcType, error)

func (BleSvcType) MarshalJSON

func (a BleSvcType) MarshalJSON() ([]byte, error)

func (*BleSvcType) UnmarshalJSON

func (a *BleSvcType) UnmarshalJSON(data []byte) error

type BleUuid

type BleUuid struct {
	// Set to 0 if the 128-bit UUID should be used.
	U16 BleUuid16

	U128 BleUuid128
}

func NewBleUuid16

func NewBleUuid16(uuid16 uint16) BleUuid

func ParseUuid

func ParseUuid(uuidStr string) (BleUuid, error)

func (*BleUuid) MarshalJSON

func (bu *BleUuid) MarshalJSON() ([]byte, error)

func (*BleUuid) String

func (bu *BleUuid) String() string

func (*BleUuid) UnmarshalJSON

func (bu *BleUuid) UnmarshalJSON(data []byte) error

type BleUuid128

type BleUuid128 [16]byte

func ParseUuid128

func ParseUuid128(s string) (BleUuid128, error)

func (*BleUuid128) MarshalJSON

func (bu128 *BleUuid128) MarshalJSON() ([]byte, error)

func (*BleUuid128) String

func (bu128 *BleUuid128) String() string

func (*BleUuid128) UnmarshalJSON

func (bu128 *BleUuid128) UnmarshalJSON(data []byte) error

type BleUuid16

type BleUuid16 uint16

func ParseUuid16

func ParseUuid16(s string) (BleUuid16, error)

func (*BleUuid16) String

func (bu16 *BleUuid16) String() string

Jump to

Keyboard shortcuts

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