Documentation
¶
Index ¶
- Constants
- func GetSysAttr(connHandle ble.Handle, data []byte, flags SysAttrFlags) (int, error)
- func HVX(connHandle ble.Handle, params *HVXParams, data ...byte) (int, error)
- func SetSysAttr(connHandle ble.Handle, data []byte, flags SysAttrFlags) error
- type Attr
- type AttrMeta
- type AttrOptions
- type CharHandles
- type CharMeta
- type CharPF
- type Error
- type HVXParams
- type Handle
- type Op
- type ServiceType
- type SysAttrFlags
- type Write
Constants ¶
View Source
const ( EvtBase = 0x50 EvtLast = 0x6F )
View Source
const ( EvtWrite = EvtBase + 0 // write operation performed EvtRWAuthorizeReq = EvtBase + 1 // read/write authorization request EvtSysAttrMissing = EvtBase + 2 // persistent sys. attr. access is pending EvtHVC = EvtBase + 3 // handle value confirmation EvtSCConfirm = EvtBase + 4 // service changed confirmation EvtExchangeMTUReq = EvtBase + 5 // exchange MTU request EvtTimeout = EvtBase + 6 // peer failed to resp. to ATT req. in time EvtHVNTxComplete = EvtBase + 7 // handle val. notification Tx complete )
View Source
const ErrorBase = ble.ErrorBase + 0x400
Variables ¶
This section is empty.
Functions ¶
func GetSysAttr ¶
GetSysAttr retrieves the persistent system attributes.
func HVX ¶
HVX handles value notification or indication. If len(data) != 0 the attribute will be updated before sending the notification or indication. HVX returns the number of bytes written to attribute.
func SetSysAttr ¶
func SetSysAttr(connHandle ble.Handle, data []byte, flags SysAttrFlags) error
SetSysAttr sets the persistent system attributes for a connection.
Types ¶
type Attr ¶
type Attr struct { UUID *ble.UUID // attribute UUID. Meta *AttrMeta // metadata InitLen uint16 // initial attribute value length in bytes InitOffs uint16 // initial attribute value offset in bytes MaxLen uint16 // maximum attribute value length in bytes Value *byte // pointer to the attribute data }
type AttrMeta ¶
type AttrMeta struct { ReadPerm gap.ConnSecMode WritePerm gap.ConnSecMode Options AttrOptions }
type AttrOptions ¶
type AttrOptions uint8
const ( VLenAttr AttrOptions = 1 << 0 // variable length attribute ValLoc AttrOptions = 3 << 1 // attribute value location ValStack AttrOptions = 1 << 1 // attr. value located in stack memory ValUser AttrOptions = 2 << 1 // attr. value located in user memory ReadAuth AttrOptions = 1 << 3 // authoriz. requested on every read WriteAuth AttrOptions = 1 << 4 // authoriz. requested on every write )
type CharHandles ¶
type CharHandles struct { Value Handle // handle to the characteristic value. UserDesc Handle // handle to the user description descriptor CCCD Handle // handle to the client char. conf. descriptor SCCD Handle // handle to the server char. conf. descriptor }
func AddCharacteristic ¶
func AddCharacteristic(service Handle, charMeta *CharMeta, charVal *Attr) (handles CharHandles, err error)
type CharMeta ¶
type CharMeta struct { Props gatt.CharProps // characteristic properties ExtProps gatt.CharExtProps // characteristic extended properties. UserDesc *byte // pointer to a UTF-8 encoded string UserDescMaxSize uint16 UserDescSize uint16 PF *CharPF // presentation format (CPF descriptor) UserDescMeta *AttrMeta // user description descriptor metadata CCCDMeta *AttrMeta // client char. conf. descriptor metadeta SCCDMeta *AttrMeta // server char. conf. descriptor metadata }
type Handle ¶
type Handle uint16
func AddService ¶
func AddService(typ ServiceType, uuid *ble.UUID) (h Handle, err error)
AddService adds a service.
type Op ¶
type Op uint8
const ( OpInvalid Op = 0 // invalid operation OpWriteReq Op = 1 // write request OpWriteCmd Op = 2 // write command OpSignWriteCmd Op = 3 // signed write command OpPrepWriteReq Op = 4 // prepare write request OpExecWriteReqCancel Op = 5 // cancel all prepared writes OpExecWriteReqNow Op = 6 // immediately execute all prepared writes )
type ServiceType ¶
type ServiceType uint8
const ( InvalidService ServiceType = 0 PrimaryService ServiceType = 1 SecondaryService ServiceType = 2 )
type SysAttrFlags ¶
type SysAttrFlags uint32
const ( SysAttrSys SysAttrFlags = 1 << 0 // restrict system attributes to system services SysAttrUsr SysAttrFlags = 1 << 1 // restrict system attributes to user services )
type Write ¶
Click to show internal directories.
Click to hide internal directories.