-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLTEConfig.cs
147 lines (126 loc) · 4.54 KB
/
LTEConfig.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
using hio_dotnet.Common.Enums.LTE;
using hio_dotnet.Common.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using hio_dotnet.Common.Enums.LoRaWAN;
using System.Reflection;
namespace hio_dotnet.Common.Config
{
public class LTEConfig : ConfigCommon
{
#region ConnectionParams
[ConfigSerializationAttribute(true, false, "lte", "test")]
public bool Test { get; set; } = false;
[ConfigSerializationAttribute(true, false, "lte", "nb-iot-mode")]
public bool NbIotMode { get; set; } = false;
[ConfigSerializationAttribute(true, false, "lte", "lte-m-mode")]
public bool LteMMode { get; set; } = true;
[ConfigSerializationAttribute(true, false, "lte", "autoconn")]
public bool AutoConn { get; set; } = false;
[ConfigSerializationAttribute(true, false, "lte", "clksync")]
public bool ClkSync { get; set; } = false;
[ConfigSerializationAttribute(true, false, "lte", "plmnid")]
public int PlmnId { get; set; } = 0;
[ConfigSerializationAttribute(true, false, "lte", "port")]
public int Port { get; set; } = 0;
[ConfigSerializationAttribute(true, false, "lte", "antenna")]
public AntennaType Antenna { get; set; } = AntennaType.Internal;
[ConfigSerializationAttribute(true, false, "lte", "auth")]
public LTEAuthType Authorization { get; set; } = LTEAuthType.None;
[ConfigSerializationAttribute(true, false, "lte", "apn")]
public string Apn { get; set; } = "default_apn";
[ConfigSerializationAttribute(true, false, "lte", "username")]
public string Username { get; set; } = string.Empty;
[ConfigSerializationAttribute(true, false, "lte", "password")]
public string Password { get; set; } = string.Empty;
[ConfigSerializationAttribute(true, false, "lte", "addr")]
public string Address { get; set; } = "0.0.0.0";
#endregion
#region FluentInterface
public LTEConfig WithTest(bool test)
{
Test = test;
return this;
}
public LTEConfig WithAntenna(AntennaType antenna)
{
Antenna = antenna;
return this;
}
public LTEConfig WithNbIotMode(bool nbIotMode)
{
NbIotMode = nbIotMode;
return this;
}
public LTEConfig WithLteMMode(bool lteMMode)
{
LteMMode = lteMMode;
return this;
}
public LTEConfig WithAutoConn(bool autoConn)
{
AutoConn = autoConn;
return this;
}
public LTEConfig WithPlmnId(int plmnId)
{
PlmnId = plmnId;
return this;
}
public LTEConfig WithClkSync(bool clkSync)
{
ClkSync = clkSync;
return this;
}
public LTEConfig WithApn(string apn)
{
Apn = apn;
return this;
}
public LTEConfig WithAuth(LTEAuthType auth)
{
Authorization = auth;
return this;
}
public LTEConfig WithUsername(string username)
{
Username = username;
return this;
}
public LTEConfig WithPassword(string password)
{
Password = password;
return this;
}
public LTEConfig WithAddress(string address)
{
Address = address;
return this;
}
public LTEConfig WithPort(int port)
{
Port = port;
return this;
}
#endregion
#region ParsingMethods
public void ParseLine(string line)
{
if (string.IsNullOrEmpty(line))
throw new ArgumentNullException("LTE Parsing>> Cannot parse null or empty line");
if (line.Contains("lrw "))
throw new ArgumentException("LTE Parsing>> The config line is not for LTE. It belongs to LoRaWAN parsing.");
if (line.Contains("ble "))
throw new ArgumentException("LTE Parsing>> The config line is not for LTE. It belongs to BLE parsing.");
if (line.Contains("app "))
throw new ArgumentException("LTE Parsing>> The config line is not for LTE. It belongs to APP parsing.");
if (line.Contains("lte config "))
line = line.Replace("lte config ", string.Empty).ReplaceLineEndings();
ParseLineToProp(line);
}
#endregion
}
}