notecard

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: MIT Imports: 13 Imported by: 2

Documentation

Index

Constants

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

Module communication interfaces

View Source
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)

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 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.

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 ReqCardMotion = "card.motion"

ReqCardMotion (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 ReqCardWireless = "card.wireless"

ReqCardWireless (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 ReqEnvGet = "env.get"

ReqEnvGet (golint)

View Source
const ReqEnvLocation = "env.location"

ReqEnvLocation (golint)

View Source
const ReqEnvTime = "env.time"

ReqEnvTime (golint)

View Source
const ReqFileAdd = "file.add"

ReqFileAdd (golint)

View Source
const ReqFileChanges = "file.changes"

ReqFileChanges (golint)

View Source
const ReqFileDelete = "file.delete"

ReqFileDelete (golint)

View Source
const ReqFileGetL = "file.get"

ReqFileGetL (golint)

View Source
const ReqFileSet = "file.set"

ReqFileSet (golint)

View Source
const ReqFileStats = "file.stats"

ReqFileStats (golint)

View Source
const ReqFileSync = "file.sync"

ReqFileSync (golint)

View Source
const ReqNoteAdd = "note.add"

ReqNoteAdd (golint)

View Source
const ReqNoteChanges = "note.changes"

ReqNoteChanges (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 ReqNotesGetL = "notes.get"

ReqNotesGetL (golint)

View Source
const ReqServiceEnvL = "service.env"

ReqServiceEnvL (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)

View Source
const SyncLogLevelAll = SyncLogLevelProg

SyncLogLevelAll is all events

View Source
const SyncLogLevelDetail = 2

SyncLogLevelDetail is major, minor, and detailed events

View Source
const SyncLogLevelMajor = 0

SyncLogLevelMajor is just major events

View Source
const SyncLogLevelMinor = 1

SyncLogLevelMinor is just major and minor events

View Source
const SyncLogLevelProg = 3

SyncLogLevelProg is everything plus programmatically-targeted

Variables

This section is empty.

Functions

func Defaults added in v1.1.16

func Defaults() (moduleInterface string, port string, portConfig int)

Defaults gets the default interface, port, and config

func I2CDefaults

func I2CDefaults() (port string, portConfig int)

I2CDefaults returns the default serial parameters

func I2CPorts

func I2CPorts() (allports []string, usbports []string, notecardports []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() (allports []string, usbports []string, notecardports []string, err error)

SerialPorts returns the list of available serial ports

Types

type CardTest added in v1.1.16

type CardTest struct {
	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 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, pretty bool)

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) Identify added in v1.1.10

func (context *Context) Identify() (protocol string, port string, portConfig int)

Identify this Notecard connection

func (*Context) Interactive added in v1.1.21

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

Interactive enters interactive request/response mode, disabling trace in case that was the last mode entered

func (*Context) PortDefaults

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

PortDefaults gets the defaults for the specified port

func (*Context) Reopen added in v1.1.10

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

Reopen the 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) Response added in v1.1.16

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

Response is used in rare cases where there is a transaction that returns multiple responses

func (*Context) SetConfig added in v1.2.0

func (context *Context) SetConfig(portConfig int) (err error)

SetConfig sets port config on the open port

func (*Context) Trace

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

Trace the incoming serial output AND connect the input handler

func (*Context) TraceCapture added in v1.1.14

func (context *Context) TraceCapture(toSend string, toEnd string) (captured string, err error)

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

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 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 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"`
	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"`
	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"`
	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"`
	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"`
	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"`
	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"`
}

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 pseudo-notefile "_synclog.qi"

Jump to

Keyboard shortcuts

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