Documentation
¶
Index ¶
- Constants
- func Defaults() (moduleInterface string, port string, portConfig int)
- func I2CDefaults() (port string, portConfig int)
- func I2CPorts() (allports []string, usbports []string, notecardports []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() (allports []string, usbports []string, notecardports []string, err error)
- type CardTest
- type Context
- func Open(moduleInterface string, port string, portConfig int) (context Context, err error)
- func OpenI2C(port string, portConfig int) (context Context, err error)
- func OpenRemote(farmURL string, farmCheckoutMins int) (context Context, err error)
- func OpenSerial(port string, portConfig int) (context Context, err error)
- func (context *Context) Close()
- func (context *Context) DebugOutput(enabled bool, pretty bool)
- func (context *Context) EnumPorts() (allports []string, usbports []string, notecardports []string, err error)
- func (context *Context) Identify() (protocol string, port string, portConfig int)
- func (context *Context) Interactive(watch bool, watchLevel int, prompt bool, watchCommand string, ...) (err error)
- func (context *Context) PortDefaults() (port string, portConfig int)
- func (context *Context) Reopen() (err error)
- func (context *Context) ReopenIfRequired() (err error)
- 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) Response() (rsp map[string]interface{}, err error)
- func (context *Context) SetConfig(portConfig int) (err error)
- func (context *Context) Trace() (err error)
- func (context *Context) TraceCapture(toSend string, toEnd string) (captured string, 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 NetInfo
- type PinState
- type RemoteCard
- type RemoteCards
- type Request
- type SyncLogBody
Constants ¶
const ( NotecardInterfaceSerial = "serial" NotecardInterfaceI2C = "i2c" NotecardInterfaceRemote = "remote" )
Module communication interfaces
const CardI2CMax = 253
CardI2CMax controls chunk size that's socially appropriate on the I2C bus. It must be 1-253 bytes as per spec (which allows space for the 2-byte header in a 255-byte read)
const CardRequestSegmentDelayMs = 250
CardRequestSegmentDelayMs (golint)
const CardRequestSegmentMaxLen = 1000
CardRequestSegmentMaxLen (golint)
const (
// I2CSlave is the slave device address
I2CSlave = 0x0703
)
const IoErrorIsRecoverable = true
IoErrorIsRecoverable is a configuration parameter describing library capabilities. Set this to true if the error recovery of the implementation supports re-open. On all implementations tested to date, I can't yet get the close/reopen working the way it does on microcontrollers. For example, on the go serial, I get a nil pointer dereference within the go library. This MAY have soemthing to do with the fact that we don't cleanly implement the shutdown/restart of the inputHandler in trace, in which case that should be fixed. In the meantime, this is disabled.
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 ReqCardLocationTrack = "card.location.track"
ReqCardLocationTrack (golint)
const ReqCardMotion = "card.motion"
ReqCardMotion (golint)
const ReqCardMotionMode = "card.motion.mode"
ReqCardMotionMode (golint)
const ReqCardMotionSync = "card.motion.sync"
ReqCardMotionSync (golint)
const ReqCardMotionTrack = "card.motion.track"
ReqCardMotionTrack (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 ReqCardTrace = "card.trace"
ReqCardTrace (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 ReqCardWireless = "card.wireless"
ReqCardWireless (golint)
const ReqDFUGet = "dfu.get"
ReqDFUGet (golint)
const ReqDFUServiceGet = "dfu.service.get"
ReqDFUServiceGet (golint)
const ReqDFUStatus = "dfu.status"
ReqDFUStatus (golint)
const ReqEnvGet = "env.get"
ReqEnvGet (golint)
const ReqEnvLocation = "env.location"
ReqEnvLocation (golint)
const ReqEnvTime = "env.time"
ReqEnvTime (golint)
const ReqFileAdd = "file.add"
ReqFileAdd (golint)
const ReqFileChanges = "file.changes"
ReqFileChanges (golint)
const ReqFileDelete = "file.delete"
ReqFileDelete (golint)
const ReqFileGetL = "file.get"
ReqFileGetL (golint)
const ReqFileSet = "file.set"
ReqFileSet (golint)
const ReqFileStats = "file.stats"
ReqFileStats (golint)
const ReqFileSync = "file.sync"
ReqFileSync (golint)
const ReqNoteAdd = "note.add"
ReqNoteAdd (golint)
const ReqNoteChanges = "note.changes"
ReqNoteChanges (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 ReqNotesGetL = "notes.get"
ReqNotesGetL (golint)
const ReqServiceEnvL = "service.env"
ReqServiceEnvL (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)
const SyncLogLevelAll = SyncLogLevelProg
SyncLogLevelAll is all events
const SyncLogLevelDetail = 2
SyncLogLevelDetail is major, minor, and detailed events
const SyncLogLevelMajor = 0
SyncLogLevelMajor is just major events
const SyncLogLevelMinor = 1
SyncLogLevelMinor is just major and minor events
const SyncLogLevelNone = -1
SyncLogLevelNone is no events
const SyncLogLevelProg = 3
SyncLogLevelProg is everything plus programmatically-targeted
const SyncLogNotefile = "_synclog.qi"
SyncLogNotefile is the special notefile containing sync log info
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
Types ¶
type CardTest ¶ added in v1.1.16
type CardTest struct {
DeviceUID string `json:"device,omitempty"`
Error string `json:"err,omitempty"`
Status string `json:"status,omitempty"`
Tests string `json:"tests,omitempty"`
FailTest string `json:"fail_test,omitempty"`
FailReason string `json:"fail_reason,omitempty"`
Info string `json:"info,omitempty"`
Board uint32 `json:"board,omitempty"`
Modem string `json:"modem,omitempty"`
ICCID string `json:"iccid,omitempty"`
IMSI string `json:"imsi,omitempty"`
IMEI string `json:"imei,omitempty"`
When int64 `json:"when,omitempty"`
SKU string `json:"sku,omitempty"`
Station string `json:"station,omitempty"`
Operator string `json:"operator,omitempty"`
Check uint32 `json:"check,omitempty"`
// Firmware info
FirmwareOrg string `json:"org,omitempty"`
FirmwareProduct string `json:"product,omitempty"`
FirmwareVersion string `json:"version,omitempty"`
FirmwareMajor uint32 `json:"ver_major,omitempty"`
FirmwareMinor uint32 `json:"ver_minor,omitempty"`
FirmwarePatch uint32 `json:"ver_patch,omitempty"`
FirmwareBuild uint32 `json:"ver_build,omitempty"`
FirmwareBuilt string `json:"built,omitempty"`
}
CardTest is a structure that is returned by the notecard after completing its self-test
type Context ¶
type Context struct {
// True to emit trace output
Debug bool
// Pretty-print trace output JSON
Pretty bool
// Class functions
PortEnumFn func() (allports []string, usbports []string, notecardports []string, err error)
PortDefaultsFn func() (port string, portConfig int)
CloseFn func(context *Context)
ReopenFn func(context *Context) (err error)
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 OpenRemote ¶ added in v1.2.3
OpenRemote opens a remote card
func OpenSerial ¶
OpenSerial opens the card on serial
func (*Context) DebugOutput ¶ added in v1.1.7
DebugOutput enables/disables debug output
func (*Context) EnumPorts ¶
func (context *Context) EnumPorts() (allports []string, usbports []string, notecardports []string, err error)
EnumPorts returns the list of all available ports on the specified interface
func (*Context) Interactive ¶ added in v1.1.21
func (context *Context) Interactive(watch bool, watchLevel int, prompt bool, watchCommand string, quitCommand string) (err error)
Interactive enters interactive request/response mode, disabling trace in case that was the last mode entered
func (*Context) PortDefaults ¶
PortDefaults gets the defaults for the specified port
func (*Context) ReopenIfRequired ¶ added in v1.2.9
ReopenIfRequired reopens the port but only if required
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) Response ¶ added in v1.1.16
Response is used in rare cases where there is a transaction that returns multiple responses
func (*Context) TraceCapture ¶ added in v1.1.14
TraceCapture monitors the trace output until a delimiter is reached It then returns the received output to the caller.
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 NetInfo ¶ added in v1.2.1
type NetInfo struct {
Iccid string `json:"iccid,omitempty"`
IccidExternal string `json:"iccid_external,omitempty"`
Imsi string `json:"imsi,omitempty"`
ImsiExternal string `json:"imsi_external,omitempty"`
Imei string `json:"imei,omitempty"`
ModemFirmware string `json:"modem,omitempty"`
Band string `json:"band,omitempty"`
AccessTechnology string `json:"rat,omitempty"`
// Radio signal strength in dBm, or ModemValueUnknown if it is not
// available from the modem.
RssiRange int32 `json:"rssir,omitempty"`
Rssi int32 `json:"rssi,omitempty"`
// An integer indicating the reference signal received power (RSRP)
Rsrp int32 `json:"rsrp,omitempty"`
// An integer indicating the reference signal received quality (RSRQ)
Rsrq int32 `json:"rsrq,omitempty"`
// An integer indicating relative signal strength in a human-readable way
Bars uint32 `json:"bars,omitempty"`
// An integer indicating the signal to interference plus noise ratio (SINR).
// Logarithmic value of SINR. Values are in 1/5th of a dB. The range is 0-250
// which translates to -20dB - +30dB
Sinr int32 `json:"sinr,omitempty"`
// GSM RxQual, or ModemValueUnknown if it is not available from the modem.
Rxqual int32 `json:"rxqual,omitempty"`
// Device IP address
IP string `json:"ip,omitempty"`
// Device GW address
Gw string `json:"gateway,omitempty"`
// Device APN name
Apn string `json:"apn,omitempty"`
// Location area code (16 bits) or ModemValueUnknown if it is not avail from modem
Lac uint32 `json:"lac,omitempty"`
// Cell ID (28 bits) or ModemValueUnknown if it is not available from the modem.
Cellid uint32 `json:"cid,omitempty"`
// Network info
NetworkBearer int32 `json:"bearer,omitempty"`
Mcc uint32 `json:"mcc,omitempty"`
Mnc uint32 `json:"mnc,omitempty"`
// Overcurrent events
OvercurrentEvents int32 `json:"oc_events,omitempty"`
OvercurrentEventSecs int32 `json:"oc_event_time,omitempty"`
// Modem debug
ModemDebugEvents int32 `json:"modem_test_events,omitempty"`
// When the signal strength fields were last updated
Modified int64 `json:"updated,omitempty"`
}
NetInfo is the composite structure with all networking connection info
type PinState ¶
type PinState struct {
High bool `json:"high,omitempty"`
Low bool `json:"low,omitempty"`
Count []uint32 `json:"count,omitempty"`
}
PinState describes the state of an AUX pin for hardware-related Notecard requests
type RemoteCard ¶ added in v1.2.3
type RemoteCard struct {
Instance string `json:"instance,omitempty"`
Address int `json:"address,omitempty"`
DirectURL string `json:"direct,omitempty"`
ProxyURL string `json:"proxy,omitempty"`
Version string `json:"version,omitempty"`
DeviceUID string `json:"device,omitempty"`
ProductUID string `json:"product,omitempty"`
SN string `json:"sn,omitempty"`
Reservation string `json:"reservation,omitempty"`
Transactions uint32 `json:"transactions,omitempty"`
TransactionTime uint32 `json:"transaction_time,omitempty"`
Refreshed uint32 `json:"refreshed,omitempty"`
}
RemoteCard is the full description of notecards managed by the farm
type RemoteCards ¶ added in v1.2.3
type RemoteCards struct {
Cards []RemoteCard `json:"notecards,omitempty"`
}
RemoteCards are the objects that get published
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"`
Unsecure bool `json:"unsecure,omitempty"`
Alert bool `json:"alert,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"`
SecondsV string `json:"vseconds,omitempty"`
Minutes int32 `json:"minutes,omitempty"`
MinutesV string `json:"vminutes,omitempty"`
Hours int32 `json:"hours,omitempty"`
HoursV string `json:"vhours,omitempty"`
Days int32 `json:"days,omitempty"`
Result int32 `json:"result,omitempty"`
I2C int32 `json:"i2c,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"`
Movements string `json:"movements,omitempty"`
ProductUID string `json:"product,omitempty"`
DeviceUID string `json:"device,omitempty"`
RouteUID 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"`
ValueV string `json:"vvalue,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"`
Time int64 `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"`
Reset bool `json:"reset,omitempty"`
Calibration float64 `json:"calibration,omitempty"`
Heartbeat bool `json:"heartbeat,omitempty"`
Threshold int32 `json:"threshold,omitempty"`
Count uint32 `json:"count,omitempty"`
Sync bool `json:"sync,omitempty"`
Live bool `json:"live,omitempty"`
Type int32 `json:"type,omitempty"`
Number int64 `json:"number,omitempty"`
SKU string `json:"sku,omitempty"`
Net *NetInfo `json:"net,omitempty"`
Sensitivity int32 `json:"sensitivity,omitempty"`
Requested int32 `json:"requested,omitempty"`
Completed int32 `json:"completed,omitempty"`
}
Request is the core API request/response data structure
type SyncLogBody ¶ added in v1.1.21
type SyncLogBody struct {
TimeSecs int64 `json:"time,omitempty"`
BootMs int64 `json:"sequence,omitempty"`
DetailLevel uint32 `json:"level,omitempty"`
Subsystem string `json:"subsystem,omitempty"`
Text string `json:"text,omitempty"`
}
SyncLogBody is the data structure used in the SyncLogNotefile