[FEAT]:串接刷卡機重啟與遠端結帳 MQTT 指令
1. 在 MqttService 中新增 nfc_reset 指令,對應原本的刷卡機重置邏輯。 2. 在 MqttService 中新增 nfc_checkout 指令,對應原本的刷卡機結帳邏輯。 3. 確保指令執行後會回傳 ACK 狀態至後台。
This commit is contained in:
parent
18943e8a0f
commit
df8dae9a56
@ -114,6 +114,28 @@ public class MqttService extends Service {
|
||||
startActivity(restartIntent);
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
}, 500);
|
||||
} else if ("nfc_reset".equals(cmd)) {
|
||||
Log.i(TAG, "Executing remote NFC reset command...");
|
||||
try {
|
||||
com.unibuy.smartdevice.devices.Rs232Dev comPort2 = new com.unibuy.smartdevice.devices.Rs232Dev(com.unibuy.smartdevice.MyApp.getInstance().getComPort2ByNFCPay());
|
||||
com.unibuy.smartdevice.devices.DevNFCPay devNFCPay = new com.unibuy.smartdevice.devices.DevNFCPay(getApplicationContext());
|
||||
comPort2.send(devNFCPay.reset());
|
||||
mqttManager.publishCommandAck(cmdId, "success", "NFC reset command sent");
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "NFC reset failed: " + e.getMessage());
|
||||
mqttManager.publishCommandAck(cmdId, "failed", "NFC reset failed: " + e.getMessage());
|
||||
}
|
||||
} else if ("nfc_checkout".equals(cmd)) {
|
||||
Log.i(TAG, "Executing remote NFC checkout command...");
|
||||
try {
|
||||
com.unibuy.smartdevice.devices.Rs232Dev comPort2 = new com.unibuy.smartdevice.devices.Rs232Dev(com.unibuy.smartdevice.MyApp.getInstance().getComPort2ByNFCPay());
|
||||
com.unibuy.smartdevice.devices.DevNFCPay devNFCPay = new com.unibuy.smartdevice.devices.DevNFCPay(getApplicationContext());
|
||||
comPort2.send(devNFCPay.checkout());
|
||||
mqttManager.publishCommandAck(cmdId, "success", "NFC checkout command sent");
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "NFC checkout failed: " + e.getMessage());
|
||||
mqttManager.publishCommandAck(cmdId, "failed", "NFC checkout failed: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "Unknown MQTT command: " + cmd);
|
||||
mqttManager.publishCommandAck(cmdId, "failed", "Unknown command");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user