⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commandmanager.java

📁 First of all, the Applet-phone is a SIP User-Agent with audio and text messaging capabilities. But
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                    - '<'  bits: 11 : shortest                    - '8'  bits: 10 : shorter                    - '4'  bits: 01 : medium                    - '0'  bits: 00 : long              5. receive:  0x30 for correctness, an other byte otherwise is error and stop              6. send:     '.'              7. receive:  0x30              8. send:     '.'              9. receive:  'd' echo command            */                      // 1.            char c='\\';             os.write(c);            SerialDebug.println("Sent to the base:       -  char: \\ (dec/hex code: 92/5C)");                        // 2.            newData = is.read();            inputBuffer.append((char)newData);            String s=new String(inputBuffer);            SerialDebug.println("Received from the base: -  char: "+s+" (dec code: "+newData+")");                        // 3.            c='0';             os.write(c);            SerialDebug.println("Sent to the base:       -  char: 0 (dec/hex code: 48/30)");                        // 4.            c='d';            os.write(c);            SerialDebug.println("Sent to the base:       -  char: e (dec/hex code: 100/64)");                        // 5.            if (range.equals(LONG_ATTENUATION) ) {                c='0';            }            if (range.equals(MEDIUM_ATTENUATION) ) {                c='4';            }            if (range.equals(SHORTER_ATTENUATION) ) {                c='8';            }            if (range.equals(SHORTEST_ATTENUATION) ) {               c='<';             }            os.write(c);            SerialDebug.println("Sent to the base:       -  attenuation char: "+c);                        // 6.            newData = is.read();            inputBuffer = new StringBuffer();            inputBuffer.append((char)newData);            s=new String(inputBuffer);            SerialDebug.println("Received from the base: -  char: "+s+" (dec code: "+newData+")");            if ((char)newData!='0') {                SerialDebug.println("ERROR code returned from the base!!!!");            }                        int cpt=1;            while (cpt!=3) {                c='.';                 os.write(c);                SerialDebug.println("Sent to the base:       -  char: . (dec/hex code: 46/2E)");                                newData = is.read();                inputBuffer = new StringBuffer();                inputBuffer.append((char)newData);                s=new String(inputBuffer);                SerialDebug.println("Received from the base: -  char: "+s+" (dec code: "+newData+")");                               cpt++;            }                  }        catch (Exception e) {            e.printStackTrace();        }    }                /*******************************************************************************/    /********************      GET_BASE_TIME_OUT       **************************/    /*******************************************************************************/              public int getBaseTimeOut() {        try {            int timeout=-1;                          wakeupBase();                        SerialDebug.println("CommandManager, getBaseTimeOut() required...");                                    StringBuffer inputBuffer = new StringBuffer();            int newData = 0;                        /* Sequence:              1. send:     '\' wake up base              2. receive:  0x30 (=0)              3. send:     0x30              4. send:     'i'              5. receive:  0x30 for correctness, an other byte otherwise is error and stop              6. send:     '.'              7. receive:  0x30              8. send:     '.'              9. receive:  'i' echo command              10. send:     '.'              11. receive:  timeout            */                        // 1.            char c='\\';             os.write(c);            SerialDebug.println("Sent to the base:       -  char: \\ (dec/hex code: 92/5C)");                        // 2.            newData = is.read();            inputBuffer.append((char)newData);            String s=new String(inputBuffer);            SerialDebug.println("Received from the base: -  char: "+s+" (dec code: "+newData+")");                        // 3.            c='0';             os.write(c);            SerialDebug.println("Sent to the base:       -  char: 0 (dec/hex code: 48/30)");                        // 4.            c='i';            os.write(c);            SerialDebug.println("Sent to the base:       -  char: i (dec/hex code: 105/69)");                        // 5.            newData = is.read();            inputBuffer = new StringBuffer();            inputBuffer.append((char)newData);            s=new String(inputBuffer);            SerialDebug.println("Received from the base: -  char: "+s+" (dec code: "+newData+")");            if ((char)newData!='0') {                SerialDebug.println("ERROR code returned from the base!!!!");                return -1;            }                        // 6. 7. 8. 9. 10. 11.             int cpt=1;            while (cpt!=4) {                c='.';                 os.write(c);                SerialDebug.println("Sent to the base:       -  char: . (dec/hex code: 46/2E)");                                newData = is.read();                inputBuffer = new StringBuffer();                inputBuffer.append((char)newData);                s=new String(inputBuffer);                SerialDebug.println("Received from the base: -  char: "+s+" (dec code: "+newData+")");                                if (cpt==3) {                    try{                        // timeout byte:                                                timeout=(newData-97+1)/2;                                      }                    catch(Exception e) {                        e.printStackTrace();                        return -1;                    }                }                               cpt++;            }                      return timeout;        }        catch (Exception e) {            e.printStackTrace();            return -1;        }    }    /*******************************************************************************/    /********************      GET_TRANSFER_MODE          **************************/    /*******************************************************************************/              public String getTransferMode() {        try {            String transferMode="NOT SET";                          wakeupBase();                                       SerialDebug.println("CommandManager, setTransferMode() required...");                                    StringBuffer inputBuffer = new StringBuffer();            int newData = 0;                        /* Sequence:              1. send:     '\' wake up base              2. receive:  0x30 (=0)              3. send:     0x30              4. send:     'l'              5. receive:  0x30 for correctness, an other byte otherwise is error and stop              6. send:     '.'              7. receive:  0x30              8. send:     '.'              9. receive:  'l' echo command              10. send:     '.'              11. receive:  mode            */                        // 1.            char c='\\';             os.write(c);            SerialDebug.println("Sent to the base:       -  char: \\ (dec/hex code: 92/5C)");                        // 2.            newData = is.read();            inputBuffer.append((char)newData);            String s=new String(inputBuffer);            SerialDebug.println("Received from the base: -  char: "+s+" (dec code: "+newData+")");                        // 3.            c='0';             os.write(c);            SerialDebug.println("Sent to the base:       -  char: 0 (dec/hex code: 48/30)");                        // 4.            c='l';            os.write(c);            SerialDebug.println("Sent to the base:       -  char: l (dec/hex code: 108/6C)");                        // 5.            newData = is.read();            inputBuffer = new StringBuffer();            inputBuffer.append((char)newData);            s=new String(inputBuffer);            SerialDebug.println("Received from the base: -  char: "+s+" (dec code: "+newData+")");            if ((char)newData!='0') {                SerialDebug.println("ERROR code returned from the base!!!!");                return "NOT SET";            }                        // 6. 7. 8. 9. 10. 11.             int cpt=1;            while (cpt!=4) {                c='.';                 os.write(c);                SerialDebug.println("Sent to the base:       -  char: . (dec/hex code: 46/2E)");                                newData = is.read();                SerialDebug.println("Received from the base: -  char: "+(char)newData+" (dec code: "+newData+")");                inputBuffer = new StringBuffer();                inputBuffer.append((char)newData);                s=new String(inputBuffer);                if (cpt==3) {                     try{                        // transfer mode                        int transferModeInt=Integer.valueOf(s).intValue();                        if (transferModeInt==0) {                            transferMode=SYNCHRONOUS_TRANSFER_MODE;                        }                        else                             if (transferModeInt==1) {                                transferMode=ASYNCHRONOUS_TRANSFER_MODE;                            }                            else {                                return "NOT SET";                            }                    }                    catch(Exception e) {                        e.printStackTrace();                        return "NOT SET";                    }                }                               cpt++;            }                      return transferMode;        }        catch (Exception e) {            e.printStackTrace();            return "NOT SET";        }    }          /*******************************************************************************/    /********************      SET_TRANSFER_MODE          **************************/    /*******************************************************************************/              public void setTransferMode(String transferMode) {        try {            if ( !transferMode.equals(ASYNCHRONOUS_TRANSFER_MODE)  && !transferMode.equals(SYNCHRONOUS_TRANSFER_MODE)) {                SerialDebug.println("ERROR: TRANSFER MODE is either: CommandManager.ASYNCHRONOUS_TRANSFER_MODE or"+                "CommandManager.SYNCHRONOUS_TRANSFER_MODE");                return;            }                          wakeupBase();                        StringBuffer inputBuffer = new StringBuffer();            int newData = 0;                        /* Sequence:              1. send:     '\' wake up base              2. receive:  0x30 (=0)              3. send:     0x30              4. send:     'k'              5. send:     mode: 0 or 1              6. send:     auth0_pc              7. send:     auth1_pc              5. receive:  0x30 for correctness, an other byte otherwise is error and stop              6. send:     '.'              7. receive:  0x30              8. send:     '.'              9. receive:  'k' echo command            */                        // 1.            char c='\\';             os.write(c);            SerialDebug.println("Sent to the base:       -  char: \\ (dec/hex code: 92/5C)");                        // 2.            newData = is.read();            inputBuffer.append((char)newData);            String s=new String(inputBuffer);            SerialDebug.println("Received from the base: -  char: "+s+" (dec code: "+newData+")");                        // 3.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -