Documentation
¶
Index ¶
- Constants
- func I2CDefaults() (port string, portConfig int)
- func I2CPorts() (ports []string, err error)
- func NewBody() (body map[string]interface{})
- func NewRequest(reqType string) (req map[string]interface{})
- func SerialDefaults() (port string, portConfig int)
- func SerialPorts() (ports []string, err error)
- type Context
- func (context *Context) Close()
- func (context *Context) DebugOutput(enabled bool)
- func (context *Context) EnumPorts() (ports []string, err error)
- func (context *Context) PortDefaults() (port string, portConfig int)
- func (context *Context) Request(req map[string]interface{}) (err error)
- func (context *Context) RequestResponse(req map[string]interface{}) (rsp map[string]interface{}, err error)
- func (context *Context) Reset() (err error)
- func (context *Context) Trace() (err error)
- func (context *Context) TraceOutput(quiescentSecs int, maximumSecs int) (err error)
- func (context *Context) Transaction(req map[string]interface{}) (rsp map[string]interface{}, err error)
- func (context *Context) TransactionJSON(reqJSON []byte) (rspJSON []byte, err error)
- func (context *Context) TransactionRequest(req Request) (rsp Request, err error)
- type I2C
- type PinState
- type Request
Constants ¶
const ( NotecardInterfaceSerial = "serial" NotecardInterfaceI2C = "i2c" )
Module communication interfaces
const CardI2CMax = 255
CardI2CMax controls chunk size that's socially appropriate on the I2C bus. It must be 1-255 bytes as per spec
const CardRequestSegmentDelayMs = 250
CardRequestSegmentDelayMs (golint)
const CardRequestSegmentMaxLen = 1000
CardRequestSegmentMaxLen (golint)
const (
// I2CSlave is the slave device address
I2CSlave = 0x0703
)
const ReqCardAUX = "card.aux"
ReqCardAUX (golint)
const ReqCardAttn = "card.attn"
ReqCardAttn (golint)
const ReqCardContact = "card.contact"
ReqCardContact (golint)
const ReqCardIO = "card.io"
ReqCardIO (golint)
const ReqCardLocation = "card.location"
ReqCardLocation (golint)
const ReqCardLocationMode = "card.location.mode"
ReqCardLocationMode (golint)
const ReqCardRestart = "card.restart"
ReqCardRestart (golint)
const ReqCardRestore = "card.restore"
ReqCardRestore (golint)
const ReqCardStatus = "card.status"
ReqCardStatus (golint)
const ReqCardTemp = "card.temp"
ReqCardTemp (golint)
const ReqCardTime = "card.time"
ReqCardTime (golint)
const ReqCardUsageGet = "card.usage.get"
ReqCardUsageGet (golint)
const ReqCardUsageRate = "card.usage.rate"
ReqCardUsageRate (golint)
const ReqCardUsageTest = "card.usage.test"
ReqCardUsageTest (golint)
const ReqCardVersion = "card.version"
ReqCardVersion (golint)
const ReqCardVoltage = "card.voltage"
ReqCardVoltage (golint)
const ReqDFUGet = "dfu.get"
ReqDFUGet (golint)
const ReqDFUServiceGet = "dfu.service.get"
ReqDFUServiceGet (golint)
const ReqDFUStatus = "dfu.status"
ReqDFUStatus (golint)
const ReqFilesAdd = "files.add"
ReqFilesAdd (golint)
const ReqFilesDelete = "files.delete"
ReqFilesDelete (golint)
const ReqFilesGet = "files.get"
ReqFilesGet (golint)
const ReqFilesSet = "files.set"
ReqFilesSet (golint)
const ReqFilesStats = "files.stats"
ReqFilesStats (golint)
const ReqFilesSync = "files.sync"
ReqFilesSync (golint)
const ReqNoteAdd = "note.add"
ReqNoteAdd (golint)
const ReqNoteDelete = "note.delete"
ReqNoteDelete (golint)
const ReqNoteEvent = "note.event"
ReqNoteEvent (golint)
const ReqNoteGet = "note.get"
ReqNoteGet (golint)
const ReqNoteTemplate = "note.template"
ReqNoteTemplate (golint)
const ReqNoteUpdate = "note.update"
ReqNoteUpdate (golint)
const ReqNotesGet = "notes.get"
ReqNotesGet (golint)
const ReqServiceEnv = "service.env"
ReqServiceEnv (golint)
const ReqServiceGet = "service.get"
ReqServiceGet (golint)
const ReqServiceSet = "service.set"
ReqServiceSet (golint)
const ReqServiceSignal = "service.signal"
ReqServiceSignal (golint)
const ReqServiceStatus = "service.status"
ReqServiceStatus (golint)
const ReqServiceSync = "service.sync"
ReqServiceSync (golint)
const ReqServiceSyncStatus = "service.sync.status"
ReqServiceSyncStatus (golint)
const ReqWebGet = "web.get"
ReqWebGet (golint)
const ReqWebPost = "web.post"
ReqWebPost (golint)
const ReqWebPut = "web.put"
ReqWebPut (golint)
Variables ¶
This section is empty.
Functions ¶
func I2CDefaults ¶
I2CDefaults returns the default serial parameters
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
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 ¶
SerialDefaults returns the default serial parameters
func SerialPorts ¶
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 OpenSerial ¶
OpenSerial opens the card on serial
func (*Context) DebugOutput ¶ added in v1.1.7
DebugOutput enables/disables debug output
func (*Context) EnumPorts ¶
EnumPorts returns the list of all available ports on the specified interface
func (*Context) PortDefaults ¶
PortDefaults gets the defaults for the specified port
func (*Context) Request ¶
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) TraceOutput ¶ added in v1.1.7
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 ¶
TransactionJSON performs a card transaction using raw JSON []bytes
type I2C ¶
type I2C struct {
// contains filtered or unexported fields
}
I2C is the handle to the I2C subsystem
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