Thales' cellular IoT products business is now part of Telit Cinterion, find out more.

You are here

Http Post problem | Telit Cinterion IoT Developer Community

November 26, 2018 - 2:20pm, 3272 views

Dear,

I am using 3 modem types: TC65i, EHS8 and the ELS61. On all three I use the code below to check the internet connection. On the TC65i and the ELS61 it works fine.

When I put a (Dutch) T-Mobile card into the EHS8 the function freezes. It also freezes the running Timer class.

I'm doing the exact same thing with the TC65i and ELS61 and all works OK. I also tried multiple sim cards from T-Mobile but with the same result. 

What is going wrong when using the EHS8?

Regards.

The revision of the EHS8:

Cinterion
EHS8
REVISION 03.001
A-REVISION 00.000.51 

Code:

 
public static boolean ping(String url) {         
            
            HttpConnection c = null;
            OutputStream os = null;
            InputStream is = null;
            int ch;
            StringBuffer b = new StringBuffer();
            
            try {            
                c = (HttpConnection)Connector.open(url);
           
                // Set the request method and headers
                c.setRequestMethod(HttpConnection.POST);
                c.setRequestProperty("If-Modified-Since","7 Sep 2005 19:43:31 GMT");               
                c.setRequestProperty("User-Agent","Profile/MIDP-1.0 Configuration/CLDC-1.0");             
                c.setRequestProperty("Content-Language", "en-US");
                
                // Getting the output stream may flush the headers
                os = c.openOutputStream();              
                os.write("Ping".getBytes());                
                os.flush();                               

                is = c.openInputStream();
             
                while ((ch = is.read()) != -1) {
                    b.append((char)ch);
                }

                isPing = true;

            } 
            catch(Exception e) {
                isPing = false;
System.out.println("Ping failed\r");
            } 
            finally {
                
                try {
                    os.flush();
                    os.close();
                } catch (Exception ex) {
				
                }                
                try {
                    is.close();
                } catch (Exception ex) {
				
                }                
                try {
                    c.close();
                } catch (Exception ex) {
				
                }
                
System.out.println("Pinging return: " + isPing + "\r");

                return isPing;
            }
        }