Beispiel #1
0
 public void execute() {
   logger.debug("Exec");
   if (commandInternalStatus.equals("check")) {
     Kernel.getSerialConnectionManager().write("AT+CPIN?\r\n");
   } else {
     Kernel.getSerialConnectionManager().write("AT+CPIN=\"" + pinCode + "\"\r\n");
   }
 }
Beispiel #2
0
 public boolean isExpected(String s) {
   logger.debug("isExpected(" + s + ") [" + status.toString() + "]");
   switch (status) {
     case WAITING:
       {
         if (s.startsWith("AT+CPIN?")) { // ECHO Pin check
           status = Status.INITIALIZED;
           logger.debug("Echo:" + s);
         } else if (s.startsWith("AT+CPIN=")) { // ECHO Set Pin
           status = Status.ANSWERED;
           logger.debug("Echo:" + s);
         } else {
           logger.warn("[WAITING] Unexpected answer:" + s);
           return false;
         }
         return true;
       }
     case INITIALIZED:
       {
         logger.debug("Answer:" + s);
         if (s.contains("+CPIN: SIM PIN")) { // XmppModem waiting for a PIN
           status = Status.ANSWERED;
           CPIN cmd2 = new CPIN();
           cmd2.setPinCode(pinCode);
           cmd2.commandInternalStatus = "set";
           Kernel.getCommandManager().renewCommand(cmd2);
           logger.debug("Command renewed.");
         } else if (s.contains("READY")) {
           status = Status.ANSWERED;
         } else {
           logger.warn("[INITIALIZED] Unexpected answer:" + s);
           return false;
         }
         return true;
       }
     case ANSWERED:
       {
         if (s.contains("OK")) {
           status = Status.TERMINATED;
           result = Result.OK;
         } else if (s.contains("ERROR")) {
           status = Status.TERMINATED;
           result = Result.ERROR;
         } else {
           logger.warn("[Answered] Unexpected answer:" + s);
           return false;
         }
         return true;
       }
   }
   return false; // To change body of implemented methods use File | Settings | File Templates.
 }