mirror of
https://github.com/Vale54321/schafkopf-bot.git
synced 2025-12-15 19:29:33 +01:00
Nfc reader (#2)
* added pn532.jar * added pn532 * changed KartenLeserer * added leser to BackendServer * added welcheKarteSticht methode * added welcheKarteSticht methode * added sendKarte tofrontend when scanned * added build config * installed pn532 as local dependency * added local dependency to pom * edited KartenLeser * edited KartenLeser * edited KartenLeser * edited KartenLeser * edited pom * edited pom * edited pom * deleted unused files * added led * added led * added right dot env path * added right dot env path * added waitForScanMethod * added waitForScanMethod * added waitForScanMethod * added waitForScanMethod * added waitForScanMethod * added waitForScanMethod * removed unused print statements * removed unused imports * removed pn532 jar * removed pn532 jar
This commit is contained in:
committed by
GitHub
parent
e63f18f4b7
commit
7f2cf98607
1
.gitignore
vendored
1
.gitignore
vendored
@@ -36,3 +36,4 @@ build/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
/.idea/
|
||||
|
||||
8
.idea/.gitignore
generated
vendored
8
.idea/.gitignore
generated
vendored
@@ -1,8 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
7
.idea/encodings.xml
generated
7
.idea/encodings.xml
generated
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
13
.idea/misc.xml
generated
13
.idea/misc.xml
generated
@@ -1,13 +0,0 @@
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
124
.idea/uiDesigner.xml
generated
124
.idea/uiDesigner.xml
generated
@@ -1,124 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
||||
BIN
lib/pn532/pn532-sdk/1.0.2/pn532-sdk-1.0.2.jar
Normal file
BIN
lib/pn532/pn532-sdk/1.0.2/pn532-sdk-1.0.2.jar
Normal file
Binary file not shown.
1
lib/pn532/pn532-sdk/1.0.2/pn532-sdk-1.0.2.jar.md5
Normal file
1
lib/pn532/pn532-sdk/1.0.2/pn532-sdk-1.0.2.jar.md5
Normal file
@@ -0,0 +1 @@
|
||||
171ab3333078fd908c878b85563a5ccc
|
||||
1
lib/pn532/pn532-sdk/1.0.2/pn532-sdk-1.0.2.jar.sha1
Normal file
1
lib/pn532/pn532-sdk/1.0.2/pn532-sdk-1.0.2.jar.sha1
Normal file
@@ -0,0 +1 @@
|
||||
2bf9f8b279977cb5511cb075f4f2cd316e2bfa62
|
||||
9
lib/pn532/pn532-sdk/1.0.2/pn532-sdk-1.0.2.pom
Normal file
9
lib/pn532/pn532-sdk/1.0.2/pn532-sdk-1.0.2.pom
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>pn532</groupId>
|
||||
<artifactId>pn532-sdk</artifactId>
|
||||
<version>1.0.2</version>
|
||||
<description>POM was created from install:install-file</description>
|
||||
</project>
|
||||
1
lib/pn532/pn532-sdk/1.0.2/pn532-sdk-1.0.2.pom.md5
Normal file
1
lib/pn532/pn532-sdk/1.0.2/pn532-sdk-1.0.2.pom.md5
Normal file
@@ -0,0 +1 @@
|
||||
c0332fdac981cf53dc426b4fb6a173df
|
||||
1
lib/pn532/pn532-sdk/1.0.2/pn532-sdk-1.0.2.pom.sha1
Normal file
1
lib/pn532/pn532-sdk/1.0.2/pn532-sdk-1.0.2.pom.sha1
Normal file
@@ -0,0 +1 @@
|
||||
d6d7adcafc0119db3ec26d1bf8522fff1e78160c
|
||||
12
lib/pn532/pn532-sdk/maven-metadata-local.xml
Normal file
12
lib/pn532/pn532-sdk/maven-metadata-local.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>pn532</groupId>
|
||||
<artifactId>pn532-sdk</artifactId>
|
||||
<versioning>
|
||||
<release>1.0.2</release>
|
||||
<versions>
|
||||
<version>1.0.2</version>
|
||||
</versions>
|
||||
<lastUpdated>20231116111447</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
||||
1
lib/pn532/pn532-sdk/maven-metadata-local.xml.md5
Normal file
1
lib/pn532/pn532-sdk/maven-metadata-local.xml.md5
Normal file
@@ -0,0 +1 @@
|
||||
324d2ea359305a5cdef2fd48169e4c6d
|
||||
1
lib/pn532/pn532-sdk/maven-metadata-local.xml.sha1
Normal file
1
lib/pn532/pn532-sdk/maven-metadata-local.xml.sha1
Normal file
@@ -0,0 +1 @@
|
||||
68b60db960171920acbf8b33283396ded102e64e
|
||||
94
pom.xml
94
pom.xml
@@ -12,8 +12,76 @@
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<!-- DEPENDENCIES VERSIONS -->
|
||||
<slf4j.version>1.7.32</slf4j.version>
|
||||
<pi4j.version>2.4.0</pi4j.version>
|
||||
<maven-compiler.version>3.5.1</maven-compiler.version>
|
||||
|
||||
</properties>
|
||||
<build>
|
||||
<finalName>schafkopf-backend-build</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>org.example.BackendServer</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
<showWarnings>true</showWarnings>
|
||||
<verbose>false</verbose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
|
||||
</transformers>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>in-project</id>
|
||||
<name>In Project Repo</name>
|
||||
<url>file://${project.basedir}/lib</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<!-- To write basic websockets against -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
@@ -47,5 +115,31 @@
|
||||
<artifactId>dotenv-java</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- include Pi4J Core -->
|
||||
<dependency>
|
||||
<groupId>com.pi4j</groupId>
|
||||
<artifactId>pi4j-core</artifactId>
|
||||
<version>${pi4j.version}</version> <!-- Use the latest version available -->
|
||||
</dependency>
|
||||
|
||||
<!-- include Pi4J Plugins (Platforms and I/O Providers) -->
|
||||
<dependency>
|
||||
<groupId>com.pi4j</groupId>
|
||||
<artifactId>pi4j-plugin-raspberrypi</artifactId>
|
||||
<version>${pi4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pi4j</groupId>
|
||||
<artifactId>pi4j-plugin-pigpio</artifactId>
|
||||
<version>${pi4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>pn532</groupId>
|
||||
<artifactId>pn532-sdk</artifactId>
|
||||
<version>1.0.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -13,6 +13,7 @@ import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerI
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlets.CrossOriginFilter;
|
||||
@@ -33,17 +34,25 @@ public class BackendServer
|
||||
private final ServerConnector connector;
|
||||
|
||||
private final Schafkopf schafkopfGame;
|
||||
private final KartenLeser nfcLeser;
|
||||
private CountDownLatch nfcLatch = new CountDownLatch(1);
|
||||
|
||||
private Boolean readingMode = false;
|
||||
private String uidString = "";
|
||||
|
||||
public BackendServer()
|
||||
{
|
||||
Dotenv dotenv = Dotenv.configure().load();
|
||||
Dotenv dotenv = Dotenv.configure().directory("./").load();
|
||||
server = new Server();
|
||||
InetSocketAddress address = new InetSocketAddress(dotenv.get("VITE_APP_WEBSOCKET_IP"), 8080);
|
||||
connector = new ServerConnector(server);
|
||||
connector.setHost(address.getHostName());
|
||||
connector.setPort(address.getPort());
|
||||
server.addConnector(connector);
|
||||
|
||||
schafkopfGame = new Schafkopf(this);
|
||||
nfcLeser = new KartenLeser(this);
|
||||
|
||||
// Setup the basic application "context" for this application at "/"
|
||||
// This is also known as the handler tree (in jetty speak)
|
||||
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
|
||||
@@ -133,4 +142,23 @@ public class BackendServer
|
||||
public void showFarbe() {
|
||||
schafkopfGame.showFarbe();
|
||||
}
|
||||
public void nfcGelesen(String uidString) {
|
||||
if(this.uidString.equals(uidString)){
|
||||
return;
|
||||
}
|
||||
if(!this.readingMode){
|
||||
return;
|
||||
}
|
||||
|
||||
this.uidString = uidString;
|
||||
nfcLatch.countDown();
|
||||
}
|
||||
|
||||
public String waitForCardScan() throws InterruptedException {
|
||||
this.readingMode = true;
|
||||
nfcLatch.await();
|
||||
this.readingMode = false;
|
||||
nfcLatch = new CountDownLatch(1);
|
||||
return this.uidString;
|
||||
}
|
||||
}
|
||||
72
src/main/java/org/example/KartenLeser.java
Normal file
72
src/main/java/org/example/KartenLeser.java
Normal file
@@ -0,0 +1,72 @@
|
||||
package org.example;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.pi4j.Pi4J;
|
||||
import com.pi4j.io.i2c.I2C;
|
||||
import mk.hsilomedus.pn532.*;
|
||||
import mk.hsilomedus.pn532.Pn532SamThread.Pn532SamThreadListener;
|
||||
|
||||
public final class KartenLeser {
|
||||
|
||||
private static BackendServer server;
|
||||
|
||||
public KartenLeser(BackendServer server){
|
||||
this.server = 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,6 +76,89 @@ public class KartenUtil {
|
||||
return cardName;
|
||||
}
|
||||
|
||||
public static String getIdOfUid(String uid){
|
||||
switch (uid){
|
||||
case "04A56BB4780000":
|
||||
return "eichel_7";
|
||||
case "04A46BB4780000":
|
||||
return "eichel_8";
|
||||
case "04A26BB4780000":
|
||||
return "eichel_9";
|
||||
case "04A16BB4780000":
|
||||
return "eichel_x";
|
||||
case "049E6BB4780000":
|
||||
return "eichel_k";
|
||||
case "04A86BB4780000":
|
||||
return "eichel_a";
|
||||
case "04A06BB4780000":
|
||||
return "eichel_u";
|
||||
case "049F6BB4780000":
|
||||
return "eichel_o";
|
||||
|
||||
case "04F26BB4780000":
|
||||
return "blatt_7";
|
||||
case "04A76BB4780000":
|
||||
return "blatt_8";
|
||||
case "049B6BB4780000":
|
||||
return "blatt_9";
|
||||
case "04996BB4780000":
|
||||
return "blatt_x";
|
||||
case "041CD2C2126F81":
|
||||
return "blatt_k";
|
||||
case "04A96BB4780000":
|
||||
return "blatt_a";
|
||||
case "049A6BB4780000":
|
||||
return "blatt_u";
|
||||
case "049D6BB4780000":
|
||||
return "blatt_o";
|
||||
|
||||
case "04936BB4780000":
|
||||
return "schell_7";
|
||||
case "04F697C2126F80":
|
||||
return "schell_8";
|
||||
case "04946BB4780000":
|
||||
return "schell_9";
|
||||
case "04956BB4780000":
|
||||
return "schell_x";
|
||||
case "04986BB4780000":
|
||||
return "schell_k";
|
||||
case "04AA6BB4780000":
|
||||
return "schell_a";
|
||||
case "04966BB4780000":
|
||||
return "schell_u";
|
||||
case "04976BB4780000":
|
||||
return "schell_o";
|
||||
|
||||
case "04F36BB4780000":
|
||||
return "herz_7";
|
||||
case "04B06BB4780000":
|
||||
return "herz_8";
|
||||
case "04AF6BB4780000":
|
||||
return "herz_9";
|
||||
case "04AE6BB4780000":
|
||||
return "herz_x";
|
||||
case "04AB6BB4780000":
|
||||
return "herz_k";
|
||||
case "049C6BB4780000":
|
||||
return "herz_a";
|
||||
case "04AD6BB4780000":
|
||||
return "herz_u";
|
||||
case "04AC6BB4780000":
|
||||
return "herz_o";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Karte getKarteById(String id){
|
||||
List<Karte> kartenList = initializeSchafKopfCardDeck();
|
||||
for (Karte karte : kartenList) {
|
||||
if (karte.getId().equalsIgnoreCase(id)) {
|
||||
return karte;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void removeCards(List<Karte> allCards, List<Karte> cardsToRemove) {
|
||||
allCards.removeAll(cardsToRemove);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,6 @@ public class Schafkopf {
|
||||
String karteJson = gson.toJson(karte);
|
||||
server.sendMessageToAllFrontendEndpoints(karteJson);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void showFarbe() {
|
||||
|
||||
Reference in New Issue
Block a user