Add ip/port setting
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Akari.Provider.WaveshareUART.Users;
|
||||
using System;
|
||||
using System.IO;
|
||||
using WaveshareUARTFingerprintSensor;
|
||||
|
||||
@@ -6,7 +7,9 @@ namespace Akari.Provider.WaveshareUART
|
||||
{
|
||||
public class WaveshareUARTProvider
|
||||
{
|
||||
public const string SettingsFilePath = "settings.txt";
|
||||
public const string SerialPortFilePath = "serial.txt";
|
||||
public const string ServerIPFilePath = "ip.txt";
|
||||
public const string ServerPortFilePath = "port.txt";
|
||||
|
||||
public static WaveshareUARTProvider Instance { get; }
|
||||
|
||||
@@ -25,7 +28,21 @@ namespace Akari.Provider.WaveshareUART
|
||||
|
||||
public void InitSensor()
|
||||
{
|
||||
FingerprintSensor = new FingerprintSensor(File.ReadAllText(SettingsFilePath));
|
||||
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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user