notecard

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: MIT Imports: 14 Imported by: 2

Documentation

Index

Constants

View Source
const (
	NotecardInterfaceSerial = "serial"
	NotecardInterfaceI2C    = "i2c"
)

Module communication interfaces

View Source
const CardI2CMax = 255

CardI2CMax controls chunk size that's socially appropriate on the I2C bus. It must be 1-255 bytes as per spec

View Source
const CardRequestSegmentDelayMs = 250

CardRequestSegmentDelayMs (golint)

View Source
const CardRequestSegmentMaxLen = 1000

CardRequestSegmentMaxLen (golint)

View Source
const (
	// I2CSlave is the slave device address
	I2CSlave = 0x0703
)
View Source
const ReqCardAUX = "card.aux"

ReqCardAUX (golint)

View Source
const ReqCardAttn = "card.attn"

ReqCardAttn (golint)

View Source
const ReqCardContact = "card.contact"

ReqCardContact (golint)

View Source
const ReqCardIO = "card.io"

ReqCardIO (golint)

View Source
const ReqCardLocation = "card.location"

ReqCardLocation (golint)

View Source
const ReqCardLocationMode = "card.location.mode"

ReqCardLocationMode (golint)

View Source
const ReqCardRestart = "card.restart"

ReqCardRestart (golint)

View Source
const ReqCardRestore = "card.restore"

ReqCardRestore (golint)

View Source
const ReqCardStatus = "card.status"

ReqCardStatus (golint)

View Source
const ReqCardTemp = "card.temp"

ReqCardTemp (golint)

View Source
const ReqCardTime = "card.time"

ReqCardTime (golint)

View Source
const ReqCardUsageGet = "card.usage.get"

ReqCardUsageGet (golint)

View Source
const ReqCardUsageRate = "card.usage.rate"

ReqCardUsageRate (golint)

View Source
const ReqCardUsageTest = "card.usage.test"

ReqCardUsageTest (golint)

View Source
const ReqCardVersion = "card.version"

ReqCardVersion (golint)

View Source
const ReqCardVoltage = "card.voltage"

ReqCardVoltage (golint)

View Source
const ReqDFUGet = "dfu.get"

ReqDFUGet (golint)

View Source
const ReqDFUServiceGet = "dfu.service.get"

ReqDFUServiceGet (golint)

View Source
const ReqDFUStatus = "dfu.status"

ReqDFUStatus (golint)

View Source
const ReqFilesAdd = "files.add"

ReqFilesAdd (golint)

View Source
const ReqFilesDelete = "files.delete"

ReqFilesDelete (golint)

View Source
const ReqFilesGet = "files.get"

ReqFilesGet (golint)

View Source
const ReqFilesSet = "files.set"

ReqFilesSet (golint)

View Source
const ReqFilesStats = "files.stats"

ReqFilesStats (golint)

View Source
const ReqFilesSync = "files.sync"

ReqFilesSync (golint)

View Source
const ReqNoteAdd = "note.add"

ReqNoteAdd (golint)

View Source
const ReqNoteDelete = "note.delete"

ReqNoteDelete (golint)

View Source
const ReqNoteEvent = "note.event"

ReqNoteEvent (golint)

View Source
const ReqNoteGet = "note.get"

ReqNoteGet (golint)

View Source
const ReqNoteTemplate = "note.template"

ReqNoteTemplate (golint)

View Source
const ReqNoteUpdate = "note.update"

ReqNoteUpdate (golint)

View Source
const ReqNotesGet = "notes.get"

ReqNotesGet (golint)

View Source
const ReqServiceEnv = "service.env"

ReqServiceEnv (golint)

View Source
const ReqServiceGet = "service.get"

ReqServiceGet (golint)

View Source
const ReqServiceSet = "service.set"

ReqServiceSet (golint)

View Source
const ReqServiceSignal = "service.signal"

ReqServiceSignal (golint)

View Source
const ReqServiceStatus = "service.status"

ReqServiceStatus (golint)

View Source
const ReqServiceSync = "service.sync"

ReqServiceSync (golint)

View Source
const ReqServiceSyncStatus = "service.sync.status"

ReqServiceSyncStatus (golint)

View Source
const ReqWebGet = "web.get"

ReqWebGet (golint)

View Source
const ReqWebPost = "web.post"

ReqWebPost (golint)

View Source
const ReqWebPut = "web.put"

ReqWebPut (golint)

Variables

This section is empty.

Functions

func I2CDefaults

func I2CDefaults() (port string, portConfig int)

I2CDefaults returns the default serial parameters

func I2CPorts

func I2CPorts() (ports []string, err error)

I2CPorts returns the list of available I2C ports

func NewBody added in v1.1.5

func NewBody() (body map[string]interface{})

NewBody creates a new body. Note that this method is provided merely as syntactic sugar, as of the form body := note.NewBody()

func NewRequest added in v1.1.5

func NewRequest(reqType string) (req map[string]interface{})

NewRequest creates a new request. Note that this method is provided merely as syntactic sugar, as of the form req := note.NewRequest("note.add")

func SerialDefaults

func SerialDefaults() (port string, portConfig int)

SerialDefaults returns the default serial parameters

func SerialPorts

func SerialPorts() (ports []string, err error)

SerialPorts returns the list of available serial ports

Types

type Context

type Context struct {

	// True to emit trace output
	Debug bool

	// Class functions
	PortEnumFn     func() (ports []string, err error)
	PortDefaultsFn func() (port string, portConfig int)
	CloseFn        func(context *Context)
	ResetFn        func(context *Context) (err error)
	TransactionFn  func(context *Context, reqJSON []byte) (rspJSON []byte, err error)
	// contains filtered or unexported fields
}

Context for the port that is open

func Open

func Open(moduleInterface string, port string, portConfig int) (context Context, err error)

Open the card to establish communications

func OpenI2C

func OpenI2C(port string, portConfig int) (context Context, err error)

OpenI2C opens the card on I2C

func OpenSerial

func OpenSerial(port string, portConfig int) (context Context, err error)

OpenSerial opens the card on serial

func (*Context) Close

func (context *Context) Close()

Close the port

func (*Context) DebugOutput added in v1.1.7

func (context *Context) DebugOutput(enabled bool)

DebugOutput enables/disables debug output

func (*Context) EnumPorts

func (context *Context) EnumPorts() (ports []string, err error)

EnumPorts returns the list of all available ports on the specified interface

func (*Context) PortDefaults

func (context *Context) PortDefaults() (port string, portConfig int)

PortDefaults gets the defaults for the specified port

func (*Context) Request

func (context *Context) Request(req map[string]interface{}) (err error)

Request performs a card transaction with a JSON structure and doesn't return a response (This is for semantic compatibility with other languages.)

func (*Context) RequestResponse

func (context *Context) RequestResponse(req map[string]interface{}) (rsp map[string]interface{}, err error)

RequestResponse performs a card transaction with a JSON structure and doesn't return a response (This is for semantic compatibility with other languages.)

func (*Context) Reset

func (context *Context) Reset() (err error)

Reset the port

func (*Context) Trace

func (context *Context) Trace() (err error)

Trace the incoming serial output AND connect the input handler

func (*Context) TraceOutput added in v1.1.7

func (context *Context) TraceOutput(quiescentSecs int, maximumSecs int) (err error)

TraceOutput monitors the trace output for a certain period of time quiescentSecs says "if nonzero, return after N secs of no output activity" maximumSecs says "if nonzero, return after N secs even if output activity is continuing"

func (*Context) Transaction

func (context *Context) Transaction(req map[string]interface{}) (rsp map[string]interface{}, err error)

Transaction performs a card transaction with a JSON structure

func (*Context) TransactionJSON

func (context *Context) TransactionJSON(reqJSON []byte) (rspJSON []byte, err error)

TransactionJSON performs a card transaction using raw JSON []bytes

func (*Context) TransactionRequest

func (context *Context) TransactionRequest(req Request) (rsp Request, err error)

TransactionRequest performs a card transaction with a Req structure

type I2C

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

I2C is the handle to the I2C subsystem

type PinState

type PinState struct {
	High  bool     `json:"high,omitempty"`
	Count []uint32 `json:"count,omitempty"`
}

PinState describes the state of an AUX pin for hardware-related Notecard requests

type Request

type Request struct {
	Req              string                        `json:"req,omitempty"`
	Err              string                        `json:"err,omitempty"`
	RequestID        uint32                        `json:"id,omitempty"`
	NotefileID       string                        `json:"file,omitempty"`
	TrackerID        string                        `json:"tracker,omitempty"`
	NoteID           string                        `json:"note,omitempty"`
	Body             *map[string]interface{}       `json:"body,omitempty"`
	Payload          *[]byte                       `json:"payload,omitempty"`
	Deleted          bool                          `json:"deleted,omitempty"`
	Start            bool                          `json:"start,omitempty"`
	Stop             bool                          `json:"stop,omitempty"`
	Delete           bool                          `json:"delete,omitempty"`
	USB              bool                          `json:"usb,omitempty"`
	Connected        bool                          `json:"connected,omitempty"`
	Secure           bool                          `json:"secure,omitempty"`
	Retry            bool                          `json:"retry,omitempty"`
	Signals          int32                         `json:"signals,omitempty"`
	Max              int32                         `json:"max,omitempty"`
	Changes          int32                         `json:"changes,omitempty"`
	Seconds          int32                         `json:"seconds,omitempty"`
	Minutes          int32                         `json:"minutes,omitempty"`
	Hours            int32                         `json:"hours,omitempty"`
	Days             int32                         `json:"days,omitempty"`
	Result           int32                         `json:"result,omitempty"`
	Port             int32                         `json:"port,omitempty"`
	Status           string                        `json:"status,omitempty"`
	Version          string                        `json:"version,omitempty"`
	Name             string                        `json:"name,omitempty"`
	Org              string                        `json:"org,omitempty"`
	Role             string                        `json:"role,omitempty"`
	Email            string                        `json:"email,omitempty"`
	Area             string                        `json:"area,omitempty"`
	Country          string                        `json:"country,omitempty"`
	Zone             string                        `json:"zone,omitempty"`
	Mode             string                        `json:"mode,omitempty"`
	Host             string                        `json:"host,omitempty"`
	Target           string                        `json:"target,omitempty"`
	ProductUID       string                        `json:"product,omitempty"`
	DeviceUID        string                        `json:"device,omitempty"`
	Route            string                        `json:"route,omitempty"`
	Files            *[]string                     `json:"files,omitempty"`
	FileInfo         *map[string]note.NotefileInfo `json:"info,omitempty"`
	Notes            *map[string]note.Info         `json:"notes,omitempty"`
	Pad              int32                         `json:"pad,omitempty"`
	Storage          int32                         `json:"storage,omitempty"`
	LocationOLC      string                        `json:"olc,omitempty"`
	Latitude         float64                       `json:"lat,omitempty"`
	Longitude        float64                       `json:"lon,omitempty"`
	Value            float64                       `json:"value,omitempty"`
	Wireless         string                        `json:"wireless,omitempty"`
	SN               string                        `json:"sn,omitempty"`
	Text             string                        `json:"text,omitempty"`
	Offset           int32                         `json:"offset,omitempty"`
	Length           int32                         `json:"length,omitempty"`
	Total            int32                         `json:"total,omitempty"`
	BytesSent        uint32                        `json:"bytes_sent,omitempty"`
	BytesReceived    uint32                        `json:"bytes_received,omitempty"`
	NotesSent        uint32                        `json:"notes_sent,omitempty"`
	NotesReceived    uint32                        `json:"notes_received,omitempty"`
	SessionsStandard uint32                        `json:"sessions_standard,omitempty"`
	SessionsSecure   uint32                        `json:"sessions_secure,omitempty"`
	Megabytes        int32                         `json:"megabytes,omitempty"`
	BytesPerDay      int32                         `json:"bytes_per_day,omitempty"`
	DataRate         float64                       `json:"rate,omitempty"`
	NumBytes         int32                         `json:"bytes,omitempty"`
	Template         bool                          `json:"template,omitempty"`
	BodyTemplate     string                        `json:"body_template,omitempty"`
	PayloadTemplate  int32                         `json:"payload_template,omitempty"`
	Allow            bool                          `json:"allow,omitempty"`
	Align            bool                          `json:"align,omitempty"`
	Limit            bool                          `json:"limit,omitempty"`
	ReqTime          bool                          `json:"reqtime,omitempty"`
	ReqLoc           bool                          `json:"reqloc,omitempty"`
	Trace            string                        `json:"trace,omitempty"`
	Usage            *[]string                     `json:"usage,omitempty"`
	State            *[]PinState                   `json:"state,omitempty"`
	Serial           string                        `json:"serial,omitempty"`
	Time             uint32                        `json:"time,omitempty"`
	VMin             float64                       `json:"vmin,omitempty"`
	VMax             float64                       `json:"vmax,omitempty"`
	VAvg             float64                       `json:"vavg,omitempty"`
	Daily            float64                       `json:"daily,omitempty"`
	Weekly           float64                       `json:"weekly,omitempty"`
	Montly           float64                       `json:"monthly,omitempty"`
	Verify           bool                          `json:"verify,omitempty"`
	Set              bool                          `json:"set,omitempty"`
	Calibration      float64                       `json:"calibration,omitempty"`
	Heartbeat        bool                          `json:"heartbeat,omitempty"`
	Threshold        int32                         `json:"threshold,omitempty"`
	Count            uint32                        `json:"count,omitempty"`
}

Request is the core API request/response data structure

Jump to

Keyboard shortcuts

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