diff --git a/app/src/main/java/com/unibuy/smartdevice/service/MqttService.java b/app/src/main/java/com/unibuy/smartdevice/service/MqttService.java index 70fa1cf..8951aa9 100644 --- a/app/src/main/java/com/unibuy/smartdevice/service/MqttService.java +++ b/app/src/main/java/com/unibuy/smartdevice/service/MqttService.java @@ -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");