Update buildAndTest.yml and remove unused dependencies

This commit is contained in:
Valentin Heiserer
2024-04-17 00:15:00 +02:00
committed by GitHub
parent 402a2d71e2
commit 8bf8140247
14 changed files with 145 additions and 176 deletions

View File

@@ -24,7 +24,6 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlets.CrossOriginFilter;
import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer;
import org.schafkopf.cardreader.CardReader;
import org.schafkopf.cardreader.GpioReader;
import org.schafkopf.cardreader.UsbCardReader;
/** Main Class that represents the Backend Server. */
@@ -53,19 +52,8 @@ public class BackendServer {
schafkopfGame = new Schafkopf(this);
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("win")) {
// Windows
nfcLeser = new UsbCardReader(this);
} else if (osName.contains("nix") || osName.contains("nux") || osName.contains("mac")) {
// Unix/Linux/Mac
// You can add additional checks for specific Linux distributions or macOS versions if needed
// For now, assuming Raspberry Pi is running Linux
nfcLeser = new GpioReader(this);
} else {
// Other OS
throw new RuntimeException("Unsupported OS: " + osName);
}
nfcLeser = new UsbCardReader(this);
// Setup the basic application "context" for this application at "/"
// This is also known as the handler tree (in jetty speak)

View File

@@ -1,70 +0,0 @@
package org.schafkopf.cardreader;
import com.pi4j.io.i2c.I2C;
import java.io.IOException;
import mk.hsilomedus.pn532.Pn532ContextHelper;
import mk.hsilomedus.pn532.Pn532I2c;
import mk.hsilomedus.pn532.Pn532SamThread;
import mk.hsilomedus.pn532.Pn532SamThread.Pn532SamThreadListener;
import org.schafkopf.BackendServer;
/** Class that represents the NFC Reader. */
public final class GpioReader extends CardReader {
/**
* Creates an Instance of the KartenLeser.
*
* @param server Backend Server to call methods on.
*/
public GpioReader(BackendServer server) {
super(server);
new Thread(
() -> {
new KartenListener().run();
})
.start();
}
public static final void main(String[] args) throws IOException {}
private static class KartenListener implements Pn532SamThreadListener {
@SuppressWarnings("rawtypes")
Pn532SamThread<I2C> i2cThread = new Pn532SamThread<>(this, new Pn532I2c());
public void run() {
Pn532ContextHelper.initialize();
i2cThread.start();
}
public void close() {
closeThread(i2cThread);
Pn532ContextHelper.shutdown();
}
@Override
public void receiveMessage(String message) {
System.out.println(message);
}
@Override
public void uidReceived(String displayName, byte[] uid) {
server.nfcGelesen(Pn532SamThreadListener.getUidString(uid));
}
@SuppressWarnings("rawtypes")
private void closeThread(Pn532SamThread thread) {
if (thread != null && thread.isAlive()) {
thread.close();
try {
thread.join();
} catch (InterruptedException e) {
System.out.println("Error closing thread: " + e.getMessage());
Thread.currentThread().interrupt();
}
}
}
}
}