Documentation ¶
Index ¶
- Constants
- Variables
- func AccessStatusXact(x *BleXport, attStatus uint8, data []byte) error
- func AddSvcsXact(x *BleXport, svcs []BleAddSvc) error
- func BhdTimeoutError(rspType MsgType, seq BleSeq) error
- func BleAdvReportFromScanEvt(e *BleScanEvt) BleAdvReport
- func BleDescFromConnFindRsp(r *BleConnFindRsp) BleConnDesc
- func BuildMgmtChrs(mgmtProto sesn.MgmtProto) (BleMgmtChrs, error)
- func ClearSvcsXact(x *BleXport) error
- func ConnFindXact(x *BleXport, connHandle uint16) (BleConnDesc, error)
- func DiscoverDevice(bx *BleXport, ownAddrType BleAddrType, duration time.Duration, ...) (*BleDev, error)
- func DiscoverDeviceWithName(bx *BleXport, ownAddrType BleAddrType, timeout time.Duration, name string) (*BleDev, error)
- func ErrCodeToAtt(e int) int
- func ErrCodeToHci(e int) int
- func ErrCodeToL2c(e int) int
- func ErrCodeToSmPeer(e int) int
- func ErrCodeToSmUs(e int) int
- func ErrCodeToString(e int) string
- func FindChrXact(x *BleXport, svcUuid BleUuid, chrUuid BleUuid) (uint16, uint16, error)
- func GapService(devName string) BleSvc
- func GattService() BleSvc
- func GenRandAddrXact(x *BleXport) (BleAddr, error)
- func IsSecErr(err error) bool
- func MsgOpToString(op MsgOp) string
- func MsgTypeToString(msgType MsgType) string
- func NotifyXact(x *BleXport, connHandle uint16, attrHandle uint16, data []byte) error
- func ResetXact(x *BleXport) error
- func SetPreferredMtuXact(x *BleXport, mtu uint16) error
- func SetRandAddrXact(x *BleXport, addr BleAddr) error
- func StatusError(op MsgOp, msgType MsgType, status int) error
- func SyncXact(x *BleXport) (bool, error)
- func ToSecurityErr(err error) error
- type AdvertiseCfg
- type Advertiser
- type BleAccessEvt
- type BleAccessStatusReq
- type BleAccessStatusRsp
- type BleAddChr
- type BleAddDsc
- type BleAddSvc
- type BleAddSvcsReq
- type BleAddSvcsRsp
- type BleAdvCompleteEvt
- type BleAdvFieldsReq
- type BleAdvFieldsRsp
- type BleAdvRspSetDataReq
- type BleAdvRspSetDataRsp
- type BleAdvSetDataReq
- type BleAdvSetDataRsp
- type BleAdvStartReq
- type BleAdvStartRsp
- type BleAdvStopReq
- type BleAdvStopRsp
- type BleBytes
- type BleClearSvcsReq
- type BleClearSvcsRsp
- type BleCommitSvcsReq
- type BleCommitSvcsRsp
- type BleConnCancelEvt
- type BleConnCancelReq
- type BleConnCancelRsp
- type BleConnFindReq
- type BleConnFindRsp
- type BleConnectEvt
- type BleConnectReq
- type BleConnectRsp
- type BleDiscAllChrsReq
- type BleDiscAllChrsRsp
- type BleDiscAllDscsReq
- type BleDiscAllDscsRsp
- type BleDiscAllSvcsReq
- type BleDiscAllSvcsRsp
- type BleDiscChr
- type BleDiscChrEvt
- type BleDiscChrUuidReq
- type BleDiscChrUuidRsp
- type BleDiscDsc
- type BleDiscDscEvt
- type BleDiscSvc
- type BleDiscSvcEvt
- type BleDiscSvcUuidReq
- type BleDiscSvcUuidRsp
- type BleDisconnectEvt
- type BleEncChangeEvt
- type BleErrRsp
- type BleExchangeMtuReq
- type BleExchangeMtuRsp
- type BleFindChrReq
- type BleFindChrRsp
- type BleGenRandAddrReq
- type BleGenRandAddrRsp
- type BleHdr
- type BleMtuChangeEvt
- type BleNotifyReq
- type BleNotifyRsp
- type BleNotifyRxEvt
- type BlePasskeyEvt
- type BleRegChr
- type BleRegDsc
- type BleRegSvc
- type BleResetEvt
- type BleResetReq
- type BleResetRsp
- type BleScanCancelReq
- type BleScanCancelRsp
- type BleScanCompleteEvt
- type BleScanEvt
- type BleScanReq
- type BleScanRsp
- type BleSecurityInitiateReq
- type BleSecurityInitiateRsp
- type BleSeq
- type BleSesn
- func (s *BleSesn) AbortRx(seq uint8) error
- func (s *BleSesn) Close() error
- func (s *BleSesn) CoapIsTcp() bool
- func (s *BleSesn) ConnInfo() (BleConnDesc, error)
- func (s *BleSesn) Filters() (nmcoap.TxMsgFilter, nmcoap.RxMsgFilter)
- func (s *BleSesn) IsOpen() bool
- func (s *BleSesn) ListenCoap(mc nmcoap.MsgCriteria) (*nmcoap.Listener, error)
- func (s *BleSesn) MgmtProto() sesn.MgmtProto
- func (s *BleSesn) MtuIn() int
- func (s *BleSesn) MtuOut() int
- func (s *BleSesn) Open() error
- func (s *BleSesn) OpenConnected(connHandle uint16, eventListener *Listener) error
- func (s *BleSesn) RxAccept() (sesn.Sesn, *sesn.SesnCfg, error)
- func (s *BleSesn) RxCoap(opt sesn.TxOptions) (coap.Message, error)
- func (s *BleSesn) SetFilters(txFilter nmcoap.TxMsgFilter, rxFilter nmcoap.RxMsgFilter)
- func (s *BleSesn) SetOobKey(key []byte)
- func (s *BleSesn) StopListenCoap(mc nmcoap.MsgCriteria)
- func (s *BleSesn) TxCoap(m coap.Message) error
- func (s *BleSesn) TxRxMgmt(m *nmp.NmpMsg, timeout time.Duration) (nmp.NmpRsp, error)
- func (s *BleSesn) TxRxMgmtAsync(m *nmp.NmpMsg, timeout time.Duration, ch chan nmp.NmpRsp, errc chan error) error
- type BleSetPreferredMtuReq
- type BleSetPreferredMtuRsp
- type BleSetRandAddrReq
- type BleSetRandAddrRsp
- type BleSmInjectIoReq
- type BleSmInjectIoRsp
- type BleSyncEvt
- type BleSyncReq
- type BleSyncRsp
- type BleTerminateReq
- type BleTerminateRsp
- type BleWriteAckEvt
- type BleWriteCmdReq
- type BleWriteCmdRsp
- type BleWriteReq
- type BleWriteRsp
- type BleXport
- func (bx *BleXport) AcquireMasterPrimary(token interface{}) error
- func (bx *BleXport) AcquireMasterSecondary() error
- func (bx *BleXport) AcquireSlave(token interface{}) error
- func (bx *BleXport) AddListener(key ListenerKey) (*Listener, error)
- func (bx *BleXport) AddSesn(connHandle uint16, s *NakedSesn)
- func (bx *BleXport) Advertiser() *Advertiser
- func (bx *BleXport) BuildSesn(cfg sesn.SesnCfg) (sesn.Sesn, error)
- func (bx *BleXport) FindSesn(connHandle uint16) *NakedSesn
- func (bx *BleXport) GetMasterSecondary() Preemptable
- func (bx *BleXport) ReleaseMaster()
- func (bx *BleXport) ReleaseSlave()
- func (bx *BleXport) RemoveKey(key ListenerKey) *Listener
- func (bx *BleXport) RemoveListener(listener *Listener) *ListenerKey
- func (bx *BleXport) RemoveSesn(connHandle uint16) *NakedSesn
- func (bx *BleXport) Restart(reason string)
- func (bx *BleXport) RspTimeout() time.Duration
- func (bx *BleXport) SetMasterSecondary(s Preemptable) error
- func (bx *BleXport) SetServices(svcs []BleSvc) error
- func (bx *BleXport) Start() error
- func (bx *BleXport) Stop() error
- func (bx *BleXport) StopWaitingForMasterPrimary(token interface{}, err error)
- func (bx *BleXport) StopWaitingForMasterSecondary(err error)
- func (bx *BleXport) StopWaitingForSlave(token interface{}, err error)
- func (bx *BleXport) Tx(data []byte) error
- type Characteristic
- type ChrMgr
- type Conn
- func (c *Conn) AttMtu() uint16
- func (c *Conn) ConnInfo() BleConnDesc
- func (c *Conn) Connect(ownAddrType BleAddrType, peer BleDev, timeout time.Duration) error
- func (c *Conn) DisconnectChan() <-chan error
- func (c *Conn) DiscoverSvcs() error
- func (c *Conn) ExchangeMtu() error
- func (c *Conn) Inherit(connHandle uint16, bl *Listener) error
- func (c *Conn) InitiateSecurity() error
- func (c *Conn) IsConnected() bool
- func (c *Conn) ListenForNotifications(chr *Characteristic) (*NotifyListener, error)
- func (c *Conn) Profile() *Profile
- func (c *Conn) SmInjectIo(io SmIo) error
- func (c *Conn) SmIoDemandChan() <-chan SmIoDemand
- func (c *Conn) Stop() error
- func (c *Conn) Subscribe(chr *Characteristic) error
- func (c *Conn) WriteChr(chr *Characteristic, payload []byte, name string) error
- func (c *Conn) WriteChrNoRsp(chr *Characteristic, payload []byte, name string) error
- type Descriptor
- type Discoverer
- type DiscovererParams
- type Dispatcher
- type Listener
- type ListenerKey
- type ListenerMap
- func (lm *ListenerMap) AddListener(key ListenerKey, listener *Listener) error
- func (lm *ListenerMap) ExtractAll() []*Listener
- func (lm *ListenerMap) FindListener(seq BleSeq, typ MsgType, connHandle int) (ListenerKey, *Listener)
- func (lm *ListenerMap) RemoveKey(key ListenerKey) *Listener
- func (lm *ListenerMap) RemoveListener(listener *Listener) *ListenerKey
- type Master
- func (m *Master) Abort(err error)
- func (m *Master) AcquirePrimary(token interface{}) error
- func (m *Master) AcquireSecondary() error
- func (m *Master) GetSecondary() Preemptable
- func (m *Master) Release()
- func (m *Master) SetSecondary(s Preemptable) error
- func (m *Master) StopWaitingPrimary(token interface{}, err error)
- func (m *Master) StopWaitingSecondary(err error)
- type Msg
- type MsgBase
- type MsgOp
- type MsgType
- type NakedSesn
- func (s *NakedSesn) AbortRx(seq uint8) error
- func (s *NakedSesn) Close() error
- func (s *NakedSesn) CoapIsTcp() bool
- func (s *NakedSesn) ConnInfo() (BleConnDesc, error)
- func (s *NakedSesn) Filters() (nmcoap.TxMsgFilter, nmcoap.RxMsgFilter)
- func (s *NakedSesn) IsOpen() bool
- func (s *NakedSesn) ListenCoap(mc nmcoap.MsgCriteria) (*nmcoap.Listener, error)
- func (s *NakedSesn) MgmtProto() sesn.MgmtProto
- func (s *NakedSesn) MtuIn() int
- func (s *NakedSesn) MtuOut() int
- func (s *NakedSesn) Open() error
- func (s *NakedSesn) OpenConnected(connHandle uint16, eventListener *Listener) error
- func (s *NakedSesn) RxAccept() (sesn.Sesn, *sesn.SesnCfg, error)
- func (s *NakedSesn) RxCoap(opt sesn.TxOptions) (coap.Message, error)
- func (s *NakedSesn) SetFilters(txFilter nmcoap.TxMsgFilter, rxFilter nmcoap.RxMsgFilter)
- func (s *NakedSesn) SetOobKey(key []byte)
- func (s *NakedSesn) StopListenCoap(mc nmcoap.MsgCriteria)
- func (s *NakedSesn) TxCoap(m coap.Message) error
- func (s *NakedSesn) TxRxMgmt(m *nmp.NmpMsg, timeout time.Duration) (nmp.NmpRsp, error)
- func (s *NakedSesn) TxRxMgmtAsync(m *nmp.NmpMsg, timeout time.Duration, ch chan nmp.NmpRsp, errc chan error) error
- type NakedSesnState
- type Notification
- type NotifyListener
- type OpTypePair
- type Preemptable
- type Profile
- type Receiver
- func (r *Receiver) AddListener(name string, key ListenerKey) (*Listener, error)
- func (r *Receiver) RemoveAll(name string)
- func (r *Receiver) RemoveKey(name string, key ListenerKey) *Listener
- func (r *Receiver) RemoveListener(name string, listener *Listener) *ListenerKey
- func (r *Receiver) WaitUntilNoListeners()
- type Service
- type SmIo
- type SmIoDemand
- type Syncer
- type XportCfg
Constants ¶
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 )
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 )
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 )
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 )
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.
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.
const ( DISCOVERER_STATE_IDLE discovererState = iota DISCOVERER_STATE_STARTED DISCOVERER_STATE_STOPPING DISCOVERER_STATE_STOPPED )
const ( MASTER_STATE_IDLE masterState = iota MASTER_STATE_SECONDARY MASTER_STATE_PRIMARY MASTER_STATE_PRIMARY_SECONDARY_PENDING )
const BLE_CONN_HANDLE_NONE uint16 = 0xffff
const ERR_CODE_ATT_BASE = 0x100
const ERR_CODE_HCI_BASE = 0x200
const ERR_CODE_L2C_BASE = 0x300
const ERR_CODE_SM_PEER_BASE = 0x500
const ERR_CODE_SM_US_BASE = 0x400
const NOTIFY_CMD_BASE_SZ = 3
const WRITE_CMD_BASE_SZ = 3
Variables ¶
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", }
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", }
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", }
var MsgOpStringMap = map[MsgOp]string{ MSG_OP_REQ: "request", MSG_OP_RSP: "response", MSG_OP_EVT: "event", }
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", }
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 AddSvcsXact ¶
func BhdTimeoutError ¶
func BleAdvReportFromScanEvt ¶
func BleAdvReportFromScanEvt(e *BleScanEvt) BleAdvReport
func BleDescFromConnFindRsp ¶
func BleDescFromConnFindRsp(r *BleConnFindRsp) BleConnDesc
func BuildMgmtChrs ¶
func ClearSvcsXact ¶
func ConnFindXact ¶
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 ErrCodeToAtt ¶
func ErrCodeToHci ¶
func ErrCodeToL2c ¶
func ErrCodeToSmPeer ¶
func ErrCodeToSmUs ¶
func ErrCodeToString ¶
func FindChrXact ¶
func GapService ¶
func GapService(devName string) BleSvc
func GattService ¶
func GattService() BleSvc
func GenRandAddrXact ¶
func MsgOpToString ¶
func MsgTypeToString ¶
func NotifyXact ¶
func SetPreferredMtuXact ¶
func SetRandAddrXact ¶
func ToSecurityErr ¶
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 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 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 BleAdvCompleteEvt ¶
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 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 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 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 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 BleBytes ¶
type BleBytes struct {
Bytes []byte
}
func (*BleBytes) MarshalJSON ¶
func (*BleBytes) UnmarshalJSON ¶
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 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 BleConnCancelEvt ¶
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 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 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 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 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 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 BleDiscChr ¶
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 BleDiscChrUuidRsp ¶
type BleDiscDsc ¶
type BleDiscDsc struct { Handle uint16 `json:"handle"` Uuid BleUuid `json:"uuid"` }
type BleDiscDscEvt ¶
type BleDiscSvc ¶
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 BleDisconnectEvt ¶
type BleEncChangeEvt ¶
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 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 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 BleMtuChangeEvt ¶
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 BleNotifyRxEvt ¶
type BlePasskeyEvt ¶
type BleRegSvc ¶
type BleRegSvc struct { Uuid BleUuid `json:"uuid"` Handle uint16 `json:"handle"` Chrs []BleRegChr `json:"characteristics"` }
func CommitSvcsXact ¶
type BleResetEvt ¶
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 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 BleScanCompleteEvt ¶
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 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 BleSeq ¶
type BleSeq uint32
const BLE_SEQ_EVT_MIN BleSeq = 0xffffff00
const BLE_SEQ_MIN BleSeq = 0
const BLE_SEQ_NONE BleSeq = 0xffffffff
type BleSesn ¶
type BleSesn struct { Ns *NakedSesn // contains filtered or unexported fields }
func (*BleSesn) Filters ¶
func (s *BleSesn) Filters() (nmcoap.TxMsgFilter, nmcoap.RxMsgFilter)
func (*BleSesn) ListenCoap ¶
func (*BleSesn) OpenConnected ¶
func (*BleSesn) SetFilters ¶
func (s *BleSesn) SetFilters(txFilter nmcoap.TxMsgFilter, rxFilter nmcoap.RxMsgFilter)
func (*BleSesn) StopListenCoap ¶
func (s *BleSesn) StopListenCoap(mc nmcoap.MsgCriteria)
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 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 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 BleSyncEvt ¶
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 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 BleWriteAckEvt ¶
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 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 BleXport ¶
type BleXport struct {
// contains filtered or unexported fields
}
Implements xport.Xport.
func NewBleXport ¶
func (*BleXport) AcquireMasterPrimary ¶
func (*BleXport) AcquireMasterSecondary ¶
func (*BleXport) AcquireSlave ¶
func (*BleXport) AddListener ¶
func (bx *BleXport) AddListener(key ListenerKey) (*Listener, error)
func (*BleXport) Advertiser ¶
func (bx *BleXport) Advertiser() *Advertiser
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 (*BleXport) RspTimeout ¶
func (*BleXport) SetMasterSecondary ¶
func (bx *BleXport) SetMasterSecondary(s Preemptable) error
func (*BleXport) SetServices ¶
func (*BleXport) StopWaitingForMasterPrimary ¶
func (*BleXport) StopWaitingForMasterSecondary ¶
func (*BleXport) StopWaitingForSlave ¶
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) SetServices ¶
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 (*Conn) DisconnectChan ¶
func (*Conn) DiscoverSvcs ¶
func (*Conn) ExchangeMtu ¶
func (*Conn) InitiateSecurity ¶
func (*Conn) IsConnected ¶
func (*Conn) ListenForNotifications ¶
func (c *Conn) ListenForNotifications(chr *Characteristic) ( *NotifyListener, error)
func (*Conn) SmInjectIo ¶
func (*Conn) SmIoDemandChan ¶
func (c *Conn) SmIoDemandChan() <-chan SmIoDemand
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 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 ¶
type ListenerKey ¶
type ListenerKey struct { // seq-key only. Seq BleSeq // tch-key only (type-conn-handle). Type MsgType ConnHandle int }
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 (*Master) AcquirePrimary ¶
func (*Master) AcquireSecondary ¶
func (*Master) GetSecondary ¶
func (m *Master) GetSecondary() Preemptable
func (*Master) SetSecondary ¶
func (m *Master) SetSecondary(s Preemptable) error
func (*Master) StopWaitingPrimary ¶
Removes the specified primary from the wait queue.
func (*Master) StopWaitingSecondary ¶
Removes the specified secondary from the wait queue.
type MsgOp ¶
type MsgOp int
func MsgOpFromString ¶
func (MsgOp) MarshalJSON ¶
func (*MsgOp) UnmarshalJSON ¶
type MsgType ¶
type MsgType int
func MsgTypeFromString ¶
func (MsgType) MarshalJSON ¶
func (*MsgType) UnmarshalJSON ¶
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 (*NakedSesn) Filters ¶
func (s *NakedSesn) Filters() (nmcoap.TxMsgFilter, nmcoap.RxMsgFilter)
func (*NakedSesn) ListenCoap ¶
func (*NakedSesn) OpenConnected ¶
func (*NakedSesn) SetFilters ¶
func (s *NakedSesn) SetFilters(txFilter nmcoap.TxMsgFilter, rxFilter nmcoap.RxMsgFilter)
func (*NakedSesn) StopListenCoap ¶
func (s *NakedSesn) StopListenCoap(mc nmcoap.MsgCriteria)
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 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) SetServices ¶
type Receiver ¶
type Receiver struct {
// contains filtered or unexported fields
}
func (*Receiver) AddListener ¶
func (r *Receiver) AddListener(name string, key ListenerKey) ( *Listener, error)
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 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