sesn

package
v0.0.0-...-0602f2a Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteResource

func DeleteResource(s Sesn, resType ResourceType, uri string,
	o TxOptions) (coap.COAPCode, []byte, error)

func GetResource

func GetResource(s Sesn, resType ResourceType, uri string, o TxOptions) (
	coap.COAPCode, []byte, error)

func PostResource

func PostResource(s Sesn, resType ResourceType, uri string,
	value []byte, o TxOptions) (coap.COAPCode, []byte, error)

func PutCborResource

func PutCborResource(s Sesn, resType ResourceType, uri string,
	value map[string]interface{},
	o TxOptions) (coap.COAPCode, map[string]interface{}, error)

func PutResource

func PutResource(s Sesn, resType ResourceType, uri string,
	value []byte, o TxOptions) (coap.COAPCode, []byte, error)

func TxNmp

func TxNmp(s Sesn, m *nmp.NmpMsg, o TxOptions) (nmp.NmpRsp, error)

Types

type MgmtProto

type MgmtProto int
const (
	MGMT_PROTO_NMP MgmtProto = iota
	MGMT_PROTO_OMP
)

type OnCloseFn

type OnCloseFn func(s Sesn, err error)

type PeerSpec

type PeerSpec struct {
	Ble bledefs.BleDev
	Udp string
}

type ResourceType

type ResourceType int
const (
	RES_TYPE_PUBLIC ResourceType = iota
	RES_TYPE_UNAUTH
	RES_TYPE_SECURE
)

func ParseResType

func ParseResType(s string) (ResourceType, error)

func (ResourceType) String

func (r ResourceType) String() string

type Sesn

type Sesn interface {

	// Initiates communication with the peer.  For connection-oriented
	// transports, this creates a connection.
	// Returns:
	//     * nil: success.
	//     * nmxutil.SesnAlreadyOpenError: session already open.
	//     * other error
	Open() error

	// Ends communication with the peer.  For connection-oriented transports,
	// this closes the connection.
	//     * nil: success.
	//     * nmxutil.SesnClosedError: session not open.
	//     * other error
	Close() error

	// Indicates whether the session is currently open.
	IsOpen() bool

	// Retrieves the maximum data payload for incoming data packets.
	MtuIn() int

	// Retrieves the maximum data payload for outgoing data packets.
	MtuOut() int

	MgmtProto() MgmtProto

	// Indicates whether the session uses the TCP form of CoAP.
	CoapIsTcp() bool

	// Stops a receive operation in progress.  This must be called from a
	// separate thread, as sesn receive operations are blocking.
	AbortRx(nmpSeq uint8) error

	// Performs a blocking transmit a single NMP message and listens for the
	// response.
	//     * nil: success.
	//     * nmxutil.SesnClosedError: session not open.
	//     * other error
	TxNmpOnce(m *nmp.NmpMsg, opt TxOptions) (nmp.NmpRsp, error)

	TxCoapOnce(m coap.Message, resType ResourceType,
		opt TxOptions) (coap.COAPCode, []byte, error)
}

Represents a communication session with a specific peer. The particulars vary according to protocol and transport. Several Sesn instances can use the same Xport.

type SesnCfg

type SesnCfg struct {
	// General configuration.
	MgmtProto MgmtProto
	PeerSpec  PeerSpec
	OnCloseCb OnCloseFn

	// Transport-specific configuration.
	Ble SesnCfgBle
}

func NewSesnCfg

func NewSesnCfg() SesnCfg

type SesnCfgBle

type SesnCfgBle struct {
	// General configuration.
	OwnAddrType  bledefs.BleAddrType
	EncryptWhen  bledefs.BleEncryptWhen
	CloseTimeout time.Duration
	WriteRsp     bool

	// Central configuration.
	Central SesnCfgBleCentral
}

type SesnCfgBleCentral

type SesnCfgBleCentral struct {
	ConnTries   int
	ConnTimeout time.Duration
}

type TxOptions

type TxOptions struct {
	Timeout time.Duration
	Tries   int
}

func NewTxOptions

func NewTxOptions() TxOptions

func (*TxOptions) AfterTimeout

func (opt *TxOptions) AfterTimeout() <-chan time.Time

Jump to

Keyboard shortcuts

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