|
@@ -35,13 +35,17 @@ import com.clj.fastble.utils.HexUtil;
|
|
|
import com.google.common.util.concurrent.ListenableFuture;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
+import com.naz.sdkdemo.activity.UpTrademarkActivity;
|
|
|
import com.naz.sdkdemo.activity.ble.comm.ObserverManager;
|
|
|
import com.naz.sdkdemo.base.BaseActivity;
|
|
|
import com.naz.sdkdemo.bean.PrintModule;
|
|
|
import com.naz.sdkdemo.bean.PrintModule2;
|
|
|
import com.naz.sdkdemo.bean.PrintModule3;
|
|
|
+import com.naz.sdkdemo.helper.SerialPortManager;
|
|
|
import com.naz.sdkdemo.http.ApiHelper;
|
|
|
import com.naz.sdkdemo.utils.MyTools;
|
|
|
+import com.naz.sdkdemo.utils.SerialUtil;
|
|
|
+import com.naz.sdkdemo.weight.UserCache;
|
|
|
import com.tencent.smtt.export.external.interfaces.WebResourceError;
|
|
|
import com.tencent.smtt.export.external.interfaces.WebResourceRequest;
|
|
|
import com.tencent.smtt.sdk.WebSettings;
|
|
@@ -88,7 +92,9 @@ public class MainActivity extends BaseActivity {
|
|
|
|
|
|
private Button printBtn;
|
|
|
private Button connectBtn;
|
|
|
-
|
|
|
+ private Button connectLight;
|
|
|
+ private Button turnOnLight;
|
|
|
+ private Button closeLight;
|
|
|
private TSPLPrinter printer;
|
|
|
|
|
|
String savePath;
|
|
@@ -256,6 +262,32 @@ public class MainActivity extends BaseActivity {
|
|
|
connectUSB(searchUsb());
|
|
|
}
|
|
|
});
|
|
|
+ connectLight = findViewById(R.id.connect2);
|
|
|
+ turnOnLight = findViewById(R.id.light);
|
|
|
+ connectLight.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ connectLight();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ turnOnLight.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (serialPortManager != null){
|
|
|
+ serialPortManager.turnOnLight(6);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ closeLight = findViewById(R.id.closeLight);
|
|
|
+ closeLight.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (serialPortManager!=null){
|
|
|
+ serialPortManager.close();
|
|
|
+ serialPortManager = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener(){
|
|
|
@Override
|
|
@@ -293,6 +325,7 @@ public class MainActivity extends BaseActivity {
|
|
|
// startActivity(new Intent(MainActivity.this, CaremaActivity.class));
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private AndroidInterface aIn;
|
|
@@ -1088,6 +1121,35 @@ public class MainActivity extends BaseActivity {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ private SerialPortManager serialPortManager;
|
|
|
+
|
|
|
+ private void connectLight(){
|
|
|
+ if (serialPortManager == null){
|
|
|
+ serialPortManager = new SerialPortManager();
|
|
|
+ serialPortManager.init(MainActivity.this, UserCache.getSerialName(), UserCache.getSerialRate(), new SerialPortManager.SerialCallBack() {
|
|
|
+ @Override
|
|
|
+ public void dataCallBack(String data) {
|
|
|
+ Log.e("--------->","------->data="+data);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void openCallBack(int code) {
|
|
|
+ Log.e("--------->","------->openCallBack code="+code);
|
|
|
+ if (code == 1){
|
|
|
+
|
|
|
+ }else {
|
|
|
+ Toast.makeText(MainActivity.this, "串口未打开", Toast.LENGTH_SHORT).show();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void closeCallBack(int code) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected void onDestroy() {
|
|
|
super.onDestroy();
|