diff --git a/.idea/gradle.xml b/.idea/gradle.xml index a0c2f22..79d16a6 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -8,7 +8,7 @@ - + diff --git a/.idea/misc.xml b/.idea/misc.xml index d4f9d85..5b947be 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,7 @@ - + diff --git a/app/build.gradle b/app/build.gradle index 65eaea4..1257415 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -55,6 +55,8 @@ dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.recyclerview:recyclerview:1.2.1' implementation 'com.google.android.libraries.places:places:2.5.0' + implementation 'androidx.navigation:navigation-fragment:2.4.1' + implementation 'androidx.navigation:navigation-ui:2.4.1' // implementation files('libs\\org.eclipse.paho.android.service-1.1.1.jar') // implementation files('libs\\org.eclipse.paho.client.mqttv3-1.2.5.jar') testImplementation 'junit:junit:4.13.2' @@ -65,6 +67,7 @@ dependencies { // implementation files('libs\\gson-2.2.2.jar') implementation files('libs\\sdkapi.jar') compileOnly files('libs/sdkapi.jar') + compileOnly files('libs/PC_RFID.jar') implementation files('libs/modbus4Android-1.2.jar') implementation 'com.contrarywind:Android-PickerView:3.2.6' implementation 'com.github.Ccapton:Android-ColorfulProgressBar:1.0.5' @@ -79,4 +82,6 @@ dependencies { implementation 'com.github.zcweng:switch-button:0.0.3@aar' // easyPermissions权限管理 implementation 'pub.devrel:easypermissions:2.0.1' + implementation 'com.github.mik3y:usb-serial-for-android:3.5.1' + //implementation fileTree(dir: "libs", include: ["*.jar"]) } \ No newline at end of file diff --git a/app/libs/PC_RFID.jar b/app/libs/PC_RFID.jar new file mode 100644 index 0000000..e77aa59 Binary files /dev/null and b/app/libs/PC_RFID.jar differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e2be416..9542fc9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -13,11 +13,14 @@ - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + android:label="@string/title_activity_plate" + android:theme="@style/AppTheme.NoActionBar" /> - @@ -133,12 +50,6 @@ - - availableDrivers = prober.findAllDrivers(usbManager); + + if (!availableDrivers.isEmpty()) { + UsbSerialDriver driver = availableDrivers.get(0); + UsbDevice device = driver.getDevice(); + + connection = usbManager.openDevice(device); + usbSerialPort = driver.getPorts().get(0); + usbSerialPort.open(connection); + usbSerialPort.setParameters(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE); + + readThread = new ReadThread(); + readThread.start(); + } else { + throw new IOException("No USB serial device found"); + } + } + + public void closeDevice() { + if (readThread != null) { + readThread.interrupt(); + readThread = null; + } + + if (usbSerialPort != null) { + try { + usbSerialPort.close(); + } catch (IOException e) { + e.printStackTrace(); + } + usbSerialPort = null; + } + + if (connection != null) { + connection.close(); + connection = null; + } + } + + public void sendData(byte[] data) throws IOException { + if (usbSerialPort != null) { + usbSerialPort.write(data, 1000); + } + } + + private class ReadThread extends Thread { + @Override + public void run() { + byte[] buffer = new byte[1024]; + int numBytes; + + while (!isInterrupted()) { + try { + numBytes = usbSerialPort.read(buffer, 1000); + if (numBytes > 0) { + byte[] data = new byte[numBytes]; + System.arraycopy(buffer, 0, data, 0, numBytes); + onDataReceivedListener.onDataReceived(data); + } + } catch (IOException e) { + e.printStackTrace(); + break; + } + } + } + } \ No newline at end of file diff --git a/app/src/main/java/com/example/bpa/view/PlateActivity.java b/app/src/main/java/com/example/bpa/view/PlateActivity.java new file mode 100644 index 0000000..7ad1cf4 --- /dev/null +++ b/app/src/main/java/com/example/bpa/view/PlateActivity.java @@ -0,0 +1,47 @@ +package com.example.bpa.view; + +import android.os.Bundle; + +import com.google.android.material.snackbar.Snackbar; + +import androidx.appcompat.app.AppCompatActivity; + +import android.view.View; + +import androidx.navigation.NavController; +import androidx.navigation.Navigation; +import androidx.navigation.ui.AppBarConfiguration; +import androidx.navigation.ui.NavigationUI; + + +import com.example.bpa.R; +import com.pc_rfid.api.PC_API; +import com.pc_rfid.api.RFdata; + +public class PlateActivity extends AppCompatActivity { + + private AppBarConfiguration appBarConfiguration; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.plate_main); + + RFdata data=new RFdata(); + PC_API.USB_init(getApplicationContext()); + boolean b; + if (!PC_API.PC_GetDeviceInfoVersion(data)) { + b = false; + } else { + b = true; + } + } + + @Override + public boolean onSupportNavigateUp() { + NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_plate); + return NavigationUI.navigateUp(navController, appBarConfiguration) + || super.onSupportNavigateUp(); + } +} \ No newline at end of file diff --git a/app/src/main/jniLibs/arm64-v8a/libCOM.so b/app/src/main/jniLibs/arm64-v8a/libCOM.so new file mode 100644 index 0000000..c35ac81 Binary files /dev/null and b/app/src/main/jniLibs/arm64-v8a/libCOM.so differ diff --git a/app/src/main/jniLibs/armeabi-v7a/libCOM.so b/app/src/main/jniLibs/armeabi-v7a/libCOM.so new file mode 100644 index 0000000..ef75fc9 Binary files /dev/null and b/app/src/main/jniLibs/armeabi-v7a/libCOM.so differ diff --git a/app/src/main/jniLibs/x86/libCOM.so b/app/src/main/jniLibs/x86/libCOM.so new file mode 100644 index 0000000..c181967 Binary files /dev/null and b/app/src/main/jniLibs/x86/libCOM.so differ diff --git a/app/src/main/jniLibs/x86_64/libCOM.so b/app/src/main/jniLibs/x86_64/libCOM.so new file mode 100644 index 0000000..609ab65 Binary files /dev/null and b/app/src/main/jniLibs/x86_64/libCOM.so differ diff --git a/app/src/main/res/layout/datatab/layout/activity_plate.xml b/app/src/main/res/layout/datatab/layout/activity_plate.xml new file mode 100644 index 0000000..56cbbe4 --- /dev/null +++ b/app/src/main/res/layout/datatab/layout/activity_plate.xml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/datatab/layout/content_plate.xml b/app/src/main/res/layout/datatab/layout/content_plate.xml new file mode 100644 index 0000000..7078fe0 --- /dev/null +++ b/app/src/main/res/layout/datatab/layout/content_plate.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/datatab/layout/fragment_first.xml b/app/src/main/res/layout/datatab/layout/fragment_first.xml new file mode 100644 index 0000000..fb44a3d --- /dev/null +++ b/app/src/main/res/layout/datatab/layout/fragment_first.xml @@ -0,0 +1,28 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/datatab/layout/fragment_second.xml b/app/src/main/res/layout/datatab/layout/fragment_second.xml new file mode 100644 index 0000000..bd90524 --- /dev/null +++ b/app/src/main/res/layout/datatab/layout/fragment_second.xml @@ -0,0 +1,27 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/datatab/layout/plate_main.xml b/app/src/main/res/layout/datatab/layout/plate_main.xml new file mode 100644 index 0000000..41d2ef1 --- /dev/null +++ b/app/src/main/res/layout/datatab/layout/plate_main.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/datatab/navigation/nav_graph.xml b/app/src/main/res/layout/datatab/navigation/nav_graph.xml new file mode 100644 index 0000000..3b4e29c --- /dev/null +++ b/app/src/main/res/layout/datatab/navigation/nav_graph.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/datatab/values-land/dimens.xml b/app/src/main/res/layout/datatab/values-land/dimens.xml new file mode 100644 index 0000000..22d7f00 --- /dev/null +++ b/app/src/main/res/layout/datatab/values-land/dimens.xml @@ -0,0 +1,3 @@ + + 48dp + \ No newline at end of file diff --git a/app/src/main/res/layout/datatab/values-w1240dp/dimens.xml b/app/src/main/res/layout/datatab/values-w1240dp/dimens.xml new file mode 100644 index 0000000..d73f4a3 --- /dev/null +++ b/app/src/main/res/layout/datatab/values-w1240dp/dimens.xml @@ -0,0 +1,3 @@ + + 200dp + \ No newline at end of file diff --git a/app/src/main/res/layout/datatab/values-w600dp/dimens.xml b/app/src/main/res/layout/datatab/values-w600dp/dimens.xml new file mode 100644 index 0000000..22d7f00 --- /dev/null +++ b/app/src/main/res/layout/datatab/values-w600dp/dimens.xml @@ -0,0 +1,3 @@ + + 48dp + \ No newline at end of file diff --git a/app/src/main/res/layout/datatab/values/dimens.xml b/app/src/main/res/layout/datatab/values/dimens.xml new file mode 100644 index 0000000..125df87 --- /dev/null +++ b/app/src/main/res/layout/datatab/values/dimens.xml @@ -0,0 +1,3 @@ + + 16dp + \ No newline at end of file diff --git a/app/src/main/res/layout/datatab/values/strings.xml b/app/src/main/res/layout/datatab/values/strings.xml index 6048840..06e2443 100644 --- a/app/src/main/res/layout/datatab/values/strings.xml +++ b/app/src/main/res/layout/datatab/values/strings.xml @@ -1,4 +1,13 @@ Hello blank fragment + PlateActivity + + First Fragment + Second Fragment + Next + Previous + + Hello first fragment + Hello second fragment. Arg: %1$s \ No newline at end of file diff --git a/app/src/main/res/layout/datatab/values/themes.xml b/app/src/main/res/layout/datatab/values/themes.xml new file mode 100644 index 0000000..d907dd5 --- /dev/null +++ b/app/src/main/res/layout/datatab/values/themes.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file