devices

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeviceConnection

type DeviceConnection struct {
	Type  string `json:"type"`  // "mac", "ip", "bluetooth", etc.
	Value string `json:"value"` // The connection identifier value
}

DeviceConnection represents a network-based connection identifier

type DeviceEntry

type DeviceEntry struct {
	// Core identification
	ID          string             `json:"id"`          // Unique device ID
	Identifiers []DeviceIdentifier `json:"identifiers"` // Multiple identifiers
	Connections []DeviceConnection `json:"connections"` // Network connections

	// Device information
	Name         string     `json:"name,omitempty"`
	Manufacturer string     `json:"manufacturer,omitempty"`
	Model        string     `json:"model,omitempty"`
	ModelID      string     `json:"model_id,omitempty"`
	DeviceType   DeviceType `json:"device_type"`

	// Version information
	HWVersion string `json:"hw_version,omitempty"`
	SWVersion string `json:"sw_version,omitempty"`

	// Configuration and capabilities
	SupportedPorts     []int    `json:"supported_ports,omitempty"`
	SupportedProtocols []string `json:"supported_protocols,omitempty"`
	HasGPS             bool     `json:"has_gps,omitempty"`

	// Organization and area (SpaceDF specific)
	Organization string  `json:"organization,omitempty"`
	AreaID       *string `json:"area_id,omitempty"`

	// Status and control
	DisabledBy *string `json:"disabled_by,omitempty"`
	ConfigURL  *string `json:"config_url,omitempty"`

	// Timestamps
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	LastSeen  *time.Time `json:"last_seen,omitempty"`

	// Additional metadata
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

DeviceEntry represents a comprehensive device entry

func (*DeviceEntry) AddConnection

func (d *DeviceEntry) AddConnection(connType, value string)

AddConnection adds a new connection to the device

func (*DeviceEntry) AddIdentifier

func (d *DeviceEntry) AddIdentifier(identifierType, key, value string)

AddIdentifier adds a new identifier to the device

func (*DeviceEntry) GetConnectionByType

func (d *DeviceEntry) GetConnectionByType(connType string) *DeviceConnection

GetConnectionByType returns the first connection with the specified type

func (*DeviceEntry) GetConnectionValue

func (d *DeviceEntry) GetConnectionValue(connType string) string

GetConnectionValue returns the value of the first connection with the specified type

func (*DeviceEntry) GetDevEUI

func (d *DeviceEntry) GetDevEUI() string

GetDevEUI returns the LoRaWAN DevEUI identifier value

func (*DeviceEntry) GetESN

func (d *DeviceEntry) GetESN() string

GetESN returns the satellite ESN identifier value

func (*DeviceEntry) GetIdentifierByKey

func (d *DeviceEntry) GetIdentifierByKey(key string) *DeviceIdentifier

GetIdentifierByKey returns the first identifier with the specified key

func (*DeviceEntry) GetIdentifierValue

func (d *DeviceEntry) GetIdentifierValue(key string) string

GetIdentifierValue returns the value of the first identifier with the specified key

func (*DeviceEntry) GetMAC

func (d *DeviceEntry) GetMAC() string

GetMAC returns the network MAC address

func (*DeviceEntry) SupportsPort

func (d *DeviceEntry) SupportsPort(port int) bool

SupportsPort checks if the device supports a specific fPort

func (*DeviceEntry) SupportsProtocol

func (d *DeviceEntry) SupportsProtocol(protocol string) bool

SupportsProtocol checks if the device supports a specific protocol

func (*DeviceEntry) UpdateLastSeen

func (d *DeviceEntry) UpdateLastSeen()

UpdateLastSeen updates the last seen timestamp

type DeviceIdentifier

type DeviceIdentifier struct {
	Type  string `json:"type"`  // "lorawan", "satellite", "network", etc.
	Key   string `json:"key"`   // "dev_eui", "esn", "mac", etc.
	Value string `json:"value"` // The actual identifier value
}

DeviceIdentifier represents a single identifier for a device

type DeviceParser

type DeviceParser interface {
	// GetDeviceType returns the device type this parser handles
	GetDeviceType() DeviceType

	// CanParse checks if this parser can handle the given payload
	// This is used for device detection/routing
	CanParse(payload *RawPayload) bool

	// Parse converts raw payload into structured ParsedData
	Parse(ctx context.Context, payload *RawPayload) (*ParsedData, error)

	// Validate performs device-specific validation on the parsed data
	Validate(data *ParsedData) error
}

DeviceParser defines the interface that each device plugin must implement

type DeviceParserWithMetadata

type DeviceParserWithMetadata interface {
	DeviceParser
	GetMetadata() ParserMetadata
}

DeviceParserWithMetadata extends DeviceParser with metadata

type DeviceType

type DeviceType string

DeviceType represents the model/type of a device

const (
	DeviceTypeRAK2270 DeviceType = "RAK2270"
	DeviceTypeUnknown DeviceType = "UNKNOWN"
)

type GatewayInfo

type GatewayInfo struct {
	GatewayID string   `json:"gateway_id"`
	RSSI      int      `json:"rssi"`
	SNR       float64  `json:"snr"`
	Location  Location `json:"location,omitempty"`
}

GatewayInfo contains information about the gateway that received the message

type IdentifierDetector

type IdentifierDetector struct{}

IdentifierDetector handles automatic detection of device identifiers from message payloads

func NewIdentifierDetector

func NewIdentifierDetector() *IdentifierDetector

NewIdentifierDetector creates a new identifier detector

func (*IdentifierDetector) DetectIdentifiers

func (d *IdentifierDetector) DetectIdentifiers(payload, locationPayload map[string]interface{}) []DeviceIdentifier

DetectIdentifiers analyzes a message payload and extracts all possible device identifiers

func (*IdentifierDetector) LogDetectedIdentifiers

func (d *IdentifierDetector) LogDetectedIdentifiers(identifiers []DeviceIdentifier)

LogDetectedIdentifiers logs detected identifiers for debugging

type Location

type Location struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
	Altitude  float64 `json:"altitude,omitempty"`
}

Location represents geographical coordinates

type ParsedData

type ParsedData struct {
	DeviceEUI    string                 `json:"device_eui"`
	DeviceType   DeviceType             `json:"device_type"`
	Timestamp    time.Time              `json:"timestamp"`
	Location     *Location              `json:"location,omitempty"`
	SensorData   map[string]interface{} `json:"sensor_data"`
	BatteryLevel *float64               `json:"battery_level,omitempty"`
	RawData      string                 `json:"raw_data,omitempty"`
}

ParsedData represents the device-specific parsed data

type ParserMetadata

type ParserMetadata struct {
	DeviceType     DeviceType
	Manufacturer   string
	Model          string
	Version        string
	Description    string
	SupportedPorts []int // FPorts this device uses
}

ParserMetadata provides information about the device parser

type RawPayload

type RawPayload struct {
	DeviceEUI string                 `json:"device_eui"`
	FPort     int                    `json:"fport"`
	Data      string                 `json:"data"` // Base64-encoded payload
	Timestamp time.Time              `json:"timestamp"`
	RxInfo    []GatewayInfo          `json:"rx_info"`
	Metadata  map[string]interface{} `json:"metadata"`

	// Enhanced with multi-identifier support
	Identifiers []DeviceIdentifier `json:"identifiers,omitempty"` // Multiple device IDs
	Connections []DeviceConnection `json:"connections,omitempty"` // Network connections
}

RawPayload represents the incoming device data before parsing

Jump to

Keyboard shortcuts

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