I'm now trying to create a simple to use library, instead of using the Main.java file with Processing.
In the Main.java I had:
Code:package libnfcjava;
public class Main {
static {
System.load("C:\\RFIDtest\\code\\libnfc.dll");
System.load("C:\\RFIDtest\\code\\LibNFCNative.dll");
}
public Main() {
}
public static void main(String[] args) {
}
public native String nativeTagID();
public native boolean nativeConnectedRFID();
}
I accessed the native functions (JNI) from within Processing by doing (for example):
boolean RFIDON = new Main().nativeConnectedRFID();For the Processing library I now have a slightly different .java:
Code:package libnfc;
import processing.core.PApplet;
public class LibNFC {
PApplet myParent;
public final String VERSION = "0.1.0";
static {
System.load("C:\\RFIDtest\\code\\libnfc.dll");
System.load("C:\\RFIDtest\\code\\LibNFCNative.dll");
}
public LibNFC(PApplet theParent) {
myParent = theParent;
}
public String version() {
return VERSION;
}
public boolean isOn() {
boolean status = this.nativeConnectedRFID();
return status;
}
public String tagID() {
String tag = this.nativeTagID();
return tag;
}
public native String nativeTagID();
public native boolean nativeConnectedRFID();
}
But when I try to run this example:
Code:import libnfc.*;
LibNFC rfid;
void setup() {
rfid = new LibNFC(this);
size(400, 400);
background(255);
}
void draw() {
rectMode(CENTER);
while(rfid.isOn()) {
stroke(0);
fill(255);
rect(200,200,100,100);
String tag = rfid.tagID();
if(tag.equals("0400ae51962281")) {
stroke(0);
fill(127,0,0);
rect(200,200,100,100);
} else if(tag.equals("04ece051962280")) {
stroke(0);
fill(255,200,200);
rect(200,200,100,100);
} else {
stroke(0);
fill(255);
rect(200,200,100,100);
}
}
background(255);
}
I get the following error as soon I get to the
while(rfid.isOn()):
UnsatisfiedLinkError: libnfc.LibNFC.nativeConnectedRFID()Z