Documentation ¶
Overview ¶
Package notelib cert.go contains certificates
Package notelib config.go is where package-wide constants and vars are defined ¶
Package notelib debug.go contains things that assist in debugging ¶
Package notelib discover.go is the notehub discovery handling support ¶
Package notelib err.go contains things that assist in error handling ¶
Package notelib file.go is a 'storage driver' for a standard hierarchical file system
Package notelib fileio.go is the lowest level I/O driver underlying the file transport
Package notelib hubreq.go is the service-side complement to the Notehub client-side package ¶
Package notelib notefile.go handles management and sync of collections of individual notes ¶
Package notelib notebox.go deals with the handling of the sync'ed container of a set of related notefiles
Package notelib notefile.go handles management and sync of collections of individual notes ¶
Package notelib notehub-defs contains device-hub RPC protocol definitions ¶
Package notelib notelib.go has certain internal definitions, placed here so that they parallel the clang version.
Package notelib storage.go is the class definition for storage drivers ¶
Package notelib wire.go handles all conversions between the RPC's req/rsp structure and compressed on-wire formats
Index ¶
- Constants
- Variables
- func Checkpoint(ctx context.Context) (err error)
- func CheckpointNoteboxIfNeeded(ctx context.Context, localEndpointID string, boxLocalStorage string) error
- func CreateNotebox(ctx context.Context, endpointID string, boxStorage string) (err error)
- func DebugSet(which string, value string)
- func Delete(ctx context.Context, boxStorage string) (err error)
- func ErrorContains(err error, errKeyword string) bool
- func ErrorResponse(err error) (response []byte)
- func ErrorString(err error) string
- func FileCleanName(filename string) string
- func FileDefaultStorageObject() string
- func FileSetHandler(newfio *Fileio)
- func FileSetStorageLocation(root string)
- func FileStorageObject(containerName string) string
- func GetNotecardSecureElementRootCertificateAsPEM() (cert []byte)
- func HubCheckpointRequest() (message []byte, err error)
- func HubDiscover(deviceUID string, deviceSN string, productUID string) (hubSessionTicket string, hubEndpointID string, appUID string, ...)
- func HubErrorResponse(ctx context.Context, session *HubSession, errorMessage string) (result []byte)
- func HubRequest(ctx context.Context, content []byte, event EventFunc, session *HubSession) (reqtype string, result []byte, suppress bool, err error)
- func HubSetAccessControl(fn NoteboxAccessFunc)
- func HubSetDeviceNotifications(fn GetNotificationFunc)
- func HubSetDiscover(fn DiscoverFunc)
- func HubSetReadFile(fn ReadFileFunc)
- func HubSetSignal(fn SignalFunc)
- func HubSetUpdateEnvironment(ctx context.Context, fn NoteboxUpdateEnvFunc)
- func HubSetWebRequest(fn WebRequestFunc)
- func InitLogging(debugFunc LogFunc, infoFunc LogFunc, warnFunc LogFunc, errorFunc LogFunc)
- func Merge(localNote *note.Note, incomingNote *note.Note) note.Note
- func NotefileAttributesFromID(notefileID string) (isQueue bool, syncToHub bool, syncFromHub bool, secure bool, reserved bool, ...)
- func NotefileIDIsReserved(notefileID string) bool
- func NotefileIDIsReservedWithExceptions(notefileID string) bool
- func OLCFromINT64(code int64) (olc string)
- func OLCToINT64(olc string) (result int64)
- func PacketHeaderFromWire(wire []byte) (cid []byte, packetFlags byte, dataOffset int, err error)
- func Purge(ctx context.Context) error
- func SetTLSSupport(enabled bool)
- func TLSSupport() bool
- func TimeZoneNameToNumber(name string) int
- func TimeZoneNumberToCountry(num int) string
- func TimeZoneNumberToName(num int) string
- func WireBarsFromSession(session *HubSession) (rat string, bars uint32)
- func WireExtractSessionContext(wire []byte, session *HubSession) (suppressResponse bool, err error)
- func WireReadRequest(conn net.Conn, waitIndefinitely bool) (bytesRead uint32, request []byte, err error)
- type BulkBody
- type BulkTemplateContext
- func (tmplContext *BulkTemplateContext) BulkDecodeNextEntry() (body map[string]interface{}, payload []byte, when int64, wherewhen int64, ...)
- func (tmplContext *BulkTemplateContext) BulkEncodeNextEntry(body map[string]interface{}, payload []byte, when int64, wherewhen int64, ...) (output []byte, err error)
- type DiscoverFunc
- type DiscoverInfo
- type EventFunc
- type Fileio
- type FileioCreateFunc
- type FileioDeleteFunc
- type FileioExistsFunc
- type FileioReadJSONFunc
- type FileioWriteJSONFunc
- type Float16
- type GetNotificationFunc
- type HubSession
- func (session HubSession) LogDebug(ctx context.Context, format string, args ...interface{})
- func (session HubSession) LogError(ctx context.Context, format string, args ...interface{})
- func (session HubSession) LogInfo(ctx context.Context, format string, args ...interface{})
- func (session HubSession) LogWarn(ctx context.Context, format string, args ...interface{})
- type LogFunc
- type Node
- type Notebox
- func (box *Notebox) AddNote(ctx context.Context, endpointID string, notefileID string, noteID string, ...) (err error)
- func (box *Notebox) AddNoteWithHistory(ctx context.Context, endpointID string, notefileID string, noteID string, ...) (err error)
- func (box *Notebox) AddNotefile(ctx context.Context, notefileID string, notefileInfo *note.NotefileInfo) error
- func (box *Notebox) Checkpoint(ctx context.Context) (err error)
- func (box *Notebox) CheckpointNotefile(ctx context.Context, notefileID string) (err error)
- func (box *Notebox) ClearAllTrackers(ctx context.Context, endpointID string)
- func (box *Notebox) Close(ctx context.Context) (err error)
- func (box *Notebox) ConvertToJSON(fIndent bool) (output []byte, err error)
- func (box *Notebox) CreateNotefile(isQueue bool) *Notefile
- func (box *Notebox) DeleteNote(ctx context.Context, endpointID string, notefileID string, noteID string) (err error)
- func (box *Notebox) DeleteNotefile(ctx context.Context, notefileID string) (err error)
- func (box *Notebox) EndpointID() string
- func (box *Notebox) GetChangedNotefiles(ctx context.Context, endpointID string) (changedNotefiles []string)
- func (box *Notebox) GetChanges(endpointID string, maxBatchSize int) (file *Notefile, numChanges int, totalChanges int, totalNotes int, since int64, ...)
- func (box *Notebox) GetEventInfo() (deviceUID string, deviceSN string, productUID string)
- func (box *Notebox) GetNote(ctx context.Context, notefileID string, noteID string) (note note.Note, err error)
- func (box *Notebox) GetNotefileInfo(notefileID string) (notefileInfo note.NotefileInfo, err error)
- func (box *Notebox) MergeNotebox(ctx context.Context, fromBoxfile *Notefile) (err error)
- func (box *Notebox) NoteboxNotefileInfo() (allInfo []NoteboxNotefileInfo)
- func (box *Notebox) Notefile() *Notefile
- func (box *Notebox) NotefileExists(notefileID string) (present bool)
- func (box *Notebox) Notefiles(includeTombstones bool) (notefiles []string)
- func (box *Notebox) OpenNotefile(ctx context.Context, notefileID string) (iOpenfile *OpenNotefile, notefile *Notefile, err error)
- func (box *Notebox) Openfile() *OpenNotefile
- func (box *Notebox) Request(ctx context.Context, endpointID string, reqJSON []byte) (rspJSON []byte)
- func (box *Notebox) SetClientInfo(httpReq *http.Request, httpRsp http.ResponseWriter)
- func (box *Notebox) SetEventInfo(deviceUID string, deviceSN string, productUID string, appUID string, ...)
- func (box *Notebox) SetNotefileInfo(notefileID string, notefileInfo note.NotefileInfo) (err error)
- func (box *Notebox) UpdateChangeTracker(endpointID string, since int64, until int64) error
- func (box *Notebox) UpdateNote(ctx context.Context, endpointID string, notefileID string, noteID string, ...) (err error)
- func (box *Notebox) VerifyAccess(resource string, actions string) (err error)
- type NoteboxAccessFunc
- type NoteboxInstance
- type NoteboxNotefileInfo
- type NoteboxUpdateEnvFunc
- type Notefile
- func (nf *Notefile) AddNote(endpointID string, noteID string, xnote note.Note) (newNoteID string, err error)
- func (nf *Notefile) AddNoteWithHistory(endpointID string, noteID string, xnote note.Note) (newNoteID string, err error)
- func (nf *Notefile) AddTracker(trackerID string) error
- func (nf *Notefile) AllNotes(includeTombstones bool) (notes map[string]note.Note)
- func (nf *Notefile) AreChanges(trackerID string) (areChanges bool, err error)
- func (nf *Notefile) ClearTracker(trackerID string)
- func (nf *Notefile) Close()
- func (nf *Notefile) ConvertToJSON(indent bool) (output []byte, err error)
- func (nf *Notefile) CountNotes(includeTombstones bool) (count int)
- func (nf *Notefile) DeleteNote(endpointID string, noteID string) error
- func (nf *Notefile) DeleteTracker(trackerID string) error
- func (nf *Notefile) GetChanges(endpointID string, includeTombstones bool, maxBatchSize int) (chgfile *Notefile, numChanges int, totalChanges int, totalNotes int, ...)
- func (nf *Notefile) GetEventInfo() (deviceUID string, deviceSN string, productUID string, appUID string, ...)
- func (nf *Notefile) GetLeastRecentNoteID() (noteID string, err error)
- func (nf *Notefile) GetNote(noteID string) (xnote note.Note, err error)
- func (nf *Notefile) GetTrackers() []string
- func (nf *Notefile) Info() (info note.NotefileInfo)
- func (nf *Notefile) InternalizePayload(xp []byte) (err error)
- func (nf *Notefile) IsTracker(trackerID string) (isTracker bool)
- func (nf *Notefile) MarkAsModified(reason string)
- func (nf *Notefile) MergeNotefile(fromNotefile *Notefile) error
- func (nf *Notefile) Modified() int
- func (nf *Notefile) NewNoteID(endpointID string) string
- func (nf *Notefile) NoteIDs(includeTombstones bool) (noteIDs []string)
- func (nf *Notefile) Notefile() (notefileID string)
- func (nf *Notefile) PurgeTombstones(ignoreEndpointID string)
- func (nf *Notefile) ResolveNoteConflicts(endpointID string, noteID string, xnote note.Note) error
- func (nf *Notefile) SetEventInfo(deviceUID string, deviceSN string, productUID string, appUID string, ...)
- func (nf *Notefile) SetNoteWhen(noteID string, when int64) (success bool)
- func (nf *Notefile) UpdateChangeTracker(endpointID string, since int64, until int64) (err error)
- func (nf *Notefile) UpdateNote(endpointID string, noteID string, xnote note.Note) error
- type NotehubPB
- func (*NotehubPB) Descriptor() ([]byte, []int)deprecated
- func (x *NotehubPB) GetBytes1() int64
- func (x *NotehubPB) GetBytes2() int64
- func (x *NotehubPB) GetBytes3() int64
- func (x *NotehubPB) GetBytes4() int64
- func (x *NotehubPB) GetCellID() string
- func (x *NotehubPB) GetContinuousSession() bool
- func (x *NotehubPB) GetDeviceEndpointID() string
- func (x *NotehubPB) GetDeviceFirmware() int64
- func (x *NotehubPB) GetDeviceOrderingCode() string
- func (x *NotehubPB) GetDevicePIN() string
- func (x *NotehubPB) GetDeviceSKU() string
- func (x *NotehubPB) GetDeviceSN() string
- func (x *NotehubPB) GetDeviceUID() string
- func (x *NotehubPB) GetError() string
- func (x *NotehubPB) GetHighPowerCyclesData() uint32
- func (x *NotehubPB) GetHighPowerCyclesGPS() uint32
- func (x *NotehubPB) GetHighPowerCyclesTotal() uint32
- func (x *NotehubPB) GetHighPowerSecsData() uint32
- func (x *NotehubPB) GetHighPowerSecsGPS() uint32
- func (x *NotehubPB) GetHighPowerSecsTotal() uint32
- func (x *NotehubPB) GetHubEndpointID() string
- func (x *NotehubPB) GetHubPacketHandler() string
- func (x *NotehubPB) GetHubSessionFactoryResetID() string
- func (x *NotehubPB) GetHubSessionHandler() string
- func (x *NotehubPB) GetHubSessionTicket() string
- func (x *NotehubPB) GetHubSessionTicketExpiresTimeSec() int64
- func (x *NotehubPB) GetHubTimeNs() int64
- func (x *NotehubPB) GetMaxChanges() int64
- func (x *NotehubPB) GetMessageType() string
- func (x *NotehubPB) GetMotionOrientation() string
- func (x *NotehubPB) GetMotionSecs() int64
- func (x *NotehubPB) GetNoteID() string
- func (x *NotehubPB) GetNotefileID() string
- func (x *NotehubPB) GetNotefileIDs() string
- func (x *NotehubPB) GetNotificationSession() bool
- func (x *NotehubPB) GetProductUID() string
- func (x *NotehubPB) GetSessionIDMismatch() bool
- func (x *NotehubPB) GetSessionIDNext() int64
- func (x *NotehubPB) GetSessionIDPrev() int64
- func (x *NotehubPB) GetSessionTrigger() string
- func (x *NotehubPB) GetSince() int64
- func (x *NotehubPB) GetSuppressResponse() bool
- func (x *NotehubPB) GetTemp100() int32
- func (x *NotehubPB) GetTemp1000() int32
- func (x *NotehubPB) GetUntil() int64
- func (x *NotehubPB) GetUsageProvisioned() int64
- func (x *NotehubPB) GetUsageRcvdBytes() uint32
- func (x *NotehubPB) GetUsageRcvdBytesSecondary() uint32
- func (x *NotehubPB) GetUsageRcvdNotes() uint32
- func (x *NotehubPB) GetUsageSentBytes() uint32
- func (x *NotehubPB) GetUsageSentBytesSecondary() uint32
- func (x *NotehubPB) GetUsageSentNotes() uint32
- func (x *NotehubPB) GetUsageTCPSessions() uint32
- func (x *NotehubPB) GetUsageTLSSessions() uint32
- func (x *NotehubPB) GetVersion() int64
- func (x *NotehubPB) GetVoltage100() int32
- func (x *NotehubPB) GetVoltage1000() int32
- func (x *NotehubPB) GetWhere() string
- func (x *NotehubPB) GetWhereWhen() int64
- func (*NotehubPB) ProtoMessage()
- func (x *NotehubPB) ProtoReflect() protoreflect.Message
- func (x *NotehubPB) Reset()
- func (x *NotehubPB) String() string
- type OpenNotefile
- type Packet
- type PacketHandler
- type PacketHandlerNotecard
- type PacketHandlerNotehub
- type Precision
- type ReadFileFunc
- type SignalFunc
- type SmazzContext
- type TimeZoneNames
- type Tracker
- type Trie
- type WebRequestFunc
Constants ¶
const ( BulkNoteFormatOriginal = 1 // Original format BulkNoteFormatFlex = 2 // Different 'where', 'string', and 'payload' handling BulkNoteFormatFlexNano = 3 // Same as Flex but omits Where/When )
Bulk note formats
const ChaCha20Poly1305AuthTagLen = 16
const ChaCha20Poly1305AuthTagPlaintext = "notecard <3 notehub"
const ChaCha20Poly1305IvLen = 12
const ChaCha20Poly1305KeyLen = 32
const CidNone = byte(0) // Zero bytes
Type of connection ID present in the packet
const CidRandom = byte(1) // CidRandomLen bytes
const CidRandomLen = 6
const ErrInvalidNaNValue = float16Error("float16: invalid NaN value, expected IEEE 754 NaN")
ErrInvalidNaNValue indicates a NaN was not received.
const HTTPUserAgent = "BluesNotehub/1.0"
HTTPUserAgent is the HTTP user agent for all our uses of HTTP
const InvalidTime = int64(0xffffffff)
Define an invalid time so that we force a history to be added with a 0 time. (see packet.go and elsewhere)
const MportChangesDownlink = 250
const MportEchoDownlink = 253
const MportInvalid = 0
Message ports for packet handling
const MportMoreDownlink = 252
const MportMultiportUplink = 254 // Enum of <port><datalen><data>
const MportMultiportUplinkDownlink = 255 // Same but with a guaranteed response formatted the same way
const MportSysNotefileEnv = (MportSysNotefileFirst + 0)
const MportSysNotefileFirst = 101
const MportSysNotefileLast = 125
const MportTimeDownlink = 251
const MportUserNotefileFirst = 1
const MportUserNotefileLast = 100
const MportUserSysNotefileFirst = 126
const MportUserSysNotefileLast = 150
const PV1 = "pv1"
After trying AES GCM and struggling with block size and tag size constraints, and after then consulting with the folks at WolfSSL, we arrived at using the ChaCha20 stream cipher (thus eliminating block constraints) along with the Poly1305 MAC for integrity and authentication.
const PV1EncrAlg = "chacha20-poly1305"
const PacketFlagCompressed = 0x40
const PacketFlagDownlinksPending = 0x20
const PacketFlagEncrypted = 0x80
const PacketFlagSpare1 = 0x10
const PacketTypeMask = 0x0f
Packet type is split - a nibble of flags and a nibble of Connection ID type
const ReservedIDDelimiter = ","
ReservedIDDelimiter is used to separate lists of noteIDs, notefileIDs, endpointIDs, thus is invalid in names
const TemplateFlagClearAfterSync = 0x00000001
const UdpCidType = CidRandom
const UdpMaxMtu = 548 // Minimum internet datagram is 576, IPv4 header is 20, UDP header is 8
const UdpMinMtu = 256 // Below this, we really wouldn't have enough room for any user data to speak of
Default MTU
const UdpMtu = UdpMinMtu
const UdpPs = "udp:"
Supported packet service types. Except for UDP, where there is no ID, The appropriate ID for that service type is appended. For example, it might be the IMEI, IMSI, ICCID, or vendor-proprietary ID of the unit
Variables ¶
var ( AutoCheckpointSeconds = 5 * 60 AutoPurgeSeconds = 5 * 60 CheckpointSilently = false )
var ErrCorrupt = errors.New("smazz: corrupt input")
ErrCorrupt reports that the input is invalid.
var File_notehub_proto protoreflect.FileDescriptor
var SmazzCodeDefault = [254]string{}/* 254 elements not displayed */
Codebook for smaz compatibility
var SmazzCodeTemplate = [254]string{}/* 253 elements not displayed */
Codebook optimized for JSON templates
Functions ¶
func Checkpoint ¶ added in v0.1.13
Checkpoint all noteboxes and purge noteboxes that have been sitting unused for the autopurge interval
func CheckpointNoteboxIfNeeded ¶ added in v1.7.0
func CheckpointNoteboxIfNeeded(ctx context.Context, localEndpointID string, boxLocalStorage string) error
CheckpointNoteboxIfNeeded checkpoints a notebox if it's open
func CreateNotebox ¶
CreateNotebox creates a notebox on this endpoint
func ErrorContains ¶
ErrorContains tests to see if an error contains an error keyword that we might expect
func ErrorResponse ¶
ErrorResponse creates a simple JSON response given an error
func ErrorString ¶
ErrorString safely returns a string from any error, returning "" for nil
func FileCleanName ¶ added in v0.1.5
FileCleanName generates a clean filename with correct extension from a filename input
func FileDefaultStorageObject ¶
func FileDefaultStorageObject() string
FileDefaultStorageObject gives a deterministic storage object name from two components
func FileSetHandler ¶
func FileSetHandler(newfio *Fileio)
FileSetHandler sets an alternate file I/O package
func FileSetStorageLocation ¶
func FileSetStorageLocation(root string)
FileSetStorageLocation sets the root location for storage
func FileStorageObject ¶
FileStorageObject gives a deterministic storage object name from two components
func GetNotecardSecureElementRootCertificateAsPEM ¶
func GetNotecardSecureElementRootCertificateAsPEM() (cert []byte)
GetNotecardSecureElementRootCertificateAsPEM is the ST Microelectronics root certificate used to generate the certificate embedded in every Notecard's STSAFE-A100 secure element at point of chip manufacture.
func HubCheckpointRequest ¶ added in v1.7.0
Make a checkpoint request
func HubDiscover ¶
func HubDiscover(deviceUID string, deviceSN string, productUID string) (hubSessionTicket string, hubEndpointID string, appUID string, deviceStorageObject string, err error)
HubDiscover ensures that we've read the local server's discover info, and return the Hub's Endpoint ID
func HubErrorResponse ¶ added in v0.2.4
func HubErrorResponse(ctx context.Context, session *HubSession, errorMessage string) (result []byte)
HubErrorResponse creates an error response message to be sent to the client device, and terminates the session so that no further requests can be processed.
func HubRequest ¶
func HubRequest(ctx context.Context, content []byte, event EventFunc, session *HubSession) (reqtype string, result []byte, suppress bool, err error)
HubRequest creates a request message from a map of arguments, given an optional context parameter for fields that are shared across requests that happen within a single session. The return arguments should be interpreted as follows: - if err is returned, do not return a reply to the remote requestor - if err is nil, always send result back to request
func HubSetAccessControl ¶ added in v0.2.6
func HubSetAccessControl(fn NoteboxAccessFunc)
HubSetAccessControl sets the global notebox function to check access assertions
func HubSetDeviceNotifications ¶
func HubSetDeviceNotifications(fn GetNotificationFunc)
HubSetDeviceNotifications sets the hub notification
func HubSetDiscover ¶
func HubSetDiscover(fn DiscoverFunc)
HubSetDiscover sets the global discovery function
func HubSetUpdateEnvironment ¶ added in v1.7.0
func HubSetUpdateEnvironment(ctx context.Context, fn NoteboxUpdateEnvFunc)
HubSetUpdateEnvironment sets the global notebox function to update env vars
func HubSetWebRequest ¶
func HubSetWebRequest(fn WebRequestFunc)
HubSetWebRequest sets the web request function
func InitLogging ¶ added in v1.7.0
func NotefileAttributesFromID ¶
func NotefileAttributesFromID(notefileID string) (isQueue bool, syncToHub bool, syncFromHub bool, secure bool, reserved bool, err error)
NotefileAttributesFromID extracts attributes implied by the notefileID
func NotefileIDIsReserved ¶ added in v0.2.7
NotefileIDIsReserved returns true if the notefileID is reserved
func NotefileIDIsReservedWithExceptions ¶ added in v0.4.2
NotefileIDIsReservedWithExceptions returns true if the notefileID is reserved
func OLCFromINT64 ¶
OLCFromINT64 converts a 64-bit OLC code into a string
func OLCToINT64 ¶
OLCToINT64 converts an OLC string into a 64-bit code
func PacketHeaderFromWire ¶ added in v1.7.1
packetHeaderFromWire extracts the connection ID from the wire format
func SetTLSSupport ¶ added in v1.7.1
func SetTLSSupport(enabled bool)
SetTLSSupport tells the discover module that we do support TLS
func TLSSupport ¶
func TLSSupport() bool
TLSSupport tells the discover module that we do support TLS
func TimeZoneNameToNumber ¶ added in v0.2.3
TimeZoneNameToNumber converts a timezone number to a name
func TimeZoneNumberToCountry ¶ added in v0.2.3
TimeZoneNumberToCountry retrieves the country from the name
func TimeZoneNumberToName ¶ added in v0.2.3
TimeZoneNumberToName converts a timezone name to a number
func WireBarsFromSession ¶ added in v0.2.5
func WireBarsFromSession(session *HubSession) (rat string, bars uint32)
WireBarsFromSession extracts device's perception of the number of bars of signal from a session
func WireExtractSessionContext ¶
func WireExtractSessionContext(wire []byte, session *HubSession) (suppressResponse bool, err error)
WireExtractSessionContext extracts session context from the wire message
Types ¶
type BulkBody ¶
type BulkBody struct { // The format of the encoded binary note NoteFormat uint32 `json:"format,omitempty"` // The JSON of the Note template for this notefile. Note that we keep this in text form because // the order of the fields is relevant to the binary encoding derived from the JSON, and the various // encoders/decoders in the data processing pipeline won't retain field order. NoteTemplate string `json:"template_body,omitempty"` NoteTemplatePayloadLen int `json:"template_payload,omitempty"` }
BulkBody is the bulk data note body
type BulkTemplateContext ¶
type BulkTemplateContext struct { NoteFormat uint32 Template string Bin []byte BinLen int // Used while parsing a record BinOffset int BinUnderrun bool // Fields only valid for BulkNoteFormatOriginal ORIGTemplatePayloadLen int ORIGTemplatePayloadOffset int ORIGTemplateFlagsOffset int // contains filtered or unexported fields }
BulkTemplateContext is the context for the bulk template
func BulkDecodeTemplate ¶
func BulkDecodeTemplate(templateBodyJSON []byte, compressedPayload []byte) (tmplContext BulkTemplateContext, err error)
BulkDecodeTemplate sets up a context for decoding by taking the template and a binary buffer to be decoded
func BulkEncodeTemplate ¶ added in v1.7.0
func BulkEncodeTemplate(templateBodyJSON []byte) (context BulkTemplateContext, err error)
BulkEncodeTemplate sets up a context for encoding by taking the template and preparing a binary output buffer
func (*BulkTemplateContext) BulkDecodeNextEntry ¶ added in v1.7.0
func (tmplContext *BulkTemplateContext) BulkDecodeNextEntry() (body map[string]interface{}, payload []byte, when int64, wherewhen int64, olc string, noteID string, success bool)
BulkDecodeNextEntry extract a JSON object from the binary. Note that both 'when' and 'wherewhen' returned in standard unix epoch seconds (not in nanoseconds)
func (*BulkTemplateContext) BulkEncodeNextEntry ¶ added in v1.7.0
func (tmplContext *BulkTemplateContext) BulkEncodeNextEntry(body map[string]interface{}, payload []byte, when int64, wherewhen int64, currentLocOLC string, noteID string, noOmitEmpty bool) (output []byte, err error)
BulkEncodeNextEntry encodes a JSON object using the template in the supplied contxt
BULK_NOTEFORMAT_FLEX and BULK_NOTEFORMAT_NANOFLEX
uint8 header containing BULKFLAGS uint16 header containing variableLengthOffset If BULKFLAGS is not NANO, int64 CombinedWhen (the merger of 'when' and 'whereWhen') If BULKFLAGS is not NANO, int64 WhereOLC64 (positive if validly parsed, else negative if parsing error) N*[binary records as defined by template, with counted text strings encoded as uint16:len uint8[len] ] (beginning of variable-length data) If BULKFLAGS indicates it is present, [payloadLen] [payload] If BULKFLAGS indicates it is present, [flagsLen] [flags] If BULKFLAGS indicates it is present, [olclen] [olc]
type DiscoverFunc ¶
type DiscoverFunc func(edgeUID string, deviceSN string, productUID string, hostname string, packetHandlerVersion string) (info DiscoverInfo, err error)
DiscoverFunc is the func to retrieve discovery info for this server
type DiscoverInfo ¶
type DiscoverInfo struct { HubEndpointID string HubSessionHandler string HubSessionTicket string HubPacketHandler string HubDeviceStorageObject string HubDeviceAppUID string HubTimeNs int64 HubSessionTicketExpiresTimeNs int64 HubCert []byte }
DiscoverInfo is the information returned by DiscoverFunc
type EventFunc ¶
type EventFunc func(ctx context.Context, sess *HubSession, local bool, file *Notefile, data *note.Event) (err error)
EventFunc is the func to get called whenever there is a note add/update/delete
type Fileio ¶
type Fileio struct { Exists FileioExistsFunc Create FileioCreateFunc Delete FileioDeleteFunc ReadJSON FileioReadJSONFunc WriteJSON FileioWriteJSONFunc }
Fileio defines a set of functions for alternative file I/O
type FileioCreateFunc ¶
FileioCreateFunc creates a file
type FileioDeleteFunc ¶
FileioDeleteFunc deletes a file
type FileioExistsFunc ¶
FileioExistsFunc checks for file existence
type FileioReadJSONFunc ¶
FileioReadJSONFunc reads a JSON file
type FileioWriteJSONFunc ¶
FileioWriteJSONFunc writes a JSON file
type Float16 ¶ added in v0.3.5
type Float16 uint16
Float16 represents IEEE 754 half-precision floating-point numbers (binary16).
func FromNaN32ps ¶ added in v0.3.5
FromNaN32ps converts nan to IEEE binary16 NaN while preserving both signaling and payload. Unlike Fromfloat32(), which can only return qNaN because it sets quiet bit = 1, this can return both sNaN and qNaN. If the result is infinity (sNaN with empty payload), then the lowest bit of payload is set to make the result a NaN. Returns ErrInvalidNaNValue and 0x7c01 (sNaN) if nan isn't IEEE 754 NaN. This function was kept simple to be able to inline.
func Frombits ¶ added in v0.3.5
Frombits returns the float16 number corresponding to the IEEE 754 binary16 representation u16, with the sign bit of u16 and the result in the same bit position. Frombits(Bits(x)) == x.
func Fromfloat32 ¶ added in v0.3.5
Fromfloat32 returns a Float16 value converted from f32. Conversion uses IEEE default rounding (nearest int, with ties to even).
func Inf ¶ added in v0.3.5
Inf returns a Float16 with an infinity value with the specified sign. A sign >= returns positive infinity. A sign < 0 returns negative infinity.
func NaN ¶ added in v0.3.5
func NaN() Float16
NaN returns a Float16 of IEEE 754 binary16 not-a-number (NaN). Returned NaN value 0x7e01 has all exponent bits = 1 with the first and last bits = 1 in the significand. This is consistent with Go's 64-bit math.NaN(). Canonical CBOR in RFC 7049 uses 0x7e00.
func (Float16) Bits ¶ added in v0.3.5
Bits returns the IEEE 754 binary16 representation of f, with the sign bit of f and the result in the same bit position. Bits(Frombits(x)) == x.
func (Float16) Float32 ¶ added in v0.3.5
Float32 returns a float32 converted from f (Float16). This is a lossless conversion.
func (Float16) IsInf ¶ added in v0.3.5
IsInf reports whether f is an infinity (inf). A sign > 0 reports whether f is positive inf. A sign < 0 reports whether f is negative inf. A sign == 0 reports whether f is either inf.
func (Float16) IsNaN ¶ added in v0.3.5
IsNaN reports whether f is an IEEE 754 binary16 “not-a-number” value.
func (Float16) IsNormal ¶ added in v0.3.5
IsNormal returns true if f is neither zero, infinite, subnormal, or NaN.
func (Float16) IsQuietNaN ¶ added in v0.3.5
IsQuietNaN reports whether f is a quiet (non-signaling) IEEE 754 binary16 “not-a-number” value.
type GetNotificationFunc ¶
type GetNotificationFunc func(ctx context.Context, deviceEndpointID string, session *HubSession) (notifications []string)
GetNotificationFunc retrieves hub notifications to be sent to client
type HubSession ¶ added in v1.7.1
type HubSession struct { // These is all the fields sent from the notecard and decoded in wire.go Discovery bool Notification bool DeviceSKU string DeviceOrderingCode string DeviceFirmware int64 DevicePIN string DeviceEndpointID string HubEndpointID string HubSessionTicket string FactoryResetID string Session note.DeviceSession // Information about the current session SessionStart time.Time AppUID string Active bool Terminated bool Transactions int // Used for hubreq.go to retain inter-transaction state Notefiles []string NotefilesUpdated bool PendingWebPayload []byte DeviceMonitorID int64 // This field is used for any hub implementation to attach // data specific to that implementation Hub interface{} }
func NewHubSession ¶ added in v1.7.1
func NewHubSession(sessionUID, handlerAddr string, secure bool) HubSession
func (HubSession) LogDebug ¶ added in v1.7.1
func (session HubSession) LogDebug(ctx context.Context, format string, args ...interface{})
func (HubSession) LogError ¶ added in v1.7.1
func (session HubSession) LogError(ctx context.Context, format string, args ...interface{})
type Node ¶ added in v1.7.0
type Node struct {
// contains filtered or unexported fields
}
A Node represents a logical vertex in the trie structure.
func (*Node) Terminal ¶ added in v1.7.0
Terminal indicates whether n is terminal in the trie (that is, whether the path from the root to n represents an element in the set). For instance, if the root node is terminal, then []byte{} is in the trie.
type Notebox ¶
type Notebox struct {
// contains filtered or unexported fields
}
Notebox is the in-memory data structure for an open notebox
func OpenEndpointNotebox ¶
func OpenEndpointNotebox(ctx context.Context, localEndpointID string, boxLocalStorage string, create bool) (box *Notebox, err error)
OpenEndpointNotebox opens - creating if necessary - a notebox in File storage for an endpoint
func OpenNotebox ¶
func OpenNotebox(ctx context.Context, localEndpointID string, boxLocalStorage string) (notebox *Notebox, err error)
OpenNotebox opens a local notebox into memory.
func (*Notebox) AddNote ¶
func (box *Notebox) AddNote(ctx context.Context, endpointID string, notefileID string, noteID string, note note.Note) (err error)
AddNote adds a new note to a notefile, which is a VERY common operation
func (*Notebox) AddNoteWithHistory ¶ added in v1.7.1
func (box *Notebox) AddNoteWithHistory(ctx context.Context, endpointID string, notefileID string, noteID string, note note.Note) (err error)
AddNoteWithHistory adds a new note to a notefile, with history supplied
func (*Notebox) AddNotefile ¶
func (box *Notebox) AddNotefile(ctx context.Context, notefileID string, notefileInfo *note.NotefileInfo) error
AddNotefile adds a new notefile to the notebox, and return "nil" if it already exists
func (*Notebox) Checkpoint ¶ added in v1.7.0
Checkpoint a notebox
func (*Notebox) CheckpointNotefile ¶
CheckpointNotefile checkpoints an open Notefile to storage
func (*Notebox) ClearAllTrackers ¶
ClearAllTrackers deletes all trackers for this endpoint in order to force a resync of all files
func (*Notebox) Close ¶
Close releases a notebox, but leaves it in-memory with a 0 refcount for low-overhead re-open
func (*Notebox) ConvertToJSON ¶
ConvertToJSON serializes/marshals the in-memory Notebox into a JSON buffer
func (*Notebox) CreateNotefile ¶
CreateNotefile creates a new Notefile in-memory, which will ultimately be added to this Notebox
func (*Notebox) DeleteNote ¶
func (box *Notebox) DeleteNote(ctx context.Context, endpointID string, notefileID string, noteID string) (err error)
DeleteNote deletes an existing note from notefile
func (*Notebox) DeleteNotefile ¶
DeleteNotefile deletes a closed Notefile, and releases its storage.
func (*Notebox) EndpointID ¶
EndpointID gets the notebox's endpoint ID
func (*Notebox) GetChangedNotefiles ¶
func (box *Notebox) GetChangedNotefiles(ctx context.Context, endpointID string) (changedNotefiles []string)
GetChangedNotefiles determines, for a given tracker, if there are changes in any notebox and, if so, for which ones.
func (*Notebox) GetChanges ¶
func (box *Notebox) GetChanges(endpointID string, maxBatchSize int) (file *Notefile, numChanges int, totalChanges int, totalNotes int, since int64, until int64, err error)
GetChanges retrieves the next batch of changes being tracked
func (*Notebox) GetEventInfo ¶
GetEventInfo retrieves the info
func (*Notebox) GetNote ¶
func (box *Notebox) GetNote(ctx context.Context, notefileID string, noteID string) (note note.Note, err error)
GetNote gets a note from a notefile
func (*Notebox) GetNotefileInfo ¶
func (box *Notebox) GetNotefileInfo(notefileID string) (notefileInfo note.NotefileInfo, err error)
GetNotefileInfo retrieves info about a specific notefile
func (*Notebox) MergeNotebox ¶
MergeNotebox takes a "changes" Notefile from box.GetChanges, and integrates those changes into the current notebox. NOTE that the "fromBoxFile" should be assumed to be modified and then freed by this method, so the caller must not retain any references.
func (*Notebox) NoteboxNotefileInfo ¶ added in v1.7.1
func (box *Notebox) NoteboxNotefileInfo() (allInfo []NoteboxNotefileInfo)
NoteboxNotefileInfo gets info about all notefiles in a notebox
func (*Notebox) NotefileExists ¶ added in v0.1.10
NotefileExists returns true if notefile exists and is not deleted
func (*Notebox) OpenNotefile ¶
func (box *Notebox) OpenNotefile(ctx context.Context, notefileID string) (iOpenfile *OpenNotefile, notefile *Notefile, err error)
OpenNotefile opens a notefile, reading it from storage and bumping its refcount. As such, you MUST pair this with a call to CloseNotefile. Note that this function must work for the "" NotefileID (when opening the notebox "|" instance), so don't add a check that would prohibit this.
func (*Notebox) Openfile ¶ added in v1.7.0
func (box *Notebox) Openfile() *OpenNotefile
OpenNotefile gets the pointer to the openfile associated with the notebox
func (*Notebox) Request ¶
func (box *Notebox) Request(ctx context.Context, endpointID string, reqJSON []byte) (rspJSON []byte)
Request performs a local operation using the JSON API
func (*Notebox) SetClientInfo ¶ added in v0.2.6
func (box *Notebox) SetClientInfo(httpReq *http.Request, httpRsp http.ResponseWriter)
SetClientInfo sets information that is necessary for HTTP client access checking
func (*Notebox) SetEventInfo ¶
func (box *Notebox) SetEventInfo(deviceUID string, deviceSN string, productUID string, appUID string, eventFn EventFunc, session *HubSession)
SetEventInfo establishes default information used for change notification on notefiles opened in the box
func (*Notebox) SetNotefileInfo ¶
func (box *Notebox) SetNotefileInfo(notefileID string, notefileInfo note.NotefileInfo) (err error)
SetNotefileInfo sets the info about a notefile that is allowed to be changed after notefile creation
func (*Notebox) UpdateChangeTracker ¶
UpdateChangeTracker updates the tracker once changes have been processed
type NoteboxAccessFunc ¶ added in v0.2.6
type NoteboxAccessFunc func(httpReq *http.Request, httpRsp http.ResponseWriter, resource string, actions string) (err error)
NoteboxAccessFunc is the func to check an access assertion
type NoteboxInstance ¶ added in v0.2.6
type NoteboxInstance struct {
// contains filtered or unexported fields
}
NoteboxInstance is the in-memory data structure for an open notebox
type NoteboxNotefileInfo ¶ added in v1.7.1
type NoteboxNotefileInfo struct { NotefileID string Info note.NotefileInfo BodyTemplate string PayloadTemplate uint32 TemplateFormat uint32 TemplatePort uint16 }
Information about files and templates
func NoteboxNotefileInfoByPort ¶ added in v1.7.1
func NoteboxNotefileInfoByPort(allInfo []NoteboxNotefileInfo, port uint16) (info NoteboxNotefileInfo, present bool)
NoteboxNotefileInfoByPort gets info about all notefiles in a notebox
type NoteboxUpdateEnvFunc ¶ added in v1.7.0
type NoteboxUpdateEnvFunc func(ctx context.Context, box *Notebox, deviceUID string, appUID string, updateFeeds bool) (err error)
NoteboxUpdateEnvFunc is the func to update environment variables for a device
type Notefile ¶
type Notefile struct { Queue bool `json:"Q,omitempty"` Notes map[string]note.Note `json:"N,omitempty"` Trackers map[string]Tracker `json:"T,omitempty"` Change int64 `json:"C,omitempty"` // contains filtered or unexported fields }
Notefile is The outermost data structure of a Notefile JSON object, containing a set of notes that may be synchronized.
func CreateNotefile ¶
CreateNotefile instantiates and initializes a new Notefile, and prepares it so that notes may be added on behalf of the specified endpoint. The ID of that endpoint may be changed at any time and is merely an affordance so that we don't need to put the endpointID onto every Note call.
func (*Notefile) AddNote ¶
func (nf *Notefile) AddNote(endpointID string, noteID string, xnote note.Note) (newNoteID string, err error)
AddNote adds a newly-created Note to a Notefile. After the note is added to the Notefile, it should no longer be used because its contents is copied into the Notefile. If a unique ID for this note isn't supplied, one is generated. Note that if this is a queue, AddNote adds the newly-created note in a pre-deleted state. This is quite useful for notefiles that are being "tracked", because after all trackers receive it, they will undelete it and thus it will be present everywhere except the source. This is an intentional asymmetry in synchronization that is primarily useful when sending "to hub" or "from hub". By convention, sent notes should be deleted after they have been processed by the recipient(s).
func (*Notefile) AddNoteWithHistory ¶ added in v1.7.0
func (nf *Notefile) AddNoteWithHistory(endpointID string, noteID string, xnote note.Note) (newNoteID string, err error)
AddNoteWithHistory is same as AddNote, but it retains history
func (*Notefile) AddTracker ¶
AddTracker creates an object that will be used for performing incremental queries against the notefile. Do NOT create trackers that won't actively be used, because deletion tombstones will remain in the Notefile for as long as necessary by the oldest pending tracker. In other words, delete trackers when not in use.
func (*Notefile) AllNotes ¶ added in v1.7.0
Notes retrieves a duplicate list of all Notes in the notefile
func (*Notefile) AreChanges ¶
AreChanges determines whether or not there are any changes pending for this endpoint
func (*Notefile) ClearTracker ¶
ClearTracker clears the change count in a tracker
func (*Notefile) ConvertToJSON ¶
ConvertToJSON serializes/marshals the in-memory Notefile into a JSON buffer
func (*Notefile) CountNotes ¶
CountNotes returns the count of notes within this notefile
func (*Notefile) DeleteNote ¶
DeleteNote sets the deleted flag on an existing note from in a Notefile, marking it so that it will be purged at a later time when safe to do so from a synchronization perspective.
func (*Notefile) DeleteTracker ¶
DeleteTracker deletes an existing tracker
func (*Notefile) GetChanges ¶
func (nf *Notefile) GetChanges(endpointID string, includeTombstones bool, maxBatchSize int) (chgfile *Notefile, numChanges int, totalChanges int, totalNotes int, since int64, until int64, err error)
GetChanges retrieves the next batch of changes being tracked, initializing a new tracker if necessary.
func (*Notefile) GetEventInfo ¶ added in v1.7.0
func (nf *Notefile) GetEventInfo() (deviceUID string, deviceSN string, productUID string, appUID string, eventFn EventFunc, eventSession *HubSession)
GetEventInfo Gets information used for change notification
func (*Notefile) GetLeastRecentNoteID ¶ added in v0.2.7
GetLeastRecentNoteID enumerates and returns the first logical note to dequeue
func (*Notefile) GetTrackers ¶
GetTrackers gets a list of the trackers for a given notefile
func (*Notefile) Info ¶
func (nf *Notefile) Info() (info note.NotefileInfo)
Info returns the notefileinfo as it was when this notefile was opened
func (*Notefile) InternalizePayload ¶
InternalizePayload populates the Payload field inside a set of notes in a notefile from an external source
func (*Notefile) MarkAsModified ¶ added in v1.7.0
Mark the notefile as modified
func (*Notefile) MergeNotefile ¶
MergeNotefile combines/merges the entire contents of one Notefile into another
func (*Notefile) Modified ¶
Modified returns the number of times this has been modified in-memory since being opened. Note that this is not persistent, and is intended to be used for checkpointing.
func (*Notefile) PurgeTombstones ¶
PurgeTombstones purges tombstones that are no longer needed by trackers
func (*Notefile) ResolveNoteConflicts ¶
ResolveNoteConflicts resolves all conflicts that are pending for a Note in a Notefile
func (*Notefile) SetEventInfo ¶
func (nf *Notefile) SetEventInfo(deviceUID string, deviceSN string, productUID string, appUID string, eventFn EventFunc, eventSession *HubSession)
SetEventInfo supplies information used for change notification
func (*Notefile) SetNoteWhen ¶ added in v1.7.0
Set the 'when' date on a note immediately AFTER it has been added/updated
func (*Notefile) UpdateChangeTracker ¶
UpdateChangeTracker updates the tracker and purges tombstones after changes have been committed
type NotehubPB ¶
type NotehubPB struct { Version *int64 `protobuf:"varint,1,opt,name=Version" json:"Version,omitempty"` MessageType *string `protobuf:"bytes,2,opt,name=MessageType" json:"MessageType,omitempty"` Error *string `protobuf:"bytes,3,opt,name=Error" json:"Error,omitempty"` DeviceUID *string `protobuf:"bytes,4,opt,name=DeviceUID" json:"DeviceUID,omitempty"` DeviceEndpointID *string `protobuf:"bytes,5,opt,name=DeviceEndpointID" json:"DeviceEndpointID,omitempty"` HubTimeNs *int64 `protobuf:"varint,6,opt,name=HubTimeNs" json:"HubTimeNs,omitempty"` HubEndpointID *string `protobuf:"bytes,7,opt,name=HubEndpointID" json:"HubEndpointID,omitempty"` HubSessionTicket *string `protobuf:"bytes,8,opt,name=HubSessionTicket" json:"HubSessionTicket,omitempty"` HubSessionHandler *string `protobuf:"bytes,9,opt,name=HubSessionHandler" json:"HubSessionHandler,omitempty"` HubSessionTicketExpiresTimeSec *int64 `protobuf:"varint,10,opt,name=HubSessionTicketExpiresTimeSec" json:"HubSessionTicketExpiresTimeSec,omitempty"` NotefileID *string `protobuf:"bytes,11,opt,name=NotefileID" json:"NotefileID,omitempty"` NotefileIDs *string `protobuf:"bytes,12,opt,name=NotefileIDs" json:"NotefileIDs,omitempty"` Since *int64 `protobuf:"varint,13,opt,name=Since" json:"Since,omitempty"` Until *int64 `protobuf:"varint,14,opt,name=Until" json:"Until,omitempty"` MaxChanges *int64 `protobuf:"varint,15,opt,name=MaxChanges" json:"MaxChanges,omitempty"` DeviceSN *string `protobuf:"bytes,16,opt,name=DeviceSN" json:"DeviceSN,omitempty"` NoteID *string `protobuf:"bytes,17,opt,name=NoteID" json:"NoteID,omitempty"` SessionIDPrev *int64 `protobuf:"varint,18,opt,name=SessionIDPrev" json:"SessionIDPrev,omitempty"` SessionIDNext *int64 `protobuf:"varint,19,opt,name=SessionIDNext" json:"SessionIDNext,omitempty"` SessionIDMismatch *bool `protobuf:"varint,20,opt,name=SessionIDMismatch" json:"SessionIDMismatch,omitempty"` Bytes1 *int64 `protobuf:"varint,21,opt,name=Bytes1" json:"Bytes1,omitempty"` Bytes2 *int64 `protobuf:"varint,22,opt,name=Bytes2" json:"Bytes2,omitempty"` Bytes3 *int64 `protobuf:"varint,23,opt,name=Bytes3" json:"Bytes3,omitempty"` Bytes4 *int64 `protobuf:"varint,24,opt,name=Bytes4" json:"Bytes4,omitempty"` ProductUID *string `protobuf:"bytes,25,opt,name=ProductUID" json:"ProductUID,omitempty"` UsageProvisioned *int64 `protobuf:"varint,26,opt,name=UsageProvisioned" json:"UsageProvisioned,omitempty"` UsageRcvdBytes *uint32 `protobuf:"varint,27,opt,name=UsageRcvdBytes" json:"UsageRcvdBytes,omitempty"` UsageSentBytes *uint32 `protobuf:"varint,28,opt,name=UsageSentBytes" json:"UsageSentBytes,omitempty"` UsageTCPSessions *uint32 `protobuf:"varint,29,opt,name=UsageTCPSessions" json:"UsageTCPSessions,omitempty"` UsageTLSSessions *uint32 `protobuf:"varint,30,opt,name=UsageTLSSessions" json:"UsageTLSSessions,omitempty"` UsageRcvdNotes *uint32 `protobuf:"varint,31,opt,name=UsageRcvdNotes" json:"UsageRcvdNotes,omitempty"` UsageSentNotes *uint32 `protobuf:"varint,32,opt,name=UsageSentNotes" json:"UsageSentNotes,omitempty"` CellID *string `protobuf:"bytes,33,opt,name=CellID" json:"CellID,omitempty"` NotificationSession *bool `protobuf:"varint,34,opt,name=NotificationSession" json:"NotificationSession,omitempty"` Voltage100 *int32 `protobuf:"varint,35,opt,name=Voltage100" json:"Voltage100,omitempty"` Temp100 *int32 `protobuf:"varint,36,opt,name=Temp100" json:"Temp100,omitempty"` ContinuousSession *bool `protobuf:"varint,37,opt,name=ContinuousSession" json:"ContinuousSession,omitempty"` MotionSecs *int64 `protobuf:"varint,38,opt,name=MotionSecs" json:"MotionSecs,omitempty"` MotionOrientation *string `protobuf:"bytes,39,opt,name=MotionOrientation" json:"MotionOrientation,omitempty"` SessionTrigger *string `protobuf:"bytes,40,opt,name=SessionTrigger" json:"SessionTrigger,omitempty"` Voltage1000 *int32 `protobuf:"varint,41,opt,name=Voltage1000" json:"Voltage1000,omitempty"` Temp1000 *int32 `protobuf:"varint,42,opt,name=Temp1000" json:"Temp1000,omitempty"` HubSessionFactoryResetID *string `protobuf:"bytes,43,opt,name=HubSessionFactoryResetID" json:"HubSessionFactoryResetID,omitempty"` HighPowerSecsTotal *uint32 `protobuf:"varint,44,opt,name=HighPowerSecsTotal" json:"HighPowerSecsTotal,omitempty"` HighPowerSecsData *uint32 `protobuf:"varint,45,opt,name=HighPowerSecsData" json:"HighPowerSecsData,omitempty"` HighPowerSecsGPS *uint32 `protobuf:"varint,46,opt,name=HighPowerSecsGPS" json:"HighPowerSecsGPS,omitempty"` HighPowerCyclesTotal *uint32 `protobuf:"varint,47,opt,name=HighPowerCyclesTotal" json:"HighPowerCyclesTotal,omitempty"` HighPowerCyclesData *uint32 `protobuf:"varint,48,opt,name=HighPowerCyclesData" json:"HighPowerCyclesData,omitempty"` HighPowerCyclesGPS *uint32 `protobuf:"varint,49,opt,name=HighPowerCyclesGPS" json:"HighPowerCyclesGPS,omitempty"` DeviceSKU *string `protobuf:"bytes,50,opt,name=DeviceSKU" json:"DeviceSKU,omitempty"` DeviceFirmware *int64 `protobuf:"varint,51,opt,name=DeviceFirmware" json:"DeviceFirmware,omitempty"` DevicePIN *string `protobuf:"bytes,52,opt,name=DevicePIN" json:"DevicePIN,omitempty"` DeviceOrderingCode *string `protobuf:"bytes,53,opt,name=DeviceOrderingCode" json:"DeviceOrderingCode,omitempty"` UsageRcvdBytesSecondary *uint32 `protobuf:"varint,54,opt,name=UsageRcvdBytesSecondary" json:"UsageRcvdBytesSecondary,omitempty"` UsageSentBytesSecondary *uint32 `protobuf:"varint,55,opt,name=UsageSentBytesSecondary" json:"UsageSentBytesSecondary,omitempty"` SuppressResponse *bool `protobuf:"varint,56,opt,name=SuppressResponse" json:"SuppressResponse,omitempty"` Where *string `protobuf:"bytes,57,opt,name=Where" json:"Where,omitempty"` WhereWhen *int64 `protobuf:"varint,58,opt,name=WhereWhen" json:"WhereWhen,omitempty"` HubPacketHandler *string `protobuf:"bytes,59,opt,name=HubPacketHandler" json:"HubPacketHandler,omitempty"` // contains filtered or unexported fields }
func (*NotehubPB) Descriptor
deprecated
func (*NotehubPB) GetContinuousSession ¶ added in v0.2.7
func (*NotehubPB) GetDeviceEndpointID ¶
func (*NotehubPB) GetDeviceFirmware ¶ added in v1.7.0
func (*NotehubPB) GetDeviceOrderingCode ¶ added in v1.7.0
func (*NotehubPB) GetDevicePIN ¶ added in v1.7.0
func (*NotehubPB) GetDeviceSKU ¶ added in v1.7.0
func (*NotehubPB) GetDeviceSN ¶
func (*NotehubPB) GetDeviceUID ¶
func (*NotehubPB) GetHighPowerCyclesData ¶ added in v1.7.0
func (*NotehubPB) GetHighPowerCyclesGPS ¶ added in v1.7.0
func (*NotehubPB) GetHighPowerCyclesTotal ¶ added in v1.7.0
func (*NotehubPB) GetHighPowerSecsData ¶ added in v1.7.0
func (*NotehubPB) GetHighPowerSecsGPS ¶ added in v1.7.0
func (*NotehubPB) GetHighPowerSecsTotal ¶ added in v1.7.0
func (*NotehubPB) GetHubEndpointID ¶
func (*NotehubPB) GetHubPacketHandler ¶ added in v1.7.1
func (*NotehubPB) GetHubSessionFactoryResetID ¶ added in v1.7.0
func (*NotehubPB) GetHubSessionHandler ¶
func (*NotehubPB) GetHubSessionTicket ¶
func (*NotehubPB) GetHubSessionTicketExpiresTimeSec ¶
func (*NotehubPB) GetHubTimeNs ¶
func (*NotehubPB) GetMaxChanges ¶
func (*NotehubPB) GetMessageType ¶
func (*NotehubPB) GetMotionOrientation ¶ added in v0.3.7
func (*NotehubPB) GetMotionSecs ¶ added in v0.3.7
func (*NotehubPB) GetNotefileID ¶
func (*NotehubPB) GetNotefileIDs ¶
func (*NotehubPB) GetNotificationSession ¶
func (*NotehubPB) GetProductUID ¶
func (*NotehubPB) GetSessionIDMismatch ¶
func (*NotehubPB) GetSessionIDNext ¶
func (*NotehubPB) GetSessionIDPrev ¶
func (*NotehubPB) GetSessionTrigger ¶ added in v0.3.9
func (*NotehubPB) GetSuppressResponse ¶ added in v1.7.0
func (*NotehubPB) GetTemp100 ¶
func (*NotehubPB) GetTemp1000 ¶ added in v1.7.0
func (*NotehubPB) GetUsageProvisioned ¶
func (*NotehubPB) GetUsageRcvdBytes ¶
func (*NotehubPB) GetUsageRcvdBytesSecondary ¶ added in v1.7.0
func (*NotehubPB) GetUsageRcvdNotes ¶
func (*NotehubPB) GetUsageSentBytes ¶
func (*NotehubPB) GetUsageSentBytesSecondary ¶ added in v1.7.0
func (*NotehubPB) GetUsageSentNotes ¶
func (*NotehubPB) GetUsageTCPSessions ¶
func (*NotehubPB) GetUsageTLSSessions ¶
func (*NotehubPB) GetVersion ¶
func (*NotehubPB) GetVoltage100 ¶
func (*NotehubPB) GetVoltage1000 ¶ added in v1.7.0
func (*NotehubPB) GetWhereWhen ¶ added in v1.7.0
func (*NotehubPB) ProtoMessage ¶
func (*NotehubPB) ProtoMessage()
func (*NotehubPB) ProtoReflect ¶ added in v1.7.0
func (x *NotehubPB) ProtoReflect() protoreflect.Message
type OpenNotefile ¶
type OpenNotefile struct {
// contains filtered or unexported fields
}
OpenNotefile is the in-memory data structure for an open notefile
type PacketHandler ¶ added in v1.7.1
type PacketHandler struct { // Uploaded by Notecard when packet service is requested, and these are the // parameters used when decoding packets from the notecard AND used when // encoding packets to be sent back to the notecard. Notecard PacketHandlerNotecard `json:"notecard,omitempty"` // Set by Notehub by policy when handler is issued Notehub PacketHandlerNotehub `json:"notehub,omitempty"` }
Packet handler information
func (*PacketHandler) PacketFromWire ¶ added in v1.7.1
func (h *PacketHandler) PacketFromWire(wire []byte) (msg Packet, err error)
PacketFromWire converts a request from wire format
func (*PacketHandler) PacketMaxData ¶ added in v1.7.1
func (h *PacketHandler) PacketMaxData(encrypted bool) (length int)
PacketMaxData returns the largest amount of data allowed
func (*PacketHandler) PacketToWire ¶ added in v1.7.1
func (h *PacketHandler) PacketToWire(payload Packet, secureData bool, downlinksPending bool) (msg []byte, err error)
PacketToWire converts a Packet to wire format, which is wholly little-endian See notehub-defs.go for binary wire format of PB payload
type PacketHandlerNotecard ¶ added in v1.7.1
type PacketHandlerNotehub ¶ added in v1.7.1
type PacketHandlerNotehub struct { // The Notehub generates a unique connection ID for every NTN device. It // is always assigned, and for certain NTN transports (such as UDP) it is // carried 'in-band' in the packet contents, while for other transports // (such as skylo) it is never carrierd on-the-wire. CidType byte `json:"cid_type,omitempty"` // CID_RANDOM Cid []byte `json:"cid,omitempty"` // Random connection ID // The Notehub can optionally tell the notecard to override the standard // encryption for .dbs/.qos/.qis files, either forcing it to be ON or OFF MustEncrypt bool `json:"encrall,omitempty"` MayEncrypt bool `json:"encr,omitempty"` // Specifically used by the notecard/notehub when the transport is UDP UdpMtu uint `json:"mtu,omitempty"` UdpIpV4 string `json:"ipv4,omitempty"` UdpIpV4Port string `json:"ipv4port,omitempty"` UdpPolicy string `json:"comms,omitempty"` }
type Precision ¶ added in v0.3.5
type Precision int
Precision indicates whether the conversion to Float16 is exact, subnormal without dropped bits, inexact, underflow, or overflow.
const ( // PrecisionExact is for non-subnormals that don't drop bits during conversion. // All of these can round-trip. Should always convert to float16. PrecisionExact Precision = iota // PrecisionUnknown is for subnormals that don't drop bits during conversion but // not all of these can round-trip so precision is unknown without more effort. // Only 2046 of these can round-trip and the rest cannot round-trip. PrecisionUnknown // PrecisionInexact is for dropped significand bits and cannot round-trip. // Some of these are subnormals. Cannot round-trip float32->float16->float32. PrecisionInexact // PrecisionUnderflow is for Underflows. Cannot round-trip float32->float16->float32. PrecisionUnderflow // PrecisionOverflow is for Overflows. Cannot round-trip float32->float16->float32. PrecisionOverflow )
func PrecisionFromfloat32 ¶ added in v0.3.5
PrecisionFromfloat32 returns Precision without performing the conversion. Conversions from both Infinity and NaN values will always report PrecisionExact even if NaN payload or NaN-Quiet-Bit is lost. This function is kept simple to allow inlining and run < 0.5 ns/op, to serve as a fast filter.
type ReadFileFunc ¶
type ReadFileFunc func(ctx context.Context, appUID string, filetype notehub.UploadType, key string, offset int32, length int32, compress bool) (body notehub.UploadMetadata, payload []byte, err error)
ReadFileFunc is the func to read a byte range from the named file
type SignalFunc ¶
type SignalFunc func(deviceUID string, bodyJSON []byte, payload []byte, session *HubSession) (err error)
SignalFunc performs a web request on behalf of a device
type SmazzContext ¶ added in v1.7.0
type SmazzContext struct {
// contains filtered or unexported fields
}
func Smazz ¶ added in v1.7.0
func Smazz(table [254]string) (ctx *SmazzContext)
func (*SmazzContext) Decode ¶ added in v1.7.0
func (ctx *SmazzContext) Decode(dst, src []byte) ([]byte, error)
Decode returns the decoded form of src. The returned slice may be a sub-slice of dst if dst was large enough to hold the entire decoded block. Otherwise, a newly allocated slice will be returned. It is valid to pass a nil dst.
func (*SmazzContext) Encode ¶ added in v1.7.0
func (ctx *SmazzContext) Encode(dst, src []byte) ([]byte, error)
Encode returns the encoded form of src. The returned slice may be a sub-slice of dst if dst was large enough to hold the entire encoded block. Otherwise, a newly allocated slice will be returned. It is valid to pass a nil dst.
func (*SmazzContext) Invalid ¶ added in v1.7.0
func (ctx *SmazzContext) Invalid(src []byte) bool
See if a buffer is known NOT to be Smazz-encoded
type TimeZoneNames ¶ added in v0.2.3
TimeZoneNames is the struct for the table below
type Tracker ¶
type Tracker struct { Change int64 `json:"c,omitempty"` SessionID int64 `json:"i,omitempty"` Optimize bool `json:"o,omitempty"` }
Tracker is the structure maintained on a per-endpoint basis. When created, the Active flag being false indicates that any GetChanges will return ALL notes in the file. Only after the tracking entity has received all notes at least once can it then switch into "Optimize" mode. When Optimizing, a tracking entity will not receive its own uploaded changes - thus preventing "loopback". (Loopback is not harmful per se, but it is suboptimal from a bandwidth perspective.)
type Trie ¶ added in v1.7.0
type Trie struct {
// contains filtered or unexported fields
}
A Trie is a a prefix tree.
type WebRequestFunc ¶
type WebRequestFunc func(ctx context.Context, sess *HubSession, deviceUID string, productUID string, alias string, reqtype string, reqcontent string, reqoffset int, reqmaxbytes int, target string, bodyJSON []byte, payload []byte) (rspstatuscode int, rspheader map[string][]string, rspBodyJSON []byte, rspPayloadJSON []byte, err error)
WebRequestFunc performs a web request on behalf of a device