mirror of
https://gitea.tendokyu.moe/ppc/amnet.git
synced 2026-10-10 00:18:09 +03:00
update server to implement felica polling
This commit is contained in:
+24
-13
@@ -36,7 +36,7 @@ public static class DllMain
|
||||
CancellationTokenRegistration? cancellationRegistration = null;
|
||||
cancellationRegistration = App.Lifetime.ApplicationStarted.Register(() =>
|
||||
{
|
||||
App.Logger.LogInformation("AMNet Server ({gameId}) started successfully.", Config.GameId);
|
||||
App.Logger.LogInformation("AMNet Server ({gameId}) started successfully.", Config.GameId ?? "SXXX");
|
||||
App.Logger.LogInformation("Visit {addr} from a mobile device on the same network to get started.", WebAddress);
|
||||
|
||||
// ReSharper disable once AccessToModifiedClosure
|
||||
@@ -71,7 +71,7 @@ public static class DllMain
|
||||
using var aimeTxtReader = new StreamReader(File.OpenRead(Config.AimeTxtPath), Encoding.UTF8);
|
||||
|
||||
var fileName = Path.GetFileName(Config.AimeTxtPath);
|
||||
var cardResult = App.Services.GetRequiredService<CardPresenter>().SetCard(aimeTxtReader.ReadLine());
|
||||
var cardResult = App.Services.GetRequiredService<CardPresenter>().SetCard(aimeTxtReader.ReadLine(), null);
|
||||
|
||||
if (cardResult == null)
|
||||
{
|
||||
@@ -98,25 +98,36 @@ public static class DllMain
|
||||
return 1;
|
||||
}
|
||||
|
||||
var card = App.Services.GetRequiredService<CardPresenter>().TakeActiveCard();
|
||||
// if physical cards are being directed to
|
||||
var card = App.Services.GetRequiredService<CardPresenter>().TakeActiveCard(Config.PhysicalCardUseIDm ? false : null);
|
||||
if (card?.Expired != false)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Marshal.Copy(card.Value, 0, luid, (int)luidSize);
|
||||
return 0;
|
||||
}
|
||||
finally
|
||||
{
|
||||
App.Logger.LogInformation("Card read in: {cardId}", card);
|
||||
}
|
||||
Marshal.Copy(card.AccessCode, 0, luid, (int)luidSize);
|
||||
App.Logger.LogInformation("Access Code read: {cardId}", CardPresenter.FormatHexCode(card.AccessCode));
|
||||
return 0;
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "aime_io_nfc_get_felica_id")]
|
||||
public static unsafe int GetFelicaId(byte unitNo, ulong* idm) => 1; // felica not supported
|
||||
public static int GetFelicaId(byte unitNo, IntPtr idm)
|
||||
{
|
||||
if (!Config.PhysicalCardUseIDm || unitNo != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
var card = App.Services.GetRequiredService<CardPresenter>().TakeActiveCard(true);
|
||||
if (card?.Expired != false)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Marshal.Copy(card.IDm, 0, idm, sizeof(ulong));
|
||||
App.Logger.LogInformation("FeliCa IDm read: {idm}", card.IDm);
|
||||
return 0;
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "aime_io_led_set_color")]
|
||||
public static void SetLedColour(byte unitNo, byte r, byte g, byte b)
|
||||
|
||||
Reference in New Issue
Block a user