58 lines
1.5 KiB
C#
58 lines
1.5 KiB
C#
using Akari.Provider.WaveshareUART.Users;
|
|
using System;
|
|
using System.IO;
|
|
using WaveshareUARTFingerprintSensor;
|
|
|
|
namespace Akari.Provider.WaveshareUART
|
|
{
|
|
public class WaveshareUARTProvider
|
|
{
|
|
public const string SerialPortFilePath = "serial.txt";
|
|
public const string ServerIPFilePath = "ip.txt";
|
|
public const string ServerPortFilePath = "port.txt";
|
|
|
|
public static WaveshareUARTProvider Instance { get; }
|
|
|
|
static WaveshareUARTProvider()
|
|
{
|
|
Instance = new WaveshareUARTProvider();
|
|
}
|
|
|
|
public UsersManager UsersManager { get; }
|
|
public FingerprintSensor FingerprintSensor { get; private set; }
|
|
|
|
private WaveshareUARTProvider()
|
|
{
|
|
UsersManager = new UsersManager();
|
|
}
|
|
|
|
public void InitSensor()
|
|
{
|
|
try
|
|
{
|
|
FingerprintSensor = new FingerprintSensor(File.ReadAllText(SerialPortFilePath));
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.ForegroundColor = ConsoleColor.Red;
|
|
Console.WriteLine(e);
|
|
|
|
Console.WriteLine();
|
|
Console.WriteLine($"Couldn't read settings file '{SerialPortFilePath}'");
|
|
Console.WriteLine($"Launch the program with '-c' to config the provider");
|
|
|
|
Environment.Exit(1);
|
|
}
|
|
|
|
FingerprintSensor.Start();
|
|
}
|
|
|
|
public void FingerprintLoop()
|
|
{
|
|
InitSensor();
|
|
|
|
new TcpService().Start();
|
|
}
|
|
}
|
|
}
|