models

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: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	// Core identification
	ID          string             `json:"id"`          // Unique device ID
	DeviceEUI   string             `json:"device_eui"`  // Primary LoRaWAN DevEUI (for backward compatibility)
	Identifiers []DeviceIdentifier `json:"identifiers"` // Multiple identifiers
	Connections []DeviceConnection `json:"connections"` // Network connections

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

	// Device profile and configuration
	Profile            string   `json:"device_profile"` // Device profile name
	SupportedPorts     []int    `json:"supported_ports,omitempty"`
	SupportedProtocols []string `json:"supported_protocols,omitempty"`
	HasGPS             bool     `json:"has_gps,omitempty"`

	// Organization and space (SpaceDF specific)
	Organization string `json:"organization"`
	SpaceSlug    string `json:"space_slug,omitempty"`

	// Status and control
	IsPublished bool   `json:"is_published"`
	Skip        bool   `json:"skip,omitempty"`
	DisabledBy  string `json:"disabled_by,omitempty"`

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

	// Timestamps
	CreatedAt string `json:"created_at,omitempty"`
	UpdatedAt string `json:"updated_at,omitempty"`
	LastSeen  string `json:"last_seen,omitempty"`

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

Device represents a unified device entry combining DeviceMapping and DeviceEntry

func FromDeviceMapping

func FromDeviceMapping(dm DeviceMapping, deviceEUI string) Device

FromDeviceMapping creates a Device from legacy DeviceMapping

func (*Device) AddConnection

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

AddConnection adds a new connection to the device

func (*Device) AddIdentifier

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

AddIdentifier adds a new identifier to the device

func (*Device) GetConnectionByType

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

GetConnectionByType returns the first connection with the specified type

func (*Device) GetConnectionValue

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

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

func (*Device) GetDevEUI

func (d *Device) GetDevEUI() string

GetDevEUI returns the LoRaWAN DevEUI identifier value

func (*Device) GetESN

func (d *Device) GetESN() string

GetESN returns the satellite ESN identifier value

func (*Device) GetIdentifierByKey

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

GetIdentifierByKey returns the first identifier with the specified key

func (*Device) GetIdentifierValue

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

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

func (*Device) GetMAC

func (d *Device) GetMAC() string

GetMAC returns the network MAC address

func (*Device) SupportsPort

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

SupportsPort checks if the device supports a specific fPort

func (*Device) SupportsProtocol

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

SupportsProtocol checks if the device supports a specific protocol

func (*Device) ToDeviceMapping

func (d *Device) ToDeviceMapping() DeviceMapping

ToDeviceMapping converts the unified Device to legacy DeviceMapping for backward compatibility

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

type DeviceLocationData struct {
	Latitude     float64 `json:"latitude"`
	Longitude    float64 `json:"longitude"`
	DevEUI       string  `json:"dev_eui"`
	Organization string  `json:"organization"`
	Manufacture  string  `json:"manufacture,omitempty"`
}

DeviceLocationData represents the calculated device location

type DeviceLookupResponse

type DeviceLookupResponse struct {
	ID          string `json:"id"`
	DeviceID    string `json:"device_id"`
	DeviceModel string `json:"device_model"`
	SpaceSlug   string `json:"space_slug"`
	IsPublished bool   `json:"is_published"`
}

DeviceLookupResponse represents the payload returned by the device lookup API

type DeviceMapping

type DeviceMapping struct {
	Profile      string `json:"device_profile"`
	Organization string `json:"organization"`
	DeviceID     string `json:"id"`
	DeviceName   string `json:"device_name"`
	Manufacture  string `json:"manufacture"`
	Description  string `json:"description"`
	SpaceSlug    string `json:"space_slug"`
	IsPublished  bool   `json:"is_published"`
	Skip         bool   `json:"skip,omitempty"`
}

DeviceMapping represents a device EUI to profile mapping DEPRECATED: Use Device instead for new code

type DeviceModel added in v0.0.2

type DeviceModel struct {
	ID               string `json:"id"`
	Name             string `json:"name"`
	ManufacturerID   string `json:"manufacturer_id"`
	ManufacturerName string `json:"manufacturer_name"`
	DeviceType       string `json:"device_type"`
	KeyFeature       string `json:"key_feature"`
}

DeviceModel represents the API response structure for a device model

type DeviceProfile added in v0.0.2

type DeviceProfile struct {
	ID                    string   `yaml:"id"`
	Name                  string   `yaml:"name"`
	ManufacturerID        string   `yaml:"manufacturer_id"`
	DeviceType            string   `yaml:"device_type"`
	KeyFeature            string   `yaml:"key_feature"`
	Protocol              string   `yaml:"protocol"`
	Capabilities          []string `yaml:"capabilities"`
	GPSCapable            bool     `yaml:"gps_capable"`
	RequiresTrilateration bool     `yaml:"requires_trilateration"`
	SupportedFPorts       []int    `yaml:"supported_fports"`
	CreatedAt             string   `yaml:"created_at"`
	UpdatedAt             string   `yaml:"updated_at"`
}

DeviceProfile represents the YAML structure for device profiles

type DeviceProfileConfig added in v0.0.2

type DeviceProfileConfig struct {
	DeviceProfiles []DeviceProfile `yaml:"device_profiles"`
}

DeviceProfileConfig represents the root YAML structure for device profiles

type EndDeviceIDs

type EndDeviceIDs struct {
	DevEUI string `json:"dev_eui"`
}

EndDeviceIDs represents the device identifiers

type EntityTelemetryPayload

type EntityTelemetryPayload struct {
	Organization string                 `json:"organization"`
	DeviceEUI    string                 `json:"device_eui"`
	DeviceID     string                 `json:"device_id,omitempty"`
	SpaceSlug    string                 `json:"space_slug,omitempty"`
	Entity       TelemetryEntity        `json:"entity"`
	Timestamp    string                 `json:"timestamp"`
	Source       string                 `json:"source"`
	Metadata     map[string]interface{} `json:"metadata,omitempty"`
}

EntityTelemetryPayload represents telemetry for a single entity (no entities array)

type Gateway

type Gateway struct {
	Location *Location `json:"location,omitempty"`
	RSSI     int       `json:"rssi"`
}

Gateway represents a LoRaWAN gateway

type Location

type Location struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
}

Location represents geographical coordinates

type LocationCoordinates

type LocationCoordinates struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
	Accuracy  float64 `json:"accuracy"`
}

LocationCoordinates represents geographic coordinates

type LocationPoint

type LocationPoint struct {
	Latitude  float64
	Longitude float64
	RSSI      int
}

LocationPoint represents a point in 2D space

type LocationResult

type LocationResult struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
	Accuracy  float64 `json:"accuracy"`
}

LocationResult contains the calculated location information for logging

type Manufacturer added in v0.0.2

type Manufacturer struct {
	ID          string `yaml:"id"`
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
	PortalURL   string `yaml:"portal_url"`
}

Manufacturer represents manufacturer information

type ManufacturerConfig added in v0.0.2

type ManufacturerConfig struct {
	Manufacturers []Manufacturer `yaml:"manufacturers"`
}

ManufacturerConfig represents the root YAML structure for manufacturers

type OrgDiscoveryRequest

type OrgDiscoveryRequest struct {
	EventType   OrgEventType `json:"event_type"` // "org.discovery.request"
	EventID     string       `json:"event_id"`
	Timestamp   time.Time    `json:"timestamp"`
	ServiceName string       `json:"service_name"` // "transformer-service"
	ReplyTo     string       `json:"reply_to"`     // Queue name for response
}

OrgDiscoveryRequest is sent by transformer to request all active orgs

type OrgEvent

type OrgEvent struct {
	EventType OrgEventType `json:"event_type"`
	EventID   string       `json:"event_id"`
	Timestamp time.Time    `json:"timestamp"`
	Payload   Payload      `json:"payload"`
}

OrgEvent represents an organization lifecycle event

type OrgEventType

type OrgEventType string

OrgEventType represents the type of organization event

const (
	OrgCreated     OrgEventType = "org.created"
	OrgUpdated     OrgEventType = "org.updated"
	OrgDeactivated OrgEventType = "org.deactivated"
	OrgDeleted     OrgEventType = "org.deleted"

	// Bootstrap/Discovery events (Request-Response pattern)
	OrgDiscoveryReq  OrgEventType = "org.discovery.request"  // Transformer → Console
	OrgDiscoveryResp OrgEventType = "org.discovery.response" // Console → Transformer
)

type Payload

type Payload struct {
	ID               string    `json:"id"`
	Slug             string    `json:"slug"`
	Name             string    `json:"name"`
	Vhost            string    `json:"vhost"`
	Exchange         string    `json:"exchange"`
	AMQPURL          string    `json:"amqp_url"`
	TransformerQueue string    `json:"transformer_queue"`
	TransformedQueue string    `json:"transformed_queue"`
	IsActive         bool      `json:"is_active"`
	CreatedAt        time.Time `json:"created_at"`
	UpdatedAt        time.Time `json:"updated_at"`
}

Organization represents organization data in events

type ProcessingInfo

type ProcessingInfo struct {
	LocationCalculated bool            `json:"location_calculated"`
	ErrorMessage       string          `json:"error_message,omitempty"`
	GatewayCount       int             `json:"gateway_count"`
	HasLocationData    bool            `json:"has_location_data"`
	LocationResult     *LocationResult `json:"location_result,omitempty"`
}

ProcessingInfo contains information about how the data was processed

type RawDataLog

type RawDataLog struct {
	ID              string                 `json:"id"`
	Timestamp       string                 `json:"timestamp"`
	DeviceEUI       string                 `json:"device_eui,omitempty"`
	DeviceID        string                 `json:"device_id,omitempty"`
	DeviceName      string                 `json:"device_name,omitempty"`
	EventType       string                 `json:"event_type,omitempty"`
	RawData         string                 `json:"raw_data,omitempty"`
	DecodedRawData  interface{}            `json:"decoded_raw_data,omitempty"`
	OriginalPayload map[string]interface{} `json:"original_payload"`
	ProcessingInfo  ProcessingInfo         `json:"processing_info"`
}

RawDataLog represents the structure for logging raw data for training

type ReceiveDataRequest

type ReceiveDataRequest struct {
	Payload map[string]interface{} `json:"payload"`
}

ReceiveDataRequest represents the incoming webhook payload

type TelemetryDeviceInfo

type TelemetryDeviceInfo struct {
	Identifiers  []string `json:"identifiers"`  // ["70b3d57ed005b847"]
	Name         string   `json:"name"`         // "Conference Room Tracker"
	Manufacturer string   `json:"manufacturer"` // "RAKwireless"
	Model        string   `json:"model"`        // "RAK2270"
	ModelID      string   `json:"model_id"`     // "rak2270"
}

TelemetryDeviceInfo represents device information for telemetry

type TelemetryEntity

type TelemetryEntity struct {
	UniqueID    string                 `json:"unique_id"`                     // "acme_70b3d57ed005b847_location"
	EntityID    string                 `json:"entity_id"`                     // "device_tracker.acme_rakwireless_rak2270_70b3d57ed005b847_location"
	EntityType  string                 `json:"entity_type"`                   // "device_tracker", "sensor"
	DeviceClass string                 `json:"device_class,omitempty"`        // "location", "battery"
	Name        string                 `json:"name"`                          // "Location", "Battery Level"
	State       interface{}            `json:"state"`                         // "home", 85, 22.5
	Attributes  map[string]interface{} `json:"attributes,omitempty"`          // Additional properties
	DisplayType []string               `json:"display_type,omitempty"`        // UI hints (e.g., map, chart)
	UnitOfMeas  string                 `json:"unit_of_measurement,omitempty"` // "%", "°C"
	Icon        string                 `json:"icon,omitempty"`
	Timestamp   string                 `json:"timestamp"`
}

TelemetryEntity represents a single entity in telemetry output

type TelemetryPayload

type TelemetryPayload struct {
	Organization string                 `json:"organization"`
	DeviceEUI    string                 `json:"device_eui"`
	DeviceID     string                 `json:"device_id,omitempty"`
	SpaceSlug    string                 `json:"space_slug,omitempty"`
	DeviceInfo   TelemetryDeviceInfo    `json:"device_info"`
	Entities     []TelemetryEntity      `json:"entities"`
	Timestamp    string                 `json:"timestamp"`
	Source       string                 `json:"source"`
	Metadata     map[string]interface{} `json:"metadata,omitempty"`
}

TelemetryPayload represents the new entity-based telemetry output

type TransformedDeviceData

type TransformedDeviceData struct {
	DeviceEUI    string                 `json:"device_eui"`
	DeviceID     string                 `json:"device_id"`
	SpaceSlug    string                 `json:"space_slug"`
	IsPublished  bool                   `json:"is_published"`
	Location     LocationCoordinates    `json:"location"`
	Timestamp    string                 `json:"timestamp"`
	Organization string                 `json:"organization"`
	Metadata     map[string]interface{} `json:"metadata"`
	Source       string                 `json:"source"`
}

TransformedDeviceData represents the final transformed output (DEPRECATED: Use TelemetryPayload)

type UplinkMessage

type UplinkMessage struct {
	RxMetadata []Gateway      `json:"rx_metadata"`
	Settings   UplinkSettings `json:"settings"`
}

UplinkMessage represents the uplink message structure from LoRaWAN

type UplinkSettings

type UplinkSettings struct {
	Frequency int64 `json:"frequency"`
}

UplinkSettings contains uplink transmission settings

Jump to

Keyboard shortcuts

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