template

package
v0.0.0-...-55fa497 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTemplateNotFound = errors.New("template not found")
	ErrInvalidTemplate  = errors.New("invalid template")
)

Functions

This section is empty.

Types

type DeviceTemplate

type DeviceTemplate struct {
	ID   int    `json:"id"`
	Name string `json:"name"` // Template name (e.g., "AM319 Temperature Sensor")

	// Activation mode: "otaa" or "abp" (default "otaa")
	ActivationMode string `json:"activationMode"`

	// Region configuration
	Region int `json:"region"` // Region code (1=EU868, 2=US915, etc.)

	// Class support
	SupportedClassB bool `json:"supportedClassB"`
	SupportedClassC bool `json:"supportedClassC"`

	// Features
	SupportedADR bool    `json:"supportedADR"`
	Range        float64 `json:"range"` // Antenna range in meters

	// Data rate
	DataRate    uint8 `json:"dataRate"`    // Initial uplink data rate
	RX1DROffset uint8 `json:"rx1DROffset"` // RX1 data rate offset

	// Timing (all in milliseconds for RX windows, seconds for intervals)
	SendInterval int `json:"sendInterval"` // Uplink interval in seconds
	AckTimeout   int `json:"ackTimeout"`   // ACK timeout in seconds

	// RX1 Window settings (milliseconds)
	RX1Delay    int `json:"rx1Delay"`
	RX1Duration int `json:"rx1Duration"`

	// RX2 Window settings (milliseconds)
	RX2Delay     int     `json:"rx2Delay"`
	RX2Duration  int     `json:"rx2Duration"`
	RX2Frequency float64 `json:"rx2Frequency"` // RX2 frequency in Hz
	RX2DataRate  int     `json:"rx2DataRate"`

	// Frame settings
	FPort            uint8 `json:"fport"`
	NbRetransmission int   `json:"nbRetransmission"`
	MType            int   `json:"mtype"` // 0=UnconfirmedDataUp, 1=ConfirmedDataUp

	// Payload settings
	SupportedFragment bool `json:"supportedFragment"` // true=fragment, false=truncate

	// Codec configuration
	UseCodec bool `json:"useCodec"`
	CodecID  int  `json:"codecId"`

	// ChirpStack Integration configuration
	IntegrationEnabled bool   `json:"integrationEnabled"`
	IntegrationID      int    `json:"integrationId"`
	DeviceProfileID    string `json:"deviceProfileId"`

	// ThingsBoard Integration configuration
	TBIntegrationEnabled bool   `json:"tbIntegrationEnabled"`
	TBIntegrationID      int    `json:"tbIntegrationId"`
	TBDeviceProfileID    string `json:"tbDeviceProfileId"`
	TBCustomerID         string `json:"tbCustomerId"`
}

DeviceTemplate represents a template for bulk device creation

func GetDefaultTemplates

func GetDefaultTemplates(codecLookup func(name string) int) []*DeviceTemplate

GetDefaultTemplates returns built-in default templates for common device types codecLookup is an optional function to resolve codec names to IDs

func NewDeviceTemplate

func NewDeviceTemplate(name string) *DeviceTemplate

NewDeviceTemplate creates a new template (ID must be set by the registry)

func (*DeviceTemplate) Clone

func (t *DeviceTemplate) Clone() *DeviceTemplate

Clone returns a deep copy of the template

func (*DeviceTemplate) Validate

func (t *DeviceTemplate) Validate() error

Validate checks if the template has all required fields

Jump to

Keyboard shortcuts

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