From fd42ee3775d8696dac0f08fe4c66d83dd6efd3d3 Mon Sep 17 00:00:00 2001 From: Emilio Garcia Date: Fri, 13 Oct 2023 13:20:57 -0400 Subject: [PATCH] LoRa WAN add setter functions --- lora/lorawan/region/au915.go | 8 ++++++++ lora/lorawan/region/eu868.go | 8 ++++++++ lora/lorawan/region/us915.go | 9 +++++++++ 3 files changed, 25 insertions(+) diff --git a/lora/lorawan/region/au915.go b/lora/lorawan/region/au915.go index 5a63b2dd3..cbfd25d07 100644 --- a/lora/lorawan/region/au915.go +++ b/lora/lorawan/region/au915.go @@ -24,6 +24,14 @@ func (c *ChannelAU) CodingRate() uint8 { return c.codingRate } func (c *ChannelAU) PreambleLength() uint16 { return c.preambleLength } func (c *ChannelAU) TxPowerDBm() int8 { return c.txPowerDBm } +// Set functions +func (c *ChannelAU) SetFrequency(v uint32) { c.frequency = v } +func (c *ChannelAU) SetBandwidth(v uint8) { c.bandwidth = v } +func (c *ChannelAU) SetSpreadingFactor(v uint8) { c.spreadingFactor = v } +func (c *ChannelAU) SetCodingRate(v uint8) { c.codingRate = v } +func (c *ChannelAU) SetPreambleLength(v uint16) { c.preambleLength = v } +func (c *ChannelAU) SetTxPowerDBm(v int8) { c.txPowerDBm = v } + func (c *ChannelAU) Next() bool { return false } diff --git a/lora/lorawan/region/eu868.go b/lora/lorawan/region/eu868.go index d35d4a966..d8325ccab 100644 --- a/lora/lorawan/region/eu868.go +++ b/lora/lorawan/region/eu868.go @@ -24,6 +24,14 @@ func (c *ChannelEU) CodingRate() uint8 { return c.codingRate } func (c *ChannelEU) PreambleLength() uint16 { return c.preambleLength } func (c *ChannelEU) TxPowerDBm() int8 { return c.txPowerDBm } +// Set functions +func (c *ChannelEU) SetFrequency(v uint32) { c.frequency = v } +func (c *ChannelEU) SetBandwidth(v uint8) { c.bandwidth = v } +func (c *ChannelEU) SetSpreadingFactor(v uint8) { c.spreadingFactor = v } +func (c *ChannelEU) SetCodingRate(v uint8) { c.codingRate = v } +func (c *ChannelEU) SetPreambleLength(v uint16) { c.preambleLength = v } +func (c *ChannelEU) SetTxPowerDBm(v int8) { c.txPowerDBm = v } + func (c *ChannelEU) Next() bool { return false } diff --git a/lora/lorawan/region/us915.go b/lora/lorawan/region/us915.go index b6ab2a6a9..68ec9771a 100644 --- a/lora/lorawan/region/us915.go +++ b/lora/lorawan/region/us915.go @@ -26,6 +26,15 @@ func (c *ChannelUS) CodingRate() uint8 { return c.codingRate } func (c *ChannelUS) PreambleLength() uint16 { return c.preambleLength } func (c *ChannelUS) TxPowerDBm() int8 { return c.txPowerDBm } +// Set functions +// TODO: validate input +func (c *ChannelUS) SetFrequency(v uint32) { c.frequency = v } +func (c *ChannelUS) SetBandwidth(v uint8) { c.bandwidth = v } +func (c *ChannelUS) SetSpreadingFactor(v uint8) { c.spreadingFactor = v } +func (c *ChannelUS) SetCodingRate(v uint8) { c.codingRate = v } +func (c *ChannelUS) SetPreambleLength(v uint16) { c.preambleLength = v } +func (c *ChannelUS) SetTxPowerDBm(v int8) { c.txPowerDBm = v } + func (c *ChannelUS) Next() bool { switch c.Bandwidth() { case lora.Bandwidth_125_0: