@@ -10,31 +10,9 @@ const (
1010)
1111
1212type ChannelUS struct {
13- frequency uint32
14- bandwidth uint8
15- spreadingFactor uint8
16- codingRate uint8
17- preambleLength uint16
18- txPowerDBm int8
13+ channel
1914}
2015
21- // Getter functions
22- func (c * ChannelUS ) Frequency () uint32 { return c .frequency }
23- func (c * ChannelUS ) Bandwidth () uint8 { return c .bandwidth }
24- func (c * ChannelUS ) SpreadingFactor () uint8 { return c .spreadingFactor }
25- func (c * ChannelUS ) CodingRate () uint8 { return c .codingRate }
26- func (c * ChannelUS ) PreambleLength () uint16 { return c .preambleLength }
27- func (c * ChannelUS ) TxPowerDBm () int8 { return c .txPowerDBm }
28-
29- // Set functions
30- // TODO: validate input
31- func (c * ChannelUS ) SetFrequency (v uint32 ) { c .frequency = v }
32- func (c * ChannelUS ) SetBandwidth (v uint8 ) { c .bandwidth = v }
33- func (c * ChannelUS ) SetSpreadingFactor (v uint8 ) { c .spreadingFactor = v }
34- func (c * ChannelUS ) SetCodingRate (v uint8 ) { c .codingRate = v }
35- func (c * ChannelUS ) SetPreambleLength (v uint16 ) { c .preambleLength = v }
36- func (c * ChannelUS ) SetTxPowerDBm (v int8 ) { c .txPowerDBm = v }
37-
3816func (c * ChannelUS ) Next () bool {
3917 switch c .Bandwidth () {
4018 case lora .Bandwidth_125_0 :
@@ -76,43 +54,29 @@ func stepFrequency500(freq uint32) (uint32, bool) {
7654 return f , true
7755}
7856
79- type RegionSettingsUS915 struct {
80- joinRequestChannel * ChannelUS
81- joinAcceptChannel * ChannelUS
82- uplinkChannel * ChannelUS
57+ type SettingsUS915 struct {
58+ settings
8359}
8460
85- func US915 () * RegionSettingsUS915 {
86- return & RegionSettingsUS915 {
87- joinRequestChannel : & ChannelUS {lora .MHz_902_3 ,
61+ func US915 () * SettingsUS915 {
62+ return & SettingsUS915 { settings : settings {
63+ joinRequestChannel : & ChannelUS {channel : channel { lora .MHz_902_3 ,
8864 lora .Bandwidth_125_0 ,
8965 lora .SpreadingFactor10 ,
9066 lora .CodingRate4_5 ,
9167 US915_DEFAULT_PREAMBLE_LEN ,
92- US915_DEFAULT_TX_POWER_DBM },
93- joinAcceptChannel : & ChannelUS {0 ,
68+ US915_DEFAULT_TX_POWER_DBM }} ,
69+ joinAcceptChannel : & ChannelUS {channel : channel { 0 ,
9470 lora .Bandwidth_500_0 ,
9571 lora .SpreadingFactor9 ,
9672 lora .CodingRate4_5 ,
9773 US915_DEFAULT_PREAMBLE_LEN ,
98- US915_DEFAULT_TX_POWER_DBM },
99- uplinkChannel : & ChannelUS {lora .Mhz_903_0 ,
74+ US915_DEFAULT_TX_POWER_DBM }} ,
75+ uplinkChannel : & ChannelUS {channel : channel { lora .Mhz_903_0 ,
10076 lora .Bandwidth_500_0 ,
10177 lora .SpreadingFactor9 ,
10278 lora .CodingRate4_5 ,
10379 US915_DEFAULT_PREAMBLE_LEN ,
104- US915_DEFAULT_TX_POWER_DBM },
105- }
106- }
107-
108- func (r * RegionSettingsUS915 ) JoinRequestChannel () Channel {
109- return r .joinRequestChannel
110- }
111-
112- func (r * RegionSettingsUS915 ) JoinAcceptChannel () Channel {
113- return r .joinAcceptChannel
114- }
115-
116- func (r * RegionSettingsUS915 ) UplinkChannel () Channel {
117- return r .uplinkChannel
80+ US915_DEFAULT_TX_POWER_DBM }},
81+ }}
11882}
0 commit comments