Re: TC65 and DYNDNS

193 views
Skip to first unread message

Timo Medvedev

unread,
Mar 24, 2013, 7:25:23 PM3/24/13
to java...@googlegroups.com
I have the code. If you still need it then I will look it up.


Op vrijdag 15 maart 2013 14:51:24 UTC+1 schreef stefan...@umpi.it het volgende:
Hi all,

I've a (light) Java web server on my modem cinterion TC65, and I need to reach it using the service dyndns.
So I need to use the modem like a client to the service "dyndns": in this way I can communicate with the modem using a url. 
In which way can I use it?


I would greatly appreciate any help or suggestions.
Thanks in advance!

Stefano Rovis

unread,
Mar 25, 2013, 4:45:22 AM3/25/13
to java...@googlegroups.com
If you can post the code,
you give me a great support!

Thanks


Ing.Stefano Rovis
Progettazione Software

UMPI R&D Srl
Via Casalecchio 5
47924 Rimini (RN) Italy
Tel. + 39 0541 1795477
stefan...@umpi.it
www.umpi.it
 


Le informazioni contenute in questo messaggio sono riservate e confidenziali ed vietata la diffusione in qualunque modo eseguita. Qualora Lei non fosse la persona a cui il presente messaggio destinato, La invitiamo ad eliminarlo e a non leggerlo, dandocene gentilmente comunicazione. Per qualsiasi informazione si prega di contattare um...@umpi.it. Rif. D.L. 196/2003.

This e-mail (including attachments) is intended only for the recipient(s) named above. It may contain confidential or privileged information and should not be read, copied or otherwise used by any other person. If you are not the named recipient, please contact um...@umpi.it and delete the e-mail from your system. Rif. D.L. 196/2003.


Da: "Timo Medvedev" <tima...@gmail.com>
A: java...@googlegroups.com
Inviato: Lunedì, 25 marzo 2013 0:25:23
Oggetto: [javacint] Re: TC65 and DYNDNS
--
javacint group - http://www.javacint.com/
---
You received this message because you are subscribed to the Google Groups "Cinterion Java enabled chips support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javacint+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Timo Medvedev

unread,
Mar 25, 2013, 7:57:48 AM3/25/13
to java...@googlegroups.com
To update DynDNS hostname from TC65i code like this needs to be used and the attached Base64.java for Base64 encoding

public String updateDynDNS()
    {
        HttpConnection c = null;
        InputStream is = null;
        OutputStream os = null;
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        String response=null;
      
        String url = "http://members.dyndns.org/nic/update?system=dyndns&hostname=YOUR_HOSTNAME&wildcard=OFF";
        try {
            System.out.println("requestIPAddress(): connectie wordt geopend");
           
            c = (HttpConnection)Connector.open( url );                 
            c.setRequestMethod("GET");
            c.setRequestProperty("Host","members.dyndns.org");
            c.setRequestProperty("Authorization","Basic "+String.valueOf(Base64.encode("YOUR_USERNAME:YOUR_PASSWORD".getBytes()))+"\"");
            c.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.0");           
           
           
           
            // Getting the InputStream will open the connection
            // and read the HTTP headers. They are stored until
            // requested.
            System.out.println("requestIPAddress(): response code: "+c.getResponseCode());
           
            is = c.openInputStream();
                     
                      
           
            // Get the length and process the data          
            System.out.println("requestIPAddress(): inputstream is ok");
            if (is != null)
            {   
                System.out.println("requestIPAddress(): reading inputstream");
                int ch;
                while ((ch = is.read()) != -1) {
                //System.out.print( (char)ch );
                baos.write(ch);
                }
                          
                response = new String(baos.toByteArray());
                //System.out.println(response);                      
            }
            else System.out.println("requestIPAddress(): geen inputstream verkregen");
        }
        catch ( Exception ioe )
        {
            System.out.println("Fout: "+ioe.getMessage());
            ioe.printStackTrace();           
        }
        finally
        {
            try
            {
                if(baos != null) {
                    baos.close();                   
                    //baos = null;
                }                   
                if (is != null) {
                    is.close();
                    //is = null;
                }               
                if (c != null)
                {
                    c.close();
                    //c = null;
                }
                   
            }
            catch (IOException ioe )
            {           
                System.out.println("Fout: "+ioe.getMessage());
                ioe.printStackTrace();
            }           
          
        }        
        return response;
    }



Kind regards,
Timo Medvedev
------------------------------
TC65i programming, source codes and training ->  http://www.tc65.nl
Base64.java

Nikita Kapitonov

unread,
Mar 25, 2013, 8:33:59 AM3/25/13
to java...@googlegroups.com
Nice!

BTW, you have interesting site, maybe I'll buy your NTP protocol implementation.

Best regards,
Nikita


2013/3/25 Timo Medvedev <tima...@gmail.com>

--
Reply all
Reply to author
Forward
0 new messages