|
|
@ -48,10 +48,56 @@ public class RfidApi
|
|
|
|
Log.Error($"RfidApi StopRead err e={e}");
|
|
|
|
Log.Error($"RfidApi StopRead err e={e}");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static async Task<bool> DisConnect()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Info("DisConnect");
|
|
|
|
|
|
|
|
string url = BASE_URL + "/Api/Close";
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
string s = await _httpClient.GetStringAsync(url);
|
|
|
|
|
|
|
|
Log.Info($"DisConnect resp={s}");
|
|
|
|
|
|
|
|
return bool.Parse(s);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Error($"RfidApi DisConnect err e={e}");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static async Task<bool> Connect()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var disConnect = await DisConnect();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Log.Info("Connect");
|
|
|
|
|
|
|
|
string url = BASE_URL + "/Api/Open";
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
string s = await _httpClient.GetStringAsync(url);
|
|
|
|
|
|
|
|
Log.Info($"Connect resp={s}");
|
|
|
|
|
|
|
|
return bool.Parse(s);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Error($"RfidApi Connect err e={e}");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static async Task<RfidReadModel?> ReadRifd()
|
|
|
|
public static async Task<RfidReadModel?> ReadRifd()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
//断连
|
|
|
|
|
|
|
|
var connect = await Connect();
|
|
|
|
|
|
|
|
if (!connect)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Info("Rfid connect fail");
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Log.Info("ReadRifd");
|
|
|
|
Log.Info("ReadRifd");
|
|
|
|
string url = BASE_URL + "/Api/ReadRfidData";
|
|
|
|
string url = BASE_URL + "/Api/ReadRfidData";
|
|
|
|
try
|
|
|
|
try
|
|
|
|