flutterxamarinrfidandroid-11

Working Chainway C72 UHF sample code for Android 11 version


From what I can gather Chainway changed the API to their hardware library with the move from Android 7 to Android 11 causing almost all the current packages for different frameworks out there to no longer work. Does anyone have working sample code for the Chainway C72 running on Android 11 other than this buggy Android Studio sample project? Biggest preference would be Xamarin/Maui or Flutter, but honestly any stable code would be greatly appreciated.

What we've tried: We have noticed that most of the libraries use a deprecated API class called RFIDWithUHF. We contacted Chainway technical support and they provided us with firmware update files and mentioned that we should use RFIDWithUHFUart class instead. They provided an Android Studio sample project, if you restart the device and run the project you are able to scan RFID tags, but it is extremely buggy and quickly crashes. Closing the app and restarting it unfortunately does not recover it from this state even though the code does a free and initialise on startup. You have to reboot the device to get it out of this state.

We attempted to use the following packages/libraries with the following results:

An Observatory debugger and profiler on C72 is available at: http://127.0.0.1:61316/iEK5kGMghqQ=/
The Flutter DevTools debugger and profiler on C72 is available at: http://127.0.0.1:9101?uri=http://127.0.0.1:61316/iEK5kGMghqQ=/
I/DeviceAPI_DeviceCon(30538): getDeviceInfoFromFile configPath=/storage/emulated/0/PDAConfig.txt
D/DeviceAPI_DeviceCon(30538): cw.model2:
D/DeviceAPI_DeviceCon(30538): cw.model:mtk.6765.c72
D/DeviceAPI_DeviceCon(30538): 最终cw.model:mtk.6765.c72
I/DeviceAPI_DeviceCon(30538): model=C72,uartPath=/dev/ttyMT3,uartPath_Fingerprint=/dev/ttyMT0,uartPath_RFID=
I/DeviceAPI_DeviceCon(30538): getModel() model=C72
D/DeviceAPI(30538): UHF device = C72
D/DeviceAPI(30538): UHF_Init----------->DevIsOpen = 1
D/DeviceAPI(30538): UHF uart = /dev/ttyMT3
D/DeviceAPI_SerialPort(30538): [SerialPort_Open] [2]: No such file or directory
D/DeviceAPI(30538): UHF uhf_uart_fd = -1
I/DeviceAPI_UHF(30538): init() Uart = /dev/ttyMT3
E/DeviceAPI_UHF(30538): init() err UHFOpenAndConnect result:-1
E/DeviceAPI_UHF(30538): startInventory() err :-1
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.   
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file 'C:\Repos\Sandbox\ReactNative\c72ScannerReact\node_modules\c72-rfid-scanner\android\build.gradle' line: 23

* What went wrong:
A problem occurred evaluating project ':c72-rfid-scanner'.
> Plugin with id 'maven' not found.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':c72-rfid-scanner'.
> compileSdkVersion is not specified. Please add it to build.gradle 

Solution

  • I ended up using the rfid_c72_plugin Flutter package that seems to support the Android 11 version of the C72 well. Although whenever I press the hardware buttons it seems like the firmware crashes and I have to reboot the device. Not sure if our device or firmware version might be faulty.