×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    2

    AT Commando sent, responce from device ends with ERROR

    Hi there,

    i need some help using AT codes . In summary i need the manufacturer, imei (if supported) and the modelname of the device.

    I have simultanusly run a Sniffer who give me the request and response through the Bluetooth device and i can read that the resonse of the device is an "ERROR". I dont know actual what i can do or what my mistake is in thinking about the procedure and hope you can help me out. I tried it with a wait(500) after every flush() if the device need some time to response, but it was useless.

    Here my print of the sniffer:

    13,182 Master 46 AT+GMM. 20 16.07.2010 10:42:19.4911
    13,191 Slave 46 ..ERROR.. 22 00:00:00.0930 16.07.2010 10:42:19.5841


    Now my actual code snippet im using but i only get an empty String in lineRead.

    Code:
    public static void main(String[] args) throws IOException, InterruptedException {
    
            int index = ServicesSearch.element.indexOf("BT_HFP_AG");
            String conStr = ServicesSearch.serviceFound.elementAt(index);
            StreamConnection con = (StreamConnection)Connector.open(conStr);
    
            communicate( con);
        }
    
        private static void communicate(StreamConnection con) throws InterruptedException {
            try{
                OutputStream out = con.openOutputStream();
                InputStream in = con.openInputStream();
                
                // send String
                PrintWriter pWriter = new PrintWriter(new OutputStreamWriter(out));
                pWriter.write("AT+GMM\r"); // for the modelname
                pWriter.flush();
                pWriter.write("AT+CGMI\r"); // for the manufacturer
                pWriter.flush();
                pWriter.write("AT+CGSN\r");  // for the IMEI
                pWriter.flush();
    
                BufferedReader bReader = new BufferedReader(new InputStreamReader(in));
                String lineRead = bReader.readLine();
                System.out.println("AG: " + lineRead);
                
                out.close(); in.close(); con.close();
            }
            catch(IOException ioe){
            }
        }
    Thanks for help and hopeful to find a solution

    If questions are open ask me pls i need all help i can get and want give any answer who is helpful.
    greetings

    Skywalker

    P.S.: I have read the other two threads about AT commandos but wasnt a success.

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105

    Re: AT Commando sent, responce from device ends with ERROR

    Does this help? The first line is empty, therefore you get an empty String.
    Quote Originally Posted by Skywalker75 View Post
    I have read the other two threads about AT commandos but wasnt a success.
    Why did you not link them, so we know which you are referring to?

  3. #3
    Registered User
    Join Date
    Jul 2010
    Posts
    2

    Re: AT Commando sent, responce from device ends with ERROR

    Hi Traud and thx for answer.
    One thread was your actual posted. The other one i dont know more.
    Meantime i found that i have to send a couple of commands in order to get a right answer. There are more than 10 commands i have to send i think before i can get the manufacturer and IMEI. The joke is, i tried it with a Sony Ericsson and it was a success. I got the manufacturer, model and the imei. After that i tried it with other phones. By the LG KC780 i dont got any profiles with profile browsing, i think the command isnt mandatory only optional and this LG don't support it, damn. The Samsung, here a SGH-i8510, ends with an exception (Error: Failed to read(byte[]); [10053] An established connection was aborted by the software in your host machine.) I got the profiles but to establish a HFP-Connection it came to this error after i have sent the first AT-command.
    Now i am at a hard point for my software to find a good and going solution.

    If you wonder why i have so many loops of lineRead. I need it to get all the answers because if i only try a lineRead after the right at-command, the stream has a answer from a at-command before, the answer is slower so i have count all answers in my sniffer to find the lineread where the right data are in. I hope you understand my english

    I know that this solution dont work, because the answers differs from phone to phone. It is actual only a solution for my own Sony Ericsson K750 phone.

    Here now my actual code of the hfp-connection.

    Code:
        public static void main(String[] args) throws IOException, InterruptedException {
    
            int test = ServicesSearch.element.size();
            System.out.println("size: " + test);
            int index = ServicesSearch.element.indexOf("BT_HFP_AG");
            System.out.println("index: " + index);
            String conStr = ServicesSearch.serviceFound.elementAt(index);
            StreamConnection con = (StreamConnection)Connector.open(conStr);
    
            communicate( con);
        }
    
        private static void communicate(StreamConnection con) throws InterruptedException {
            try{
                OutputStream out = con.openOutputStream();
                InputStream in = con.openInputStream();
    
                PrintWriter pWriter = new PrintWriter(new OutputStreamWriter(out));
                BufferedReader bReader = new BufferedReader(new InputStreamReader(in));
                pWriter.write("AT+BRSF=7\r");                             //Retrieve AG Supported Features
                pWriter.flush();
                wait(1000);
                lineRead = null;
                while(lineRead == null || lineRead.isEmpty()){           // my actual solution waiting for the answer of the phone
                    lineRead = bReader.readLine();                               // to fill the stream
                }
                lineRead = null;
                while(lineRead == null || lineRead.isEmpty()){         // there are more answers i need so i have to got all i think
                    lineRead = bReader.readLine();
                }
                
                pWriter.write("AT+CIND=?\r");                          //Get supported indicators
                pWriter.flush();
                wait(1000);
                lineRead = "";
                lineRead = bReader.readLine();
                while(lineRead == null || lineRead.isEmpty()){       //waiting for the first answer of AT+CIND=?
                    lineRead = bReader.readLine();
                }
                lineRead = "";
                lineRead = bReader.readLine();
                while(lineRead == null || lineRead.isEmpty()){       // the second answer
                    lineRead = bReader.readLine();
                }
                pWriter.write("AT+CIND?\r");
                pWriter.flush();
                wait(1000);
                lineRead = "";
                while(lineRead == null || lineRead.isEmpty()){
                    lineRead = bReader.readLine();
                }
                lineRead = "";
                lineRead = bReader.readLine();
                while(lineRead == null || lineRead.isEmpty()){
                    lineRead = bReader.readLine();
                }
                pWriter.write("AT+CMER=3,0,0,1\r");
                pWriter.flush();
                wait(1000);
    
                lineRead = "";
                while(lineRead == null || lineRead.isEmpty()){
                    lineRead = bReader.readLine();
                }
                pWriter.write("AT+CHLD=?\r");
                pWriter.flush();
                wait(1000);
                lineRead = "";
                lineRead = bReader.readLine();
                while(lineRead == null || lineRead.isEmpty()){
                    lineRead = bReader.readLine();
                }
                lineRead = "";
                lineRead = bReader.readLine();
                while(lineRead == null || lineRead.isEmpty()){
                    lineRead = bReader.readLine();
                }
    
                ...... here are more lineRead Loops ........
    .......
    .......
    
                pWriter.write("AT+CGMI\r");                                   // this command sends the manufacturer
                pWriter.flush();
                wait(500);
    
                pWriter.write("AT+GMM\r");                                     //this command sends the model
                pWriter.flush();
                wait(500);
                lineRead = null;
                while(lineRead == null || lineRead.isEmpty()){
                    lineRead = bReader.readLine();
                }
                String manufacturer = lineRead;
                System.out.println("Manufacturer: " + manufacturer);
                lineRead = "";
                lineRead = bReader.readLine();
                while(lineRead == null || lineRead.isEmpty()){
                    lineRead = bReader.readLine();
                }
                pWriter.write("AT+GMR\r");
                pWriter.flush();
                wait(500);
    
                lineRead = null;
                while(lineRead == null || lineRead.isEmpty()){
                    lineRead = bReader.readLine();
                }
                lineRead = "";
                lineRead = bReader.readLine();
                while(lineRead == null || lineRead.isEmpty()){
                    lineRead = bReader.readLine();
                }
                String model = lineRead;
                System.out.println("ModelName: " + model);
                lineRead = "";
                lineRead = bReader.readLine();
                while(lineRead == null || lineRead.isEmpty()){
                    lineRead = bReader.readLine();
                }
                pWriter.write("AT+NREC=0\r");
                pWriter.flush();
                wait(500);
                lineRead = "";
                lineRead = bReader.readLine();
                while(lineRead == null || lineRead.isEmpty()){
                    lineRead = bReader.readLine();
                }
                pWriter.write("AT+CMEE=1\r");
                pWriter.flush();
                wait(500);
                lineRead = "";
                lineRead = bReader.readLine();
                while(lineRead == null || lineRead.isEmpty()){
                    lineRead = bReader.readLine();
                }
                lineRead = "";
                lineRead = bReader.readLine();
                while(lineRead == null || lineRead.isEmpty()){
                    lineRead = bReader.readLine();
                }
                lineRead = "";
                lineRead = bReader.readLine();
                while(lineRead == null || lineRead.isEmpty()){
                    lineRead = bReader.readLine();
                }
    
                pWriter.write("AT+CLIP=1\r");
                pWriter.flush();
                wait(500);
                lineRead = "";
                lineRead = bReader.readLine();
                while(lineRead == null || lineRead.isEmpty()){
                    lineRead = bReader.readLine();
                }
    
                pWriter.write("AT+CGSN\r");                                            // this command sends the IMEI
                pWriter.flush();
                wait(500);
                lineRead = null;
                while(lineRead == null || lineRead.isEmpty()){
                    lineRead = bReader.readLine();
                }
                lineRead = "";
                lineRead = bReader.readLine();
                while(lineRead == null || lineRead.isEmpty()){
                    lineRead = bReader.readLine();
                }
                lineRead = "";
                lineRead = bReader.readLine();
                while(lineRead == null || lineRead.isEmpty()){
                    lineRead = bReader.readLine();
                }
    //            System.out.println("AG: " + lineRead);
                pWriter.write("AT+CCWA=1\r");
                pWriter.flush();
                wait(500);
    
    //            lineRead += bReader.readLine();
                pWriter.write("AT+CMGF=0\r");
                pWriter.flush();
                wait(500);
                lineRead = null;
                while(lineRead == null || lineRead.isEmpty()){
                    lineRead = bReader.readLine();
                }
                lineRead = null;
                while(lineRead == null || lineRead.isEmpty()){
                    lineRead = bReader.readLine();
                }
                            lineRead = null;
                while(lineRead == null || lineRead.isEmpty()){
                    lineRead = bReader.readLine();
                }
                String IMEI = lineRead;
                System.out.println("IMEI: " + IMEI);
    
                out.close(); in.close(); con.close();
            }
            catch(IOException ioe){
                System.out.println("Error: " + ioe.getMessage());
                try {
                    con.close();
                } catch (IOException ex) {
                    Logger.getLogger(HFPConnection.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    I know that this is a bad written code but i am learning actual java and in this case i have often no idea how i can write the right code or routines.

    Greetings
    Skywalker

Similar Threads

  1. RPositioner Does not return any responce
    By teelkee in forum Symbian
    Replies: 1
    Last Post: 2010-02-22, 09:36
  2. HTTP 500 responce code
    By HasithaRandika in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2009-02-25, 13:31
  3. OBEX responce code 144 (0x90)?
    By schoenke in forum Mobile Java General
    Replies: 1
    Last Post: 2008-12-23, 12:21
  4. HTTP Post responce unerecognised event
    By anand_zain76 in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2007-08-23, 11:11
  5. Old model's responce to a Smart Message
    By marianka in forum Smart Messaging
    Replies: 0
    Last Post: 2005-05-13, 10:01

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×