nmble

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: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERR_CODE_EAGAIN          int = 1
	ERR_CODE_EALREADY            = 2
	ERR_CODE_EINVAL              = 3
	ERR_CODE_EMSGSIZE            = 4
	ERR_CODE_ENOENT              = 5
	ERR_CODE_ENOMEM              = 6
	ERR_CODE_ENOTCONN            = 7
	ERR_CODE_ENOTSUP             = 8
	ERR_CODE_EAPP                = 9
	ERR_CODE_EBADDATA            = 10
	ERR_CODE_EOS                 = 11
	ERR_CODE_ECONTROLLER         = 12
	ERR_CODE_ETIMEOUT            = 13
	ERR_CODE_EDONE               = 14
	ERR_CODE_EBUSY               = 15
	ERR_CODE_EREJECT             = 16
	ERR_CODE_EUNKNOWN            = 17
	ERR_CODE_EROLE               = 18
	ERR_CODE_ETIMEOUT_HCI        = 19
	ERR_CODE_ENOMEM_EVT          = 20
	ERR_CODE_ENOADDR             = 21
	ERR_CODE_ENOTSYNCED          = 22
	ERR_CODE_EAUTHEN             = 23
	ERR_CODE_EAUTHOR             = 24
	ERR_CODE_EENCRYPT            = 25
	ERR_CODE_EENCRYPT_KEY_SZ     = 26
	ERR_CODE_ESTORE_CAP          = 27
	ERR_CODE_ESTORE_FAIL         = 28
	ERR_CODE_EPREEMPTED          = 29
)
View Source
const (
	ERR_CODE_HCI_UNKNOWN_HCI_CMD     int = 1
	ERR_CODE_HCI_UNK_CONN_ID             = 2
	ERR_CODE_HCI_HW_FAIL                 = 3
	ERR_CODE_HCI_PAGE_TMO                = 4
	ERR_CODE_HCI_AUTH_FAIL               = 5
	ERR_CODE_HCI_PINKEY_MISSING          = 6
	ERR_CODE_HCI_MEM_CAPACITY            = 7
	ERR_CODE_HCI_CONN_SPVN_TMO           = 8
	ERR_CODE_HCI_CONN_LIMIT              = 9
	ERR_CODE_HCI_SYNCH_CONN_LIMIT        = 10
	ERR_CODE_HCI_ACL_CONN_EXISTS         = 11
	ERR_CODE_HCI_CMD_DISALLOWED          = 12
	ERR_CODE_HCI_CONN_REJ_RESOURCES      = 13
	ERR_CODE_HCI_CONN_REJ_ENC            = 14
	ERR_CODE_HCI_CONN_REJ_BD_ADDR        = 15
	ERR_CODE_HCI_CONN_ACCEPT_TMO         = 16
	ERR_CODE_HCI_UNSUPPORTED             = 17
	ERR_CODE_HCI_INV_HCI_CMD_PARMS       = 18
	ERR_CODE_HCI_REM_USER_CONN_TERM      = 19
	ERR_CODE_HCI_RD_CONN_TERM_RESRCS     = 20
	ERR_CODE_HCI_RD_CONN_TERM_PWROFF     = 21
	ERR_CODE_HCI_CONN_TERM_LOCAL         = 22
	ERR_CODE_HCI_REPEATED_ATTEMPTS       = 23
	ERR_CODE_HCI_NO_PAIRING              = 24
	ERR_CODE_HCI_UNK_LMP                 = 25
	ERR_CODE_HCI_UNSUPP_REM_FEATURE      = 26
	ERR_CODE_HCI_SCO_OFFSET              = 27
	ERR_CODE_HCI_SCO_ITVL                = 28
	ERR_CODE_HCI_SCO_AIR_MODE            = 29
	ERR_CODE_HCI_INV_LMP_LL_PARM         = 30
	ERR_CODE_HCI_UNSPECIFIED             = 31
	ERR_CODE_HCI_UNSUPP_LMP_LL_PARM      = 32
	ERR_CODE_HCI_NO_ROLE_CHANGE          = 33
	ERR_CODE_HCI_LMP_LL_RSP_TMO          = 34
	ERR_CODE_HCI_LMP_COLLISION           = 35
	ERR_CODE_HCI_LMP_PDU                 = 36
	ERR_CODE_HCI_ENCRYPTION_MODE         = 37
	ERR_CODE_HCI_LINK_KEY_CHANGE         = 38
	ERR_CODE_HCI_UNSUPP_QOS              = 39
	ERR_CODE_HCI_INSTANT_PASSED          = 40
	ERR_CODE_HCI_UNIT_KEY_PAIRING        = 41
	ERR_CODE_HCI_DIFF_TRANS_COLL         = 42
	ERR_CODE_HCI_QOS_PARM                = 44
	ERR_CODE_HCI_QOS_REJECTED            = 45
	ERR_CODE_HCI_CHAN_CLASS              = 46
	ERR_CODE_HCI_INSUFFICIENT_SEC        = 47
	ERR_CODE_HCI_PARM_OUT_OF_RANGE       = 48
	ERR_CODE_HCI_PENDING_ROLE_SW         = 50
	ERR_CODE_HCI_RESERVED_SLOT           = 52
	ERR_CODE_HCI_ROLE_SW_FAIL            = 53
	ERR_CODE_HCI_INQ_RSP_TOO_BIG         = 54
	ERR_CODE_HCI_SEC_SIMPLE_PAIR         = 55
	ERR_CODE_HCI_HOST_BUSY_PAIR          = 56
	ERR_CODE_HCI_CONN_REJ_CHANNEL        = 57
	ERR_CODE_HCI_CTLR_BUSY               = 58
	ERR_CODE_HCI_CONN_PARMS              = 59
	ERR_CODE_HCI_DIR_ADV_TMO             = 60
	ERR_CODE_HCI_CONN_TERM_MIC           = 61
	ERR_CODE_HCI_CONN_ESTABLISHMENT      = 62
	ERR_CODE_HCI_MAC_CONN_FAIL           = 63
	ERR_CODE_HCI_COARSE_CLK_ADJ          = 64
)
View Source
const (
	ERR_CODE_ATT_INVALID_HANDLE         int = 0x01
	ERR_CODE_ATT_READ_NOT_PERMITTED         = 0x02
	ERR_CODE_ATT_WRITE_NOT_PERMITTED        = 0x03
	ERR_CODE_ATT_INVALID_PDU                = 0x04
	ERR_CODE_ATT_INSUFFICIENT_AUTHEN        = 0x05
	ERR_CODE_ATT_REQ_NOT_SUPPORTED          = 0x06
	ERR_CODE_ATT_INVALID_OFFSET             = 0x07
	ERR_CODE_ATT_INSUFFICIENT_AUTHOR        = 0x08
	ERR_CODE_ATT_PREPARE_QUEUE_FULL         = 0x09
	ERR_CODE_ATT_ATTR_NOT_FOUND             = 0x0a
	ERR_CODE_ATT_ATTR_NOT_LONG              = 0x0b
	ERR_CODE_ATT_INSUFFICIENT_KEY_SZ        = 0x0c
	ERR_CODE_ATT_INVALID_ATTR_VALUE_LEN     = 0x0d
	ERR_CODE_ATT_UNLIKELY                   = 0x0e
	ERR_CODE_ATT_INSUFFICIENT_ENC           = 0x0f
	ERR_CODE_ATT_UNSUPPORTED_GROUP          = 0x10
	ERR_CODE_ATT_INSUFFICIENT_RES           = 0x11
)
View Source
const (
	ERR_CODE_SM_ERR_PASSKEY          int = 0x01
	ERR_CODE_SM_ERR_OOB                  = 0x02
	ERR_CODE_SM_ERR_AUTHREQ              = 0x03
	ERR_CODE_SM_ERR_CONFIRM_MISMATCH     = 0x04
	ERR_CODE_SM_ERR_PAIR_NOT_SUPP        = 0x05
	ERR_CODE_SM_ERR_ENC_KEY_SZ           = 0x06
	ERR_CODE_SM_ERR_CMD_NOT_SUPP         = 0x07
	ERR_CODE_SM_ERR_UNSPECIFIED          = 0x08
	ERR_CODE_SM_ERR_REPEATED             = 0x09
	ERR_CODE_SM_ERR_INVAL                = 0x0a
	ERR_CODE_SM_ERR_DHKEY                = 0x0b
	ERR_CODE_SM_ERR_NUMCMP               = 0x0c
	ERR_CODE_SM_ERR_ALREADY              = 0x0d
	ERR_CODE_SM_ERR_CROSS_TRANS          = 0x0e
)
View Source
const (
	MSG_OP_REQ MsgOp = 0
	MSG_OP_RSP       = 1
	MSG_OP_EVT       = 2
)

These values never get transmitted or received, so their precise values don't matter. We specify them explicitly here to match the blehostd source.

View Source
const (
	MSG_TYPE_ERR               MsgType = 1
	MSG_TYPE_SYNC                      = 2
	MSG_TYPE_CONNECT                   = 3
	MSG_TYPE_TERMINATE                 = 4
	MSG_TYPE_DISC_ALL_SVCS             = 5
	MSG_TYPE_DISC_SVC_UUID             = 6
	MSG_TYPE_DISC_ALL_CHRS             = 7
	MSG_TYPE_DISC_CHR_UUID             = 8
	MSG_TYPE_DISC_ALL_DSCS             = 9
	MSG_TYPE_WRITE                     = 10
	MSG_TYPE_WRITE_CMD                 = 11
	MSG_TYPE_EXCHANGE_MTU              = 12
	MSG_TYPE_GEN_RAND_ADDR             = 13
	MSG_TYPE_SET_RAND_ADDR             = 14
	MSG_TYPE_CONN_CANCEL               = 15
	MSG_TYPE_SCAN                      = 16
	MSG_TYPE_SCAN_CANCEL               = 17
	MSG_TYPE_SET_PREFERRED_MTU         = 18
	MSG_TYPE_SECURITY_INITIATE         = 19
	MSG_TYPE_CONN_FIND                 = 20
	MSG_TYPE_RESET                     = 21
	MSG_TYPE_ADV_START                 = 22
	MSG_TYPE_ADV_STOP                  = 23
	MSG_TYPE_ADV_SET_DATA              = 24
	MSG_TYPE_ADV_RSP_SET_DATA          = 25
	MSG_TYPE_ADV_FIELDS                = 26
	MSG_TYPE_CLEAR_SVCS                = 27
	MSG_TYPE_ADD_SVCS                  = 28
	MSG_TYPE_COMMIT_SVCS               = 29
	MSG_TYPE_ACCESS_STATUS             = 30
	MSG_TYPE_NOTIFY                    = 31
	MSG_TYPE_FIND_CHR                  = 32
	MSG_TYPE_SM_INJECT_IO              = 33

	MSG_TYPE_SYNC_EVT          = 2049
	MSG_TYPE_CONNECT_EVT       = 2050
	MSG_TYPE_CONN_CANCEL_EVT   = 2051
	MSG_TYPE_DISCONNECT_EVT    = 2052
	MSG_TYPE_DISC_SVC_EVT      = 2053
	MSG_TYPE_DISC_CHR_EVT      = 2054
	MSG_TYPE_DISC_DSC_EVT      = 2055
	MSG_TYPE_WRITE_ACK_EVT     = 2056
	MSG_TYPE_NOTIFY_RX_EVT     = 2057
	MSG_TYPE_MTU_CHANGE_EVT    = 2058
	MSG_TYPE_SCAN_EVT          = 2059
	MSG_TYPE_SCAN_COMPLETE_EVT = 2060
	MSG_TYPE_ADV_COMPLETE_EVT  = 2061
	MSG_TYPE_ENC_CHANGE_EVT    = 2062
	MSG_TYPE_RESET_EVT         = 2063
	MSG_TYPE_ACCESS_EVT        = 2064
	MSG_TYPE_PASSKEY_EVT       = 2065
)

These values never get transmitted or received, so their precise values don't matter. We specify them explicitly here to match the blehostd source.

View Source
const (
	DISCOVERER_STATE_IDLE discovererState = iota
	DISCOVERER_STATE_STARTED
	DISCOVERER_STATE_STOPPING
	DISCOVERER_STATE_STOPPED
)
View Source
const (
	MASTER_STATE_IDLE masterState = iota
	MASTER_STATE_SECONDARY
	MASTER_STATE_PRIMARY
	MASTER_STATE_PRIMARY_SECONDARY_PENDING
)
View Source
const BLE_CONN_HANDLE_NONE uint16 = 0xffff
View Source
const ERR_CODE_ATT_BASE = 0x100
View Source
const ERR_CODE_HCI_BASE = 0x200
View Source
const ERR_CODE_L2C_BASE = 0x300
View Source
const ERR_CODE_SM_PEER_BASE = 0x500
View Source
const ERR_CODE_SM_US_BASE = 0x400
View Source
const NOTIFY_CMD_BASE_SZ = 3
View Source
const WRITE_CMD_BASE_SZ = 3

Variables

View Source
var AttErrCodeStringMap = map[int]string{
	ERR_CODE_ATT_INVALID_HANDLE:         "invalid handle",
	ERR_CODE_ATT_READ_NOT_PERMITTED:     "read not permitted",
	ERR_CODE_ATT_WRITE_NOT_PERMITTED:    "write not permitted",
	ERR_CODE_ATT_INVALID_PDU:            "invalid pdu",
	ERR_CODE_ATT_INSUFFICIENT_AUTHEN:    "insufficient authentication",
	ERR_CODE_ATT_REQ_NOT_SUPPORTED:      "request not supported",
	ERR_CODE_ATT_INVALID_OFFSET:         "invalid offset",
	ERR_CODE_ATT_INSUFFICIENT_AUTHOR:    "insufficient authorization",
	ERR_CODE_ATT_PREPARE_QUEUE_FULL:     "prepare queue full",
	ERR_CODE_ATT_ATTR_NOT_FOUND:         "attribute not found",
	ERR_CODE_ATT_ATTR_NOT_LONG:          "attribute not long",
	ERR_CODE_ATT_INSUFFICIENT_KEY_SZ:    "insufficient key size",
	ERR_CODE_ATT_INVALID_ATTR_VALUE_LEN: "invalid attribute value length",
	ERR_CODE_ATT_UNLIKELY:               "unlikely error",
	ERR_CODE_ATT_INSUFFICIENT_ENC:       "insufficient encryption",
	ERR_CODE_ATT_UNSUPPORTED_GROUP:      "unsupported group",
	ERR_CODE_ATT_INSUFFICIENT_RES:       "insufficient resources",
}
View Source
var ErrCodeStringMap = map[int]string{
	ERR_CODE_EAGAIN:       "eagain",
	ERR_CODE_EALREADY:     "ealready",
	ERR_CODE_EINVAL:       "einval",
	ERR_CODE_EMSGSIZE:     "emsgsize",
	ERR_CODE_ENOENT:       "enoent",
	ERR_CODE_ENOMEM:       "enomem",
	ERR_CODE_ENOTCONN:     "enotconn",
	ERR_CODE_ENOTSUP:      "enotsup",
	ERR_CODE_EAPP:         "eapp",
	ERR_CODE_EBADDATA:     "ebaddata",
	ERR_CODE_EOS:          "eos",
	ERR_CODE_ECONTROLLER:  "econtroller",
	ERR_CODE_ETIMEOUT:     "etimeout",
	ERR_CODE_EDONE:        "edone",
	ERR_CODE_EBUSY:        "ebusy",
	ERR_CODE_EREJECT:      "ereject",
	ERR_CODE_EUNKNOWN:     "eunknown",
	ERR_CODE_EROLE:        "erole",
	ERR_CODE_ETIMEOUT_HCI: "etimeout_hci",
	ERR_CODE_ENOMEM_EVT:   "enomem_evt",
	ERR_CODE_ENOADDR:      "enoaddr",
	ERR_CODE_ENOTSYNCED:   "enotsynced",
}
View Source
var HciErrCodeStringMap = map[int]string{
	ERR_CODE_HCI_UNKNOWN_HCI_CMD:     "unknown hci cmd",
	ERR_CODE_HCI_UNK_CONN_ID:         "unknown connection id",
	ERR_CODE_HCI_HW_FAIL:             "hw fail",
	ERR_CODE_HCI_PAGE_TMO:            "page tmo",
	ERR_CODE_HCI_AUTH_FAIL:           "auth fail",
	ERR_CODE_HCI_PINKEY_MISSING:      "pinkey missing",
	ERR_CODE_HCI_MEM_CAPACITY:        "mem capacity",
	ERR_CODE_HCI_CONN_SPVN_TMO:       "connection supervision timeout",
	ERR_CODE_HCI_CONN_LIMIT:          "conn limit",
	ERR_CODE_HCI_SYNCH_CONN_LIMIT:    "synch conn limit",
	ERR_CODE_HCI_ACL_CONN_EXISTS:     "acl conn exists",
	ERR_CODE_HCI_CMD_DISALLOWED:      "cmd disallowed",
	ERR_CODE_HCI_CONN_REJ_RESOURCES:  "conn rej resources",
	ERR_CODE_HCI_CONN_REJ_ENC:        "conn rej security",
	ERR_CODE_HCI_CONN_REJ_BD_ADDR:    "conn rej bd addr",
	ERR_CODE_HCI_CONN_ACCEPT_TMO:     "conn accept tmo",
	ERR_CODE_HCI_UNSUPPORTED:         "unsupported",
	ERR_CODE_HCI_INV_HCI_CMD_PARMS:   "inv hci cmd parms",
	ERR_CODE_HCI_REM_USER_CONN_TERM:  "rem user conn term",
	ERR_CODE_HCI_RD_CONN_TERM_RESRCS: "rd conn term resrcs",
	ERR_CODE_HCI_RD_CONN_TERM_PWROFF: "rd conn term pwroff",
	ERR_CODE_HCI_CONN_TERM_LOCAL:     "conn term local",
	ERR_CODE_HCI_REPEATED_ATTEMPTS:   "repeated attempts",
	ERR_CODE_HCI_NO_PAIRING:          "no pairing",
	ERR_CODE_HCI_UNK_LMP:             "unk lmp",
	ERR_CODE_HCI_UNSUPP_REM_FEATURE:  "unsupp rem feature",
	ERR_CODE_HCI_SCO_OFFSET:          "sco offset",
	ERR_CODE_HCI_SCO_ITVL:            "sco itvl",
	ERR_CODE_HCI_SCO_AIR_MODE:        "sco air mode",
	ERR_CODE_HCI_INV_LMP_LL_PARM:     "inv lmp ll parm",
	ERR_CODE_HCI_UNSPECIFIED:         "unspecified",
	ERR_CODE_HCI_UNSUPP_LMP_LL_PARM:  "unsupp lmp ll parm",
	ERR_CODE_HCI_NO_ROLE_CHANGE:      "no role change",
	ERR_CODE_HCI_LMP_LL_RSP_TMO:      "lmp ll rsp tmo",
	ERR_CODE_HCI_LMP_COLLISION:       "lmp collision",
	ERR_CODE_HCI_LMP_PDU:             "lmp pdu",
	ERR_CODE_HCI_ENCRYPTION_MODE:     "encryption mode",
	ERR_CODE_HCI_LINK_KEY_CHANGE:     "link key change",
	ERR_CODE_HCI_UNSUPP_QOS:          "unsupp qos",
	ERR_CODE_HCI_INSTANT_PASSED:      "instant passed",
	ERR_CODE_HCI_UNIT_KEY_PAIRING:    "unit key pairing",
	ERR_CODE_HCI_DIFF_TRANS_COLL:     "diff trans coll",
	ERR_CODE_HCI_QOS_PARM:            "qos parm",
	ERR_CODE_HCI_QOS_REJECTED:        "qos rejected",
	ERR_CODE_HCI_CHAN_CLASS:          "chan class",
	ERR_CODE_HCI_INSUFFICIENT_SEC:    "insufficient sec",
	ERR_CODE_HCI_PARM_OUT_OF_RANGE:   "parm out of range",
	ERR_CODE_HCI_PENDING_ROLE_SW:     "pending role sw",
	ERR_CODE_HCI_RESERVED_SLOT:       "reserved slot",
	ERR_CODE_HCI_ROLE_SW_FAIL:        "role sw fail",
	ERR_CODE_HCI_INQ_RSP_TOO_BIG:     "inq rsp too big",
	ERR_CODE_HCI_SEC_SIMPLE_PAIR:     "sec simple pair",
	ERR_CODE_HCI_HOST_BUSY_PAIR:      "host busy pair",
	ERR_CODE_HCI_CONN_REJ_CHANNEL:    "conn rej channel",
	ERR_CODE_HCI_CTLR_BUSY:           "ctlr busy",
	ERR_CODE_HCI_CONN_PARMS:          "conn parms",
	ERR_CODE_HCI_DIR_ADV_TMO:         "dir adv tmo",
	ERR_CODE_HCI_CONN_TERM_MIC:       "conn term mic",
	ERR_CODE_HCI_CONN_ESTABLISHMENT:  "conn establishment",
	ERR_CODE_HCI_MAC_CONN_FAIL:       "mac conn fail",
	ERR_CODE_HCI_COARSE_CLK_ADJ:      "coarse clk adj",
}
View Source
var MsgOpStringMap = map[MsgOp]string{
	MSG_OP_REQ: "request",
	MSG_OP_RSP: "response",
	MSG_OP_EVT: "event",
}
View Source
var MsgTypeStringMap = map[MsgType]string{
	MSG_TYPE_ERR:               "error",
	MSG_TYPE_SYNC:              "sync",
	MSG_TYPE_CONNECT:           "connect",
	MSG_TYPE_TERMINATE:         "terminate",
	MSG_TYPE_DISC_ALL_SVCS:     "disc_all_svcs",
	MSG_TYPE_DISC_SVC_UUID:     "disc_svc_uuid",
	MSG_TYPE_DISC_ALL_CHRS:     "disc_all_chrs",
	MSG_TYPE_DISC_CHR_UUID:     "disc_chr_uuid",
	MSG_TYPE_DISC_ALL_DSCS:     "disc_all_dscs",
	MSG_TYPE_WRITE:             "write",
	MSG_TYPE_WRITE_CMD:         "write_cmd",
	MSG_TYPE_EXCHANGE_MTU:      "exchange_mtu",
	MSG_TYPE_GEN_RAND_ADDR:     "gen_rand_addr",
	MSG_TYPE_SET_RAND_ADDR:     "set_rand_addr",
	MSG_TYPE_CONN_CANCEL:       "conn_cancel",
	MSG_TYPE_SCAN:              "scan",
	MSG_TYPE_SCAN_CANCEL:       "scan_cancel",
	MSG_TYPE_SET_PREFERRED_MTU: "set_preferred_mtu",
	MSG_TYPE_SECURITY_INITIATE: "security_initiate",
	MSG_TYPE_CONN_FIND:         "conn_find",
	MSG_TYPE_RESET:             "reset",
	MSG_TYPE_ADV_START:         "adv_start",
	MSG_TYPE_ADV_STOP:          "adv_stop",
	MSG_TYPE_ADV_SET_DATA:      "adv_set_data",
	MSG_TYPE_ADV_RSP_SET_DATA:  "adv_rsp_set_data",
	MSG_TYPE_ADV_FIELDS:        "adv_fields",
	MSG_TYPE_CLEAR_SVCS:        "clear_svcs",
	MSG_TYPE_ADD_SVCS:          "add_svcs",
	MSG_TYPE_COMMIT_SVCS:       "commit_svcs",
	MSG_TYPE_ACCESS_STATUS:     "access_status",
	MSG_TYPE_NOTIFY:            "notify",
	MSG_TYPE_FIND_CHR:          "find_chr",
	MSG_TYPE_SM_INJECT_IO:      "sm_inject_io",

	MSG_TYPE_SYNC_EVT:          "sync_evt",
	MSG_TYPE_CONNECT_EVT:       "connect_evt",
	MSG_TYPE_CONN_CANCEL_EVT:   "conn_cancel_evt",
	MSG_TYPE_DISCONNECT_EVT:    "disconnect_evt",
	MSG_TYPE_DISC_SVC_EVT:      "disc_svc_evt",
	MSG_TYPE_DISC_CHR_EVT:      "disc_chr_evt",
	MSG_TYPE_DISC_DSC_EVT:      "disc_dsc_evt",
	MSG_TYPE_WRITE_ACK_EVT:     "write_ack_evt",
	MSG_TYPE_NOTIFY_RX_EVT:     "notify_rx_evt",
	MSG_TYPE_MTU_CHANGE_EVT:    "mtu_change_evt",
	MSG_TYPE_SCAN_EVT:          "scan_evt",
	MSG_TYPE_SCAN_COMPLETE_EVT: "scan_tmo_evt",
	MSG_TYPE_ADV_COMPLETE_EVT:  "adv_complete_evt",
	MSG_TYPE_ENC_CHANGE_EVT:    "enc_change_evt",
	MSG_TYPE_RESET_EVT:         "reset_evt",
	MSG_TYPE_ACCESS_EVT:        "access_evt",
	MSG_TYPE_PASSKEY_EVT:       "passkey_evt",
}
View Source
var SmErrCodeStringMap = map[int]string{
	ERR_CODE_SM_ERR_PASSKEY:          "passkey",
	ERR_CODE_SM_ERR_OOB:              "oob",
	ERR_CODE_SM_ERR_AUTHREQ:          "authreq",
	ERR_CODE_SM_ERR_CONFIRM_MISMATCH: "confirm mismatch",
	ERR_CODE_SM_ERR_PAIR_NOT_SUPP:    "pairing not supported",
	ERR_CODE_SM_ERR_ENC_KEY_SZ:       "encryption key size",
	ERR_CODE_SM_ERR_CMD_NOT_SUPP:     "command not supported",
	ERR_CODE_SM_ERR_UNSPECIFIED:      "unspecified",
	ERR_CODE_SM_ERR_REPEATED:         "repeated attempts",
	ERR_CODE_SM_ERR_INVAL:            "invalid parameters",
	ERR_CODE_SM_ERR_DHKEY:            "dhkey check failed",
	ERR_CODE_SM_ERR_NUMCMP:           "numeric comparison failed",
	ERR_CODE_SM_ERR_ALREADY:          "pairing already in progress",
	ERR_CODE_SM_ERR_CROSS_TRANS:      "cross transport not allowed",
}

Functions

func AccessStatusXact

func AccessStatusXact(x *BleXport, attStatus uint8, data []byte) error

func AddSvcsXact

func AddSvcsXact(x *BleXport, svcs []BleAddSvc) error

func BhdTimeoutError

func BhdTimeoutError(rspType MsgType, seq BleSeq) error

func BleAdvReportFromScanEvt

func BleAdvReportFromScanEvt(e *BleScanEvt) BleAdvReport

func BleDescFromConnFindRsp

func BleDescFromConnFindRsp(r *BleConnFindRsp) BleConnDesc

func BuildMgmtChrs

func BuildMgmtChrs(mgmtProto sesn.MgmtProto) (BleMgmtChrs, error)

func ClearSvcsXact

func ClearSvcsXact(x *BleXport) error

func ConnFindXact

func ConnFindXact(x *BleXport, connHandle uint16) (BleConnDesc, error)

func DiscoverDevice

func DiscoverDevice(
	bx *BleXport,
	ownAddrType BleAddrType,
	duration time.Duration,
	advPred BleAdvPredicate) (*BleDev, error)

Discovers a single device. After a device is successfully discovered, discovery is stopped.

func DiscoverDeviceWithName

func DiscoverDeviceWithName(
	bx *BleXport,
	ownAddrType BleAddrType,
	timeout time.Duration,
	name string) (*BleDev, error)

func ErrCodeToAtt

func ErrCodeToAtt(e int) int

func ErrCodeToHci

func ErrCodeToHci(e int) int

func ErrCodeToL2c

func ErrCodeToL2c(e int) int

func ErrCodeToSmPeer

func ErrCodeToSmPeer(e int) int

func ErrCodeToSmUs

func ErrCodeToSmUs(e int) int

func ErrCodeToString

func ErrCodeToString(e int) string

func FindChrXact

func FindChrXact(x *BleXport, svcUuid BleUuid, chrUuid BleUuid) (
	uint16, uint16, error)

func GapService

func GapService(devName string) BleSvc

func GattService

func GattService() BleSvc

func GenRandAddrXact

func GenRandAddrXact(x *BleXport) (BleAddr, error)

func IsSecErr

func IsSecErr(err error) bool

func MsgOpToString

func MsgOpToString(op MsgOp) string

func MsgTypeToString

func MsgTypeToString(msgType MsgType) string

func NotifyXact

func NotifyXact(x *BleXport, connHandle uint16, attrHandle uint16,
	data []byte) error

func ResetXact

func ResetXact(x *BleXport) error

func SetPreferredMtuXact

func SetPreferredMtuXact(x *BleXport, mtu uint16) error

func SetRandAddrXact

func SetRandAddrXact(x *BleXport, addr BleAddr) error

func StatusError

func StatusError(op MsgOp, msgType MsgType, status int) error

func SyncXact

func SyncXact(x *BleXport) (bool, error)

func ToSecurityErr

func ToSecurityErr(err error) error

Attempts to convert the given error to a BLE security error. The conversion succeeds if the error represents a pairing failure due to missing or mismatched key material.

Types

type AdvertiseCfg

type AdvertiseCfg struct {
	// Mandatory
	OwnAddrType   BleAddrType
	ConnMode      BleAdvConnMode
	DiscMode      BleAdvDiscMode
	ItvlMin       uint16
	ItvlMax       uint16
	ChannelMap    uint8
	FilterPolicy  BleAdvFilterPolicy
	HighDutyCycle bool
	AdvFields     BleAdvFields
	RspFields     BleAdvFields
	SesnCfg       sesn.SesnCfg

	// Only required for direct advertisements
	PeerAddr *BleAddr
}

func NewAdvertiseCfg

func NewAdvertiseCfg() AdvertiseCfg

type Advertiser

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

func NewAdvertiser

func NewAdvertiser(bx *BleXport) *Advertiser

func (*Advertiser) Start

func (a *Advertiser) Start(cfg AdvertiseCfg) (sesn.Sesn, error)

func (*Advertiser) Stop

func (a *Advertiser) Stop() error

type BleAccessEvt

type BleAccessEvt struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	GattOp     BleGattOp `json:"gatt_op"`
	ConnHandle uint16    `json:"conn_handle"`
	AttHandle  uint16    `json:"att_handle"`
	Data       BleBytes  `json:"data"`
}

type BleAccessStatusReq

type BleAccessStatusReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	AttStatus uint8    `json:"att_status"`
	Data      BleBytes `json:"data"`
}

func NewAccessStatusReq

func NewAccessStatusReq() *BleAccessStatusReq

type BleAccessStatusRsp

type BleAccessStatusRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleAddChr

type BleAddChr struct {
	Uuid       BleUuid     `json:"uuid"`
	Flags      BleChrFlags `json:"flags"`
	MinKeySize int         `json:"min_key_size"`
	Dscs       []BleAddDsc `json:"descriptors,omitempty"`
}

type BleAddDsc

type BleAddDsc struct {
	Uuid       BleUuid     `json:"uuid"`
	AttFlags   BleAttFlags `json:"att_flags"`
	MinKeySize int         `json:"min_key_size"`
}

type BleAddSvc

type BleAddSvc struct {
	Uuid    BleUuid     `json:"uuid"`
	SvcType BleSvcType  `json:"type"`
	Chrs    []BleAddChr `json:"characteristics,omitempty"`
}

func BleSvcToAddSvc

func BleSvcToAddSvc(svc BleSvc) BleAddSvc

type BleAddSvcsReq

type BleAddSvcsReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	Svcs []BleAddSvc `json:"services"`
}

func NewBleAddSvcsReq

func NewBleAddSvcsReq() *BleAddSvcsReq

type BleAddSvcsRsp

type BleAddSvcsRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleAdvCompleteEvt

type BleAdvCompleteEvt struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Reason int `json:"reason"`
}

type BleAdvFieldsReq

type BleAdvFieldsReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Optional
	Flags *uint8 `json:"flags,omitempty"`

	/*** 0x02,0x03 - 16-bit service class UUIDs. */
	Uuids16           []BleUuid16 `json:"uuids16,omitempty"`
	Uuids16IsComplete bool        `json:"uuids16_is_complete"`

	/*** 0x04,0x05 - 32-bit service class UUIDs. */
	Uuids32           []uint32 `json:"uuids32,omitempty"`
	Uuids32IsComplete bool     `json:"uuids32_is_complete"`

	/*** 0x06,0x07 - 128-bit service class UUIDs. */
	Uuids128           []BleUuid128 `json:"uuids128,omitempty"`
	Uuids128IsComplete bool         `json:"uuids128_is_complete"`

	/*** 0x08,0x09 - Local name. */
	Name           *string `json:"name,omitempty,omitempty"`
	NameIsComplete bool    `json:"name_is_complete"`

	/*** 0x0a - Tx power level. */
	TxPwrLvl *int8 `json:"tx_pwr_lvl,omitempty"`

	/*** 0x0d - Slave connection interval range. */
	SlaveItvlMin *uint16 `json:"slave_itvl_min,omitempty"`
	SlaveItvlMax *uint16 `json:"slave_itvl_max,omitempty"`

	/*** 0x16 - Service data - 16-bit UUID. */
	SvcDataUuid16 BleBytes `json:"svc_data_uuid16,omitempty"`

	/*** 0x17 - Public target address. */
	PublicTgtAddrs []BleAddr `json:"public_tgt_addrs,omitempty"`

	/*** 0x19 - Appearance. */
	Appearance *uint16 `json:"appearance,omitempty"`

	/*** 0x1a - Advertising interval. */
	AdvItvl *uint16 `json:"adv_itvl,omitempty"`

	/*** 0x20 - Service data - 32-bit UUID. */
	SvcDataUuid32 BleBytes `json:"svc_data_uuid32,omitempty"`

	/*** 0x21 - Service data - 128-bit UUID. */
	SvcDataUuid128 BleBytes `json:"svc_data_uuid128,omitempty"`

	/*** 0x24 - URI. */
	Uri *string `json:"uri,omitempty"`

	/*** 0xff - Manufacturer specific data. */
	MfgData BleBytes `json:"mfg_data,omitempty"`
}

func BleAdvFieldsToReq

func BleAdvFieldsToReq(f BleAdvFields) *BleAdvFieldsReq

func NewBleAdvFieldsReq

func NewBleAdvFieldsReq() *BleAdvFieldsReq

type BleAdvFieldsRsp

type BleAdvFieldsRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int      `json:"status"`
	Data   BleBytes `json:"data"`
}

type BleAdvRspSetDataReq

type BleAdvRspSetDataReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Data BleBytes `json:"data"`
}

func NewBleAdvRspSetDataReq

func NewBleAdvRspSetDataReq() *BleAdvRspSetDataReq

type BleAdvRspSetDataRsp

type BleAdvRspSetDataRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleAdvSetDataReq

type BleAdvSetDataReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Data BleBytes `json:"data"`
}

func NewBleAdvSetDataReq

func NewBleAdvSetDataReq() *BleAdvSetDataReq

type BleAdvSetDataRsp

type BleAdvSetDataRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleAdvStartReq

type BleAdvStartReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	OwnAddrType   BleAddrType        `json:"own_addr_type"`
	DurationMs    int                `json:"duration_ms"`
	ConnMode      BleAdvConnMode     `json:"conn_mode"`
	DiscMode      BleAdvDiscMode     `json:"disc_mode"`
	ItvlMin       uint16             `json:"itvl_min"`
	ItvlMax       uint16             `json:"itvl_max"`
	ChannelMap    uint8              `json:"channel_map"`
	FilterPolicy  BleAdvFilterPolicy `json:"filter_policy"`
	HighDutyCycle bool               `json:"high_duty_cycle"`

	// Only required for direct advertisements
	PeerAddr *BleAddr `json:"peer_addr,omitempty"`
}

func NewBleAdvStartReq

func NewBleAdvStartReq() *BleAdvStartReq

type BleAdvStartRsp

type BleAdvStartRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleAdvStopReq

type BleAdvStopReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`
}

func NewBleAdvStopReq

func NewBleAdvStopReq() *BleAdvStopReq

type BleAdvStopRsp

type BleAdvStopRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleBytes

type BleBytes struct {
	Bytes []byte
}

func (*BleBytes) MarshalJSON

func (bb *BleBytes) MarshalJSON() ([]byte, error)

func (*BleBytes) UnmarshalJSON

func (bb *BleBytes) UnmarshalJSON(data []byte) error

type BleClearSvcsReq

type BleClearSvcsReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`
}

func NewBleClearSvcsReq

func NewBleClearSvcsReq() *BleClearSvcsReq

type BleClearSvcsRsp

type BleClearSvcsRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleCommitSvcsReq

type BleCommitSvcsReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`
}

func NewBleCommitSvcsReq

func NewBleCommitSvcsReq() *BleCommitSvcsReq

type BleCommitSvcsRsp

type BleCommitSvcsRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`

	// Optional
	Svcs []BleRegSvc `json:"services"`
}

type BleConnCancelEvt

type BleConnCancelEvt struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`
}

type BleConnCancelReq

type BleConnCancelReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`
}

func NewBleConnCancelReq

func NewBleConnCancelReq() *BleConnCancelReq

type BleConnCancelRsp

type BleConnCancelRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleConnFindReq

type BleConnFindReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	ConnHandle uint16 `json:"conn_handle"`
}

func NewBleConnFindReq

func NewBleConnFindReq() *BleConnFindReq

type BleConnFindRsp

type BleConnFindRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status          int         `json:"status"`
	ConnHandle      uint16      `json:"conn_handle"`
	OwnIdAddrType   BleAddrType `json:"own_id_addr_type"`
	OwnIdAddr       BleAddr     `json:"own_id_addr"`
	OwnOtaAddrType  BleAddrType `json:"own_ota_addr_type"`
	OwnOtaAddr      BleAddr     `json:"own_ota_addr"`
	PeerIdAddrType  BleAddrType `json:"peer_id_addr_type"`
	PeerIdAddr      BleAddr     `json:"peer_id_addr"`
	PeerOtaAddrType BleAddrType `json:"peer_ota_addr_type"`
	PeerOtaAddr     BleAddr     `json:"peer_ota_addr"`
	Role            BleRole     `json:"role"`
	Encrypted       bool        `json:"encrypted"`
	Authenticated   bool        `json:"authenticated"`
	Bonded          bool        `json:"bonded"`
	KeySize         int         `json:"key_size"`
}

type BleConnectEvt

type BleConnectEvt struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status     int    `json:"status"`
	ConnHandle uint16 `json:"conn_handle"`
}

type BleConnectReq

type BleConnectReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	OwnAddrType  BleAddrType `json:"own_addr_type"`
	PeerAddrType BleAddrType `json:"peer_addr_type"`
	PeerAddr     BleAddr     `json:"peer_addr"`

	// Optional
	DurationMs         int `json:"duration_ms"`
	ScanItvl           int `json:"scan_itvl"`
	ScanWindow         int `json:"scan_window"`
	ItvlMin            int `json:"itvl_min"`
	ItvlMax            int `json:"itvl_max"`
	Latency            int `json:"latency"`
	SupervisionTimeout int `json:"supervision_timeout"`
	MinCeLen           int `json:"min_ce_len"`
	MaxCeLen           int `json:"max_ce_len"`
}

func NewBleConnectReq

func NewBleConnectReq() *BleConnectReq

type BleConnectRsp

type BleConnectRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleDiscAllChrsReq

type BleDiscAllChrsReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	ConnHandle  uint16 `json:"conn_handle"`
	StartHandle int    `json:"start_handle"`
	EndHandle   int    `json:"end_handle"`
}

func NewBleDiscAllChrsReq

func NewBleDiscAllChrsReq() *BleDiscAllChrsReq

type BleDiscAllChrsRsp

type BleDiscAllChrsRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleDiscAllDscsReq

type BleDiscAllDscsReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	ConnHandle  uint16 `json:"conn_handle"`
	StartHandle int    `json:"start_handle"`
	EndHandle   int    `json:"end_handle"`
}

func NewBleDiscAllDscsReq

func NewBleDiscAllDscsReq() *BleDiscAllDscsReq

type BleDiscAllDscsRsp

type BleDiscAllDscsRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleDiscAllSvcsReq

type BleDiscAllSvcsReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	ConnHandle uint16 `json:"conn_handle"`
}

func NewBleDiscAllSvcsReq

func NewBleDiscAllSvcsReq() *BleDiscAllSvcsReq

type BleDiscAllSvcsRsp

type BleDiscAllSvcsRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleDiscChr

type BleDiscChr struct {
	DefHandle  int     `json:"def_handle"`
	ValHandle  int     `json:"val_handle"`
	Properties int     `json:"properties"`
	Uuid       BleUuid `json:"uuid"`
}

type BleDiscChrEvt

type BleDiscChrEvt struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int        `json:"status"`
	Chr    BleDiscChr `json:"characteristic"`
}

type BleDiscChrUuidReq

type BleDiscChrUuidReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	ConnHandle  uint16  `json:"conn_handle"`
	StartHandle int     `json:"start_handle"`
	EndHandle   int     `json:"end_handle"`
	Uuid        BleUuid `json:"chr_uuid"`
}

type BleDiscChrUuidRsp

type BleDiscChrUuidRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleDiscDsc

type BleDiscDsc struct {
	Handle uint16  `json:"handle"`
	Uuid   BleUuid `json:"uuid"`
}

type BleDiscDscEvt

type BleDiscDscEvt struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status       int        `json:"status"`
	ChrDefHandle uint16     `json:"chr_def_handle"`
	Dsc          BleDiscDsc `json:"descriptor"`
}

type BleDiscSvc

type BleDiscSvc struct {
	StartHandle int     `json:"start_handle"`
	EndHandle   int     `json:"end_handle"`
	Uuid        BleUuid `json:"uuid"`
}

type BleDiscSvcEvt

type BleDiscSvcEvt struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int        `json:"status"`
	Svc    BleDiscSvc `json:"service"`
}

type BleDiscSvcUuidReq

type BleDiscSvcUuidReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	ConnHandle uint16  `json:"conn_handle"`
	Uuid       BleUuid `json:"svc_uuid"`
}

func NewBleDiscSvcUuidReq

func NewBleDiscSvcUuidReq() *BleDiscSvcUuidReq

type BleDiscSvcUuidRsp

type BleDiscSvcUuidRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleDisconnectEvt

type BleDisconnectEvt struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Reason     int    `json:"reason"`
	ConnHandle uint16 `json:"conn_handle"`
}

type BleEncChangeEvt

type BleEncChangeEvt struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status     int    `json:"status"`
	ConnHandle uint16 `json:"conn_handle"`
}

type BleErrRsp

type BleErrRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int    `json:"status"`
	Msg    string `json:"msg"`
}

type BleExchangeMtuReq

type BleExchangeMtuReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	ConnHandle uint16 `json:"conn_handle"`
}

func NewBleExchangeMtuReq

func NewBleExchangeMtuReq() *BleExchangeMtuReq

type BleExchangeMtuRsp

type BleExchangeMtuRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleFindChrReq

type BleFindChrReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	SvcUuid BleUuid `json:"svc_uuid"`
	ChrUuid BleUuid `json:"chr_uuid"`
}

func NewFindChrReq

func NewFindChrReq() *BleFindChrReq

type BleFindChrRsp

type BleFindChrRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status    int    `json:"status"`
	DefHandle uint16 `json:"def_handle"`
	ValHandle uint16 `json:"val_handle"`
}

type BleGenRandAddrReq

type BleGenRandAddrReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Nrpa bool `json:"nrpa"`
}

func NewBleGenRandAddrReq

func NewBleGenRandAddrReq() *BleGenRandAddrReq

type BleGenRandAddrRsp

type BleGenRandAddrRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int     `json:"status"`
	Addr   BleAddr `json:"addr"`
}

type BleHdr

type BleHdr struct {
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`
}

type BleMtuChangeEvt

type BleMtuChangeEvt struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status     int    `json:"status"`
	ConnHandle uint16 `json:"conn_handle"`
	Mtu        uint16 `json:"mtu"`
}

type BleNotifyReq

type BleNotifyReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	ConnHandle uint16   `json:"conn_handle"`
	AttrHandle uint16   `json:"attr_handle"`
	Data       BleBytes `json:"data"`
}

func NewNotifyReq

func NewNotifyReq() *BleNotifyReq

type BleNotifyRsp

type BleNotifyRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleNotifyRxEvt

type BleNotifyRxEvt struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	ConnHandle uint16   `json:"conn_handle"`
	AttrHandle int      `json:"attr_handle"`
	Indication bool     `json:"indication"`
	Data       BleBytes `json:"data"`
}

type BlePasskeyEvt

type BlePasskeyEvt struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	ConnHandle uint16      `json:"conn_handle"`
	Action     BleSmAction `json:"action"`

	// Optional
	Numcmp uint32 `json:"numcmp"`
}

type BleRegChr

type BleRegChr struct {
	Uuid      BleUuid     `json:"uuid"`
	DefHandle uint16      `json:"def_handle"`
	ValHandle uint16      `json:"val_handle"`
	Dscs      []BleRegDsc `json:"descriptors"`
}

type BleRegDsc

type BleRegDsc struct {
	Uuid   BleUuid `json:"uuid"`
	Handle uint16  `json:"handle"`
}

type BleRegSvc

type BleRegSvc struct {
	Uuid   BleUuid     `json:"uuid"`
	Handle uint16      `json:"handle"`
	Chrs   []BleRegChr `json:"characteristics"`
}

func CommitSvcsXact

func CommitSvcsXact(x *BleXport) ([]BleRegSvc, error)

type BleResetEvt

type BleResetEvt struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Reason int `json:"reason"`
}

type BleResetReq

type BleResetReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`
}

func NewResetReq

func NewResetReq() *BleResetReq

type BleResetRsp

type BleResetRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleScanCancelReq

type BleScanCancelReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`
}

func NewBleScanCancelReq

func NewBleScanCancelReq() *BleScanCancelReq

type BleScanCancelRsp

type BleScanCancelRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleScanCompleteEvt

type BleScanCompleteEvt struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Reason int `json:"reason"`
}

type BleScanEvt

type BleScanEvt struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	EventType BleAdvEventType `json:"event_type"`
	AddrType  BleAddrType     `json:"addr_type"`
	Addr      BleAddr         `json:"addr"`
	Rssi      int8            `json:"rssi"`
	Data      BleBytes        `json:"data"`

	// Optional
	DataFlags              *uint8       `json:"data_flags"`
	DataUuids16            []BleUuid16  `json:"data_uuids16"`
	DataUuids16IsComplete  bool         `json:"data_uuids16_is_complete"`
	DataUuids32            []uint32     `json:"data_uuids32"`
	DataUuids32IsComplete  bool         `json:"data_uuids32_is_complete"`
	DataUuids128           []BleUuid128 `json:"data_uuids128"`
	DataUuids128IsComplete bool         `json:"data_uuids128_is_complete"`
	DataName               *string      `json:"data_name"`
	DataNameIsComplete     bool         `json:"data_name_is_complete"`
	DataTxPwrLvl           *int8        `json:"data_tx_pwr_lvl"`
	DataSlaveItvlMin       *uint16      `json:"data_slave_itvl_min"`
	DataSlaveItvlMax       *uint16      `json:"data_slave_itvl_max"`
	DataSvcDataUuid16      BleBytes     `json:"data_svc_data_uuid16"`
	DataPublicTgtAddrs     []BleAddr    `json:"data_public_tgt_addrs"`
	DataAppearance         *uint16      `json:"data_appearance"`
	DataAdvItvl            *uint16      `json:"data_adv_itvl"`
	DataSvcDataUuid32      BleBytes     `json:"data_svc_data_uuid32"`
	DataSvcDataUuid128     BleBytes     `json:"data_svc_data_uuid128"`
	DataUri                *string      `json:"data_uri"`
	DataMfgData            BleBytes     `json:"data_mfg_data"`
}

type BleScanReq

type BleScanReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	OwnAddrType      BleAddrType         `json:"own_addr_type"`
	DurationMs       int                 `json:"duration_ms"`
	Itvl             int                 `json:"itvl"`
	Window           int                 `json:"window"`
	FilterPolicy     BleScanFilterPolicy `json:"filter_policy"`
	Limited          bool                `json:"limited"`
	Passive          bool                `json:"passive"`
	FilterDuplicates bool                `json:"filter_duplicates"`
}

func NewBleScanReq

func NewBleScanReq() *BleScanReq

type BleScanRsp

type BleScanRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleSecurityInitiateReq

type BleSecurityInitiateReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	ConnHandle uint16 `json:"conn_handle"`
}

func NewBleSecurityInitiateReq

func NewBleSecurityInitiateReq() *BleSecurityInitiateReq

type BleSecurityInitiateRsp

type BleSecurityInitiateRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleSeq

type BleSeq uint32
const BLE_SEQ_EVT_MIN BleSeq = 0xffffff00
const BLE_SEQ_MIN BleSeq = 0
const BLE_SEQ_NONE BleSeq = 0xffffffff

func NextSeq

func NextSeq() BleSeq

type BleSesn

type BleSesn struct {
	Ns *NakedSesn
	// contains filtered or unexported fields
}

func NewBleSesn

func NewBleSesn(bx *BleXport, cfg sesn.SesnCfg) (
	*BleSesn, error)

func (*BleSesn) AbortRx

func (s *BleSesn) AbortRx(seq uint8) error

func (*BleSesn) Close

func (s *BleSesn) Close() error

func (*BleSesn) CoapIsTcp

func (s *BleSesn) CoapIsTcp() bool

func (*BleSesn) ConnInfo

func (s *BleSesn) ConnInfo() (BleConnDesc, error)

func (*BleSesn) Filters

func (s *BleSesn) Filters() (nmcoap.TxMsgFilter, nmcoap.RxMsgFilter)

func (*BleSesn) IsOpen

func (s *BleSesn) IsOpen() bool

func (*BleSesn) ListenCoap

func (s *BleSesn) ListenCoap(mc nmcoap.MsgCriteria) (*nmcoap.Listener, error)

func (*BleSesn) MgmtProto

func (s *BleSesn) MgmtProto() sesn.MgmtProto

func (*BleSesn) MtuIn

func (s *BleSesn) MtuIn() int

func (*BleSesn) MtuOut

func (s *BleSesn) MtuOut() int

func (*BleSesn) Open

func (s *BleSesn) Open() error

func (*BleSesn) OpenConnected

func (s *BleSesn) OpenConnected(
	connHandle uint16, eventListener *Listener) error

func (*BleSesn) RxAccept

func (s *BleSesn) RxAccept() (sesn.Sesn, *sesn.SesnCfg, error)

func (*BleSesn) RxCoap

func (s *BleSesn) RxCoap(opt sesn.TxOptions) (coap.Message, error)

func (*BleSesn) SetFilters

func (s *BleSesn) SetFilters(txFilter nmcoap.TxMsgFilter,
	rxFilter nmcoap.RxMsgFilter)

func (*BleSesn) SetOobKey

func (s *BleSesn) SetOobKey(key []byte)

func (*BleSesn) StopListenCoap

func (s *BleSesn) StopListenCoap(mc nmcoap.MsgCriteria)

func (*BleSesn) TxCoap

func (s *BleSesn) TxCoap(m coap.Message) error

func (*BleSesn) TxRxMgmt

func (s *BleSesn) TxRxMgmt(m *nmp.NmpMsg,
	timeout time.Duration) (nmp.NmpRsp, error)

func (*BleSesn) TxRxMgmtAsync

func (s *BleSesn) TxRxMgmtAsync(m *nmp.NmpMsg,
	timeout time.Duration, ch chan nmp.NmpRsp, errc chan error) error

type BleSetPreferredMtuReq

type BleSetPreferredMtuReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Mtu uint16 `json:"mtu"`
}

func NewBleSetPreferredMtuReq

func NewBleSetPreferredMtuReq() *BleSetPreferredMtuReq

type BleSetPreferredMtuRsp

type BleSetPreferredMtuRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleSetRandAddrReq

type BleSetRandAddrReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Addr BleAddr `json:"addr"`
}

func NewBleSetRandAddrReq

func NewBleSetRandAddrReq() *BleSetRandAddrReq

type BleSetRandAddrRsp

type BleSetRandAddrRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleSmInjectIoReq

type BleSmInjectIoReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	ConnHandle uint16      `json:"conn_handle"`
	Action     BleSmAction `json:"action"`

	// Only one field valid depending on the value of `action`.
	OobData      BleBytes `json:"oob_data"`
	Passkey      uint32   `json:"passkey"`
	NumcmpAccept bool     `json:"numcmp_accept"`
}

func NewBleSmInjectIoReq

func NewBleSmInjectIoReq() *BleSmInjectIoReq

type BleSmInjectIoRsp

type BleSmInjectIoRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleSyncEvt

type BleSyncEvt struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Synced bool `json:"synced"`
}

type BleSyncReq

type BleSyncReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`
}

func NewSyncReq

func NewSyncReq() *BleSyncReq

type BleSyncRsp

type BleSyncRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Synced bool `json:"synced"`
}

type BleTerminateReq

type BleTerminateReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	ConnHandle uint16 `json:"conn_handle"`
	HciReason  int    `json:"hci_reason"`
}

func NewBleTerminateReq

func NewBleTerminateReq() *BleTerminateReq

type BleTerminateRsp

type BleTerminateRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleWriteAckEvt

type BleWriteAckEvt struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleWriteCmdReq

type BleWriteCmdReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	ConnHandle uint16   `json:"conn_handle"`
	AttrHandle int      `json:"attr_handle"`
	Data       BleBytes `json:"data"`
}

func NewBleWriteCmdReq

func NewBleWriteCmdReq() *BleWriteCmdReq

type BleWriteCmdRsp

type BleWriteCmdRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleWriteReq

type BleWriteReq struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	ConnHandle uint16   `json:"conn_handle"`
	AttrHandle int      `json:"attr_handle"`
	Data       BleBytes `json:"data"`
}

func NewBleWriteReq

func NewBleWriteReq() *BleWriteReq

type BleWriteRsp

type BleWriteRsp struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Mandatory
	Status int `json:"status"`
}

type BleXport

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

Implements xport.Xport.

func NewBleXport

func NewBleXport(cfg XportCfg) (*BleXport, error)

func (*BleXport) AcquireMasterPrimary

func (bx *BleXport) AcquireMasterPrimary(token interface{}) error

func (*BleXport) AcquireMasterSecondary

func (bx *BleXport) AcquireMasterSecondary() error

func (*BleXport) AcquireSlave

func (bx *BleXport) AcquireSlave(token interface{}) error

func (*BleXport) AddListener

func (bx *BleXport) AddListener(key ListenerKey) (*Listener, error)

func (*BleXport) AddSesn

func (bx *BleXport) AddSesn(connHandle uint16, s *NakedSesn)

func (*BleXport) Advertiser

func (bx *BleXport) Advertiser() *Advertiser

func (*BleXport) BuildSesn

func (bx *BleXport) BuildSesn(cfg sesn.SesnCfg) (sesn.Sesn, error)

func (*BleXport) FindSesn

func (bx *BleXport) FindSesn(connHandle uint16) *NakedSesn

func (*BleXport) GetMasterSecondary

func (bx *BleXport) GetMasterSecondary() Preemptable

func (*BleXport) ReleaseMaster

func (bx *BleXport) ReleaseMaster()

func (*BleXport) ReleaseSlave

func (bx *BleXport) ReleaseSlave()

func (*BleXport) RemoveKey

func (bx *BleXport) RemoveKey(key ListenerKey) *Listener

func (*BleXport) RemoveListener

func (bx *BleXport) RemoveListener(listener *Listener) *ListenerKey

func (*BleXport) RemoveSesn

func (bx *BleXport) RemoveSesn(connHandle uint16) *NakedSesn

func (*BleXport) Restart

func (bx *BleXport) Restart(reason string)

func (*BleXport) RspTimeout

func (bx *BleXport) RspTimeout() time.Duration

func (*BleXport) SetMasterSecondary

func (bx *BleXport) SetMasterSecondary(s Preemptable) error

func (*BleXport) SetServices

func (bx *BleXport) SetServices(svcs []BleSvc) error

func (*BleXport) Start

func (bx *BleXport) Start() error

func (*BleXport) Stop

func (bx *BleXport) Stop() error

func (*BleXport) StopWaitingForMasterPrimary

func (bx *BleXport) StopWaitingForMasterPrimary(token interface{}, err error)

func (*BleXport) StopWaitingForMasterSecondary

func (bx *BleXport) StopWaitingForMasterSecondary(err error)

func (*BleXport) StopWaitingForSlave

func (bx *BleXport) StopWaitingForSlave(token interface{}, err error)

func (*BleXport) Tx

func (bx *BleXport) Tx(data []byte) error

Transmit data to blehostd. If the host and controller are not synced, this function blocks until they are (or until the sync fails).

type Characteristic

type Characteristic struct {
	Uuid       BleUuid
	DefHandle  uint16
	ValHandle  uint16
	Properties BleDiscChrProperties
	Dscs       []*Descriptor
}

func (*Characteristic) String

func (c *Characteristic) String() string

func (*Characteristic) SubscribeType

func (c *Characteristic) SubscribeType() BleDiscChrProperties

type ChrMgr

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

func (*ChrMgr) Access

func (cm *ChrMgr) Access(x *BleXport, evt *BleAccessEvt) error

func (*ChrMgr) Clear

func (cm *ChrMgr) Clear()

func (*ChrMgr) SetServices

func (cm *ChrMgr) SetServices(x *BleXport, svcs []BleSvc) error

type Conn

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

Implements a low-level BLE connection. Objets of this type must never be reused; after a disconnect, a new object should be created if you wish to reconnect to the peer.

Starts Goroutines on: * Successful call to Connect(). * Successful call to Inherit().

Stops Goroutines on: * Successful call to Stop(). * Unsolicited disconnect.

func NewConn

func NewConn(bx *BleXport) *Conn

func (*Conn) AttMtu

func (c *Conn) AttMtu() uint16

func (*Conn) ConnInfo

func (c *Conn) ConnInfo() BleConnDesc

func (*Conn) Connect

func (c *Conn) Connect(ownAddrType BleAddrType, peer BleDev,
	timeout time.Duration) error

func (*Conn) DisconnectChan

func (c *Conn) DisconnectChan() <-chan error

func (*Conn) DiscoverSvcs

func (c *Conn) DiscoverSvcs() error

func (*Conn) ExchangeMtu

func (c *Conn) ExchangeMtu() error

func (*Conn) Inherit

func (c *Conn) Inherit(connHandle uint16, bl *Listener) error

Opens the session for an already-established BLE connection.

func (*Conn) InitiateSecurity

func (c *Conn) InitiateSecurity() error

func (*Conn) IsConnected

func (c *Conn) IsConnected() bool

func (*Conn) ListenForNotifications

func (c *Conn) ListenForNotifications(chr *Characteristic) (
	*NotifyListener, error)

func (*Conn) Profile

func (c *Conn) Profile() *Profile

func (*Conn) SmInjectIo

func (c *Conn) SmInjectIo(io SmIo) error

func (*Conn) SmIoDemandChan

func (c *Conn) SmIoDemandChan() <-chan SmIoDemand

func (*Conn) Stop

func (c *Conn) Stop() error

func (*Conn) Subscribe

func (c *Conn) Subscribe(chr *Characteristic) error

func (*Conn) WriteChr

func (c *Conn) WriteChr(chr *Characteristic, payload []byte,
	name string) error

func (*Conn) WriteChrNoRsp

func (c *Conn) WriteChrNoRsp(chr *Characteristic, payload []byte,
	name string) error

type Descriptor

type Descriptor struct {
	Uuid     BleUuid
	Handle   uint16
	AttFlags BleAttFlags
}

func FindDscByUuid

func FindDscByUuid(chr *Characteristic, uuid BleUuid) *Descriptor

type Discoverer

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

Listens for advertisements; reports the ones that match the specified predicate. This type is not thread-safe.

func NewDiscoverer

func NewDiscoverer(params DiscovererParams) *Discoverer

func (*Discoverer) Start

func (d *Discoverer) Start() (<-chan BleAdvReport, <-chan error, error)

func (*Discoverer) Stop

func (d *Discoverer) Stop() error

Ensures the discoverer is stopped. Errors can typically be ignored.

type DiscovererParams

type DiscovererParams struct {
	Bx          *BleXport
	OwnAddrType BleAddrType
	Passive     bool
	Duration    time.Duration
}

type Dispatcher

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

The dispatcher is the owner of the listeners it points to. Only the dispatcher writes to these listeners.

func NewDispatcher

func NewDispatcher() *Dispatcher

func (*Dispatcher) AddListener

func (d *Dispatcher) AddListener(key ListenerKey, listener *Listener) error

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(data []byte)

func (*Dispatcher) ErrorAll

func (d *Dispatcher) ErrorAll(err error)

func (*Dispatcher) RemoveKey

func (d *Dispatcher) RemoveKey(key ListenerKey) *Listener

func (*Dispatcher) RemoveListener

func (d *Dispatcher) RemoveListener(listener *Listener) *ListenerKey

type Listener

type Listener struct {
	MsgChan chan Msg
	ErrChan chan error
	TmoChan chan time.Time
	Acked   bool
	// contains filtered or unexported fields
}

func NewListener

func NewListener() *Listener

func (*Listener) AfterTimeout

func (bl *Listener) AfterTimeout(tmo time.Duration) <-chan time.Time

func (*Listener) Close

func (bl *Listener) Close()

type ListenerKey

type ListenerKey struct {
	// seq-key only.
	Seq BleSeq

	// tch-key only (type-conn-handle).
	Type       MsgType
	ConnHandle int
}

func SeqKey

func SeqKey(seq BleSeq) ListenerKey

Listener that matches by sequence number.

func TchKey

func TchKey(typ MsgType, connHandle int) ListenerKey

Listener that matches by TCH (type and conn-handle).

type ListenerMap

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

Not thread safe.

func NewListenerMap

func NewListenerMap() *ListenerMap

func (*ListenerMap) AddListener

func (lm *ListenerMap) AddListener(key ListenerKey, listener *Listener) error

func (*ListenerMap) ExtractAll

func (lm *ListenerMap) ExtractAll() []*Listener

func (*ListenerMap) FindListener

func (lm *ListenerMap) FindListener(seq BleSeq, typ MsgType, connHandle int) (
	ListenerKey, *Listener)

func (*ListenerMap) RemoveKey

func (lm *ListenerMap) RemoveKey(key ListenerKey) *Listener

func (*ListenerMap) RemoveListener

func (lm *ListenerMap) RemoveListener(listener *Listener) *ListenerKey

type Master

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

Represents the Bluetooth device's "master privileges." The device can only do one of the following actions at a time: * initiate connection * scan

Clients are divided into two groups: * primary * secondary

This struct restricts master privileges to a single client at a time. It uses the following procedure to determine which of several clients to serve:

If there is one or more waiting primaries:
    If a secondary is active, preempt it.
    Service the primaries in the order of their requests.
Else (no waiting primaries):
    Service waiting secondary if there is one.

func NewMaster

func NewMaster(x *BleXport) Master

func (*Master) Abort

func (m *Master) Abort(err error)

Releases the resource and clears the wait queue.

func (*Master) AcquirePrimary

func (m *Master) AcquirePrimary(token interface{}) error

func (*Master) AcquireSecondary

func (m *Master) AcquireSecondary() error

func (*Master) GetSecondary

func (m *Master) GetSecondary() Preemptable

func (*Master) Release

func (m *Master) Release()

func (*Master) SetSecondary

func (m *Master) SetSecondary(s Preemptable) error

func (*Master) StopWaitingPrimary

func (m *Master) StopWaitingPrimary(token interface{}, err error)

Removes the specified primary from the wait queue.

func (*Master) StopWaitingSecondary

func (m *Master) StopWaitingSecondary(err error)

Removes the specified secondary from the wait queue.

type Msg

type Msg interface{}

type MsgBase

type MsgBase struct {
	// Header
	Op   MsgOp   `json:"op"`
	Type MsgType `json:"type"`
	Seq  BleSeq  `json:"seq"`

	// Optional
	ConnHandle int `json:"conn_handle" json:",omitempty"`
}

type MsgOp

type MsgOp int

func MsgOpFromString

func MsgOpFromString(s string) (MsgOp, error)

func (MsgOp) MarshalJSON

func (o MsgOp) MarshalJSON() ([]byte, error)

func (*MsgOp) UnmarshalJSON

func (o *MsgOp) UnmarshalJSON(data []byte) error

type MsgType

type MsgType int

func MsgTypeFromString

func MsgTypeFromString(s string) (MsgType, error)

func (MsgType) MarshalJSON

func (t MsgType) MarshalJSON() ([]byte, error)

func (*MsgType) UnmarshalJSON

func (t *MsgType) UnmarshalJSON(data []byte) error

type NakedSesn

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

Implements a BLE session that does not acquire the master resource on connect. The user of this type must acquire the resource manually.

func NewNakedSesn

func NewNakedSesn(bx *BleXport, cfg sesn.SesnCfg) (*NakedSesn, error)

func (*NakedSesn) AbortRx

func (s *NakedSesn) AbortRx(seq uint8) error

func (*NakedSesn) Close

func (s *NakedSesn) Close() error

func (*NakedSesn) CoapIsTcp

func (s *NakedSesn) CoapIsTcp() bool

func (*NakedSesn) ConnInfo

func (s *NakedSesn) ConnInfo() (BleConnDesc, error)

func (*NakedSesn) Filters

func (s *NakedSesn) Filters() (nmcoap.TxMsgFilter, nmcoap.RxMsgFilter)

func (*NakedSesn) IsOpen

func (s *NakedSesn) IsOpen() bool

func (*NakedSesn) ListenCoap

func (s *NakedSesn) ListenCoap(
	mc nmcoap.MsgCriteria) (*nmcoap.Listener, error)

func (*NakedSesn) MgmtProto

func (s *NakedSesn) MgmtProto() sesn.MgmtProto

func (*NakedSesn) MtuIn

func (s *NakedSesn) MtuIn() int

func (*NakedSesn) MtuOut

func (s *NakedSesn) MtuOut() int

func (*NakedSesn) Open

func (s *NakedSesn) Open() error

func (*NakedSesn) OpenConnected

func (s *NakedSesn) OpenConnected(
	connHandle uint16, eventListener *Listener) error

func (*NakedSesn) RxAccept

func (s *NakedSesn) RxAccept() (sesn.Sesn, *sesn.SesnCfg, error)

func (*NakedSesn) RxCoap

func (s *NakedSesn) RxCoap(opt sesn.TxOptions) (coap.Message, error)

func (*NakedSesn) SetFilters

func (s *NakedSesn) SetFilters(txFilter nmcoap.TxMsgFilter,
	rxFilter nmcoap.RxMsgFilter)

func (*NakedSesn) SetOobKey

func (s *NakedSesn) SetOobKey(key []byte)

func (*NakedSesn) StopListenCoap

func (s *NakedSesn) StopListenCoap(mc nmcoap.MsgCriteria)

func (*NakedSesn) TxCoap

func (s *NakedSesn) TxCoap(m coap.Message) error

func (*NakedSesn) TxRxMgmt

func (s *NakedSesn) TxRxMgmt(m *nmp.NmpMsg,
	timeout time.Duration) (nmp.NmpRsp, error)

func (*NakedSesn) TxRxMgmtAsync

func (s *NakedSesn) TxRxMgmtAsync(m *nmp.NmpMsg,
	timeout time.Duration, ch chan nmp.NmpRsp, errc chan error) error

type NakedSesnState

type NakedSesnState int
const (
	// Session not open and no open in progress.
	NS_STATE_CLOSED NakedSesnState = iota

	// Open in progress.
	NS_STATE_OPENING_ACTIVE

	// After a failed open; additional retries remain.
	NS_STATE_OPENING_IDLE

	// Open complete.
	NS_STATE_OPEN
)

type Notification

type Notification struct {
	Chr        *Characteristic
	Data       []byte
	Indication bool
}

type NotifyListener

type NotifyListener struct {
	NotifyChan chan Notification
	ErrChan    chan error
}

func NewNotifyListener

func NewNotifyListener() *NotifyListener

type OpTypePair

type OpTypePair struct {
	Op   MsgOp
	Type MsgType
}

type Preemptable

type Preemptable interface {
	Preempt() error
}

type Profile

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

func NewProfile

func NewProfile() Profile

func (*Profile) FindChrByHandle

func (p *Profile) FindChrByHandle(handle uint16) *Characteristic

func (*Profile) FindChrByUuid

func (p *Profile) FindChrByUuid(id BleChrId) *Characteristic

func (*Profile) Services

func (p *Profile) Services() []Service

func (*Profile) SetServices

func (p *Profile) SetServices(svcs []Service)

type Receiver

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

func NewReceiver

func NewReceiver(id uint32, bx *BleXport, logDepth int) *Receiver

func (*Receiver) AddListener

func (r *Receiver) AddListener(name string, key ListenerKey) (
	*Listener, error)

func (*Receiver) RemoveAll

func (r *Receiver) RemoveAll(name string)

func (*Receiver) RemoveKey

func (r *Receiver) RemoveKey(name string, key ListenerKey) *Listener

func (*Receiver) RemoveListener

func (r *Receiver) RemoveListener(name string, listener *Listener) *ListenerKey

func (*Receiver) WaitUntilNoListeners

func (r *Receiver) WaitUntilNoListeners()

type Service

type Service struct {
	Uuid        BleUuid
	StartHandle uint16
	EndHandle   uint16
	Chrs        []*Characteristic
}

type SmIo

type SmIo struct {
	// Mandatory.
	Action BleSmAction

	// Action dependent.
	Oob          []byte // OOB only.
	Passkey      uint32 // Display and input only.
	NumcmpAccept bool   // Numcmp only.
}

Sent down from the parent session in response to an SM IO demand.

type SmIoDemand

type SmIoDemand struct {
	// Mandatory.
	Action BleSmAction

	// Only valid when Action==BLE_SM_ACTION_NUMCMP.
	Numcmp uint32
}

Sent up to the parent session to indicate that IO is required to complete a pairing procedure.

type Syncer

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

func (*Syncer) Refresh

func (s *Syncer) Refresh() (bool, error)

func (*Syncer) Start

func (s *Syncer) Start(x *BleXport) (<-chan bool, <-chan int, error)

func (*Syncer) Stop

func (s *Syncer) Stop() error

func (*Syncer) Synced

func (s *Syncer) Synced() bool

type XportCfg

type XportCfg struct {

	// Path of Unix domain socket to create and listen on.
	SockPath string

	// Path of the blehostd executable.
	BlehostdPath string

	// Path of the BLE controller device (e.g., /dev/ttyUSB0).
	DevPath string

	// How long to wait for the blehostd process to connect to the Unix domain
	// socket.
	// Default: 1 second.
	BlehostdAcceptTimeout time.Duration

	// How long to wait for a JSON response from the blehostd process.
	// Default: 10 seconds.
	BlehostdRspTimeout time.Duration

	// How long to allow for the host and controller to sync at startup.
	// Default: 2 seconds.
	SyncTimeout time.Duration

	// The static random address to use.  Set to nil if one should be
	// generated.
	// Default: nil (auto-generate).
	RandAddr *BleAddr

	// The value to specify during ATT MTU exchange.
	// Default: 264.
	PreferredMtu uint16

	// Additional args to blehostd
	BlehostdArgs []string

	// Whether to restart automatically when an error is detected.
	// Default: true.
	Restart bool
}

func NewXportCfg

func NewXportCfg() XportCfg

Jump to

Keyboard shortcuts

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