Skip to content

Commit f40c9b3

Browse files
committed
Cleanup
1 parent 51f65c6 commit f40c9b3

26 files changed

+230
-626
lines changed

src/HeboTech.ATLib.TestConsole/Program.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using HeboTech.ATLib.Communication;
2+
using HeboTech.ATLib.Inputs;
23
using HeboTech.ATLib.Modems;
34
using HeboTech.ATLib.Parsers;
5+
using HeboTech.ATLib.Results;
46
using System;
57
using System.IO.Ports;
68
using System.Threading.Tasks;
@@ -23,7 +25,7 @@ static async Task Main(string[] args)
2325

2426
AtChannel atChannel = new AtChannel(comm);
2527

26-
AdafruitFona modem = new AdafruitFona(atChannel);
28+
AdafruitFona3G modem = new AdafruitFona3G(atChannel);
2729
modem.IncomingCall += Modem_IncomingCall;
2830
modem.MissedCall += Modem_MissedCall;
2931

@@ -32,9 +34,12 @@ static async Task Main(string[] args)
3234
var simStatus = modem.GetSimStatus();
3335
Console.WriteLine($"SIM Status: {simStatus}");
3436

35-
if (simStatus == States.SimStatus.SIM_PIN)
37+
var remainingCodeAttemps = modem.GetRemainingPinPukAttempts();
38+
Console.WriteLine($"Remaining attempts: {remainingCodeAttemps}");
39+
40+
if (simStatus == SimStatus.SIM_PIN)
3641
{
37-
var simPinStatus = modem.EnterSimPin(new Pin(args[0]));
42+
var simPinStatus = modem.EnterSimPin(new PersonalIdentificationNumber(args[0]));
3843
Console.WriteLine($"SIM PIN Status: {simPinStatus}");
3944

4045
simStatus = modem.GetSimStatus();
@@ -50,7 +55,7 @@ static async Task Main(string[] args)
5055
var smsReference = modem.SendSMS(new PhoneNumber(args[1]), "Hello ATLib!");
5156
Console.WriteLine($"SMS Reference: {smsReference}");
5257

53-
Console.WriteLine("Done. Press any key to exit...");
58+
Console.WriteLine("Done. Press 'a' to answer call, 'h' to hang up, and 'q' to exit...");
5459
ConsoleKey key;
5560
while ((key = Console.ReadKey().Key) != ConsoleKey.Q)
5661
{

src/HeboTech.ATLib/EnumExtensions.cs renamed to src/HeboTech.ATLib/Extensions/EnumExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.ComponentModel;
33

4-
namespace HeboTech.ATLib
4+
namespace HeboTech.ATLib.Extensions
55
{
66
public static class EnumExtensions
77
{

src/HeboTech.ATLib/HeboTech.ATLib.csproj

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
<ItemGroup>
1919
<Compile Remove="Communication\ScriptCommunicator.cs" />
2020
<Compile Remove="Communication\SocketCommunicator.cs" />
21-
<Compile Remove="Parsers\LineReader.cs" />
2221
</ItemGroup>
2322

2423
<ItemGroup>
@@ -29,10 +28,4 @@
2928
<PackageReference Include="System.Threading.Channels" Version="4.7.1" />
3029
</ItemGroup>
3130

32-
<ItemGroup>
33-
<Folder Include="Commands\3GPP_TS_27_005\" />
34-
<Folder Include="Commands\3GPP_TS_27_007\" />
35-
<Folder Include="Commands\V25TER\" />
36-
</ItemGroup>
37-
3831
</Project>

src/HeboTech.ATLib/ITimeProvider.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Text.RegularExpressions;
3+
4+
namespace HeboTech.ATLib.Inputs
5+
{
6+
public class PersonalIdentificationNumber
7+
{
8+
public PersonalIdentificationNumber(string pin)
9+
{
10+
if (!Regex.IsMatch(pin, @"^\d{4}$"))
11+
throw new ArgumentException("Invalid PIN");
12+
Pin = pin;
13+
}
14+
15+
public string Pin { get; }
16+
17+
public override string ToString()
18+
{
19+
return Pin;
20+
}
21+
}
22+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace HeboTech.ATLib
1+
namespace HeboTech.ATLib.Inputs
22
{
33
public class PhoneNumber
44
{

src/HeboTech.ATLib/PhoneNumberFormat.cs renamed to src/HeboTech.ATLib/Inputs/PhoneNumberFormat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace HeboTech.ATLib
1+
namespace HeboTech.ATLib.Inputs
22
{
33
public enum PhoneNumberFormat : byte
44
{

src/HeboTech.ATLib/Modems/AdafruitFona.cs renamed to src/HeboTech.ATLib/Modems/AdafruitFona3G.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace HeboTech.ATLib.Modems
44
{
5-
public class AdafruitFona : ModemBase
5+
public class AdafruitFona3G : ModemBase
66
{
7-
public AdafruitFona(AtChannel channel)
7+
public AdafruitFona3G(AtChannel channel)
88
: base(channel)
99
{
1010
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using HeboTech.ATLib.Events;
2+
using HeboTech.ATLib.Inputs;
3+
using HeboTech.ATLib.Results;
4+
using System;
5+
6+
namespace HeboTech.ATLib.Modems
7+
{
8+
public interface IModem
9+
{
10+
event EventHandler<IncomingCallEventArgs> IncomingCall;
11+
event EventHandler<MissedCallEventArgs> MissedCall;
12+
13+
CommandStatus AnswerIncomingCall();
14+
CommandStatus DisableEcho();
15+
CommandStatus EnterSimPin(PersonalIdentificationNumber pin);
16+
BatteryStatus GetBatteryStatus();
17+
SignalStrength GetSignalStrength();
18+
SimStatus GetSimStatus();
19+
CallDetails Hangup();
20+
SmsReference SendSMS(PhoneNumber phoneNumber, string message);
21+
RemainingPinPukAttempts GetRemainingPinPukAttempts();
22+
}
23+
}

0 commit comments

Comments
 (0)