8 Replies Latest reply: Nov 12, 2008 9:42 AM by 843851 RSS

    Write Files through return channel

    843851
      Hi,

      i'm newer in this forum. I'm working in a MHP project, and I want to comunicate STB with the server (in this case, a PC running Apache Server).

      The question is �can I write a file in the server with data obtained on the STB? I think that it is posible via return channel, but i'm not sure. The idea is to write file (on the server) with the solutions entered by TV user in an application that have some tests. �Are other ways besides return channel to do it?

      Thanks ;)

      Regards
        • 1. Re: Write Files through return channel
          843851
          Hello,

          I have been working using the return channel and it is quite easy. My ADB STB has an ethernet with an ADSL connection so it connects instantanly. Here in this link you will find very useful information:

          http://www.cineca.tv/labs/mhplab/index-en.html

          If you need to write a file just use HTTP protocol. For example I have been using Httpservlet class to write files and to retrieve information for my application (with an Apache-Tomcat). With Apache you can do whatever you want(load background images, or write files).

          If you have any doubts ask me again.
          Abel
          • 2. Re: Write Files through return channel
            843851
            Thanks Abel,

            but, can you post any code? The goal is to create a login screen, that comunicates MHP application with the server that contains and data base, with the user login data. I read in this post http://forum.java.sun.com/thread.jspa?threadID=5252001 that you have a similar issue.

            Thanks ;)
            • 3. Re: Write Files through return channel
              843851
              Hello here you an example of login in my application:
              package es.admin.servlet;
              
              import java.io.IOException;
              import java.io.PrintWriter;
              
              import javax.servlet.ServletException;
              import javax.servlet.http.HttpServletRequest;
              import javax.servlet.http.HttpServletResponse;
              
              import es.admin.bd.PacienteBD;
              import es.admin.beans.Paciente;
              import es.admin.dao.PacienteDAO;
              
              /**
               * Servlet implementation class for Servlet: LoginPatient
               *
               */
               public class LoginPatient extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
                 static final long serialVersionUID = 1L;
                 
                  /* (non-Java-doc)
                    * @see javax.servlet.http.HttpServlet#HttpServlet()
                    */
                   public LoginPatient() {
                        super();
                   }        
                   
                   /* (non-Java-doc)
                    * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
                    */
                   protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                        // TODO Auto-generated method stub
                        processRequest(request,response);
                   }       
                   
                   /* (non-Java-doc)
                    * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
                    */
                   protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                        // TODO Auto-generated method stub
                        processRequest(request,response);
                   }   
                   
                   private void processRequest(HttpServletRequest request,HttpServletResponse response) throws IOException
                   {
                        Paciente paciente = new Paciente();
                        
                        paciente.setDni(request.getParameter("dni"));
                        
                        paciente.setContrasenia(request.getParameter("contrasenia"));
                        
                        boolean ok = PacienteBD.compruebaPaciente(paciente.getDni(),paciente.getContrasenia());
                        
                        
                        
                        response.setContentType("text/plain;charset=UTF-8");
                        
                        PrintWriter p = response.getWriter();
                        
                        if (ok)
                        {
                             p.println("true");
                        
                        
                             
                        }
                        else
                        {
                             p.print("false");
                        }
                        
                        
                        
                        
                        
                        
                   }
                   
                   
                   
              }
              public class PacienteBD {
                   
                   public static boolean compruebaPaciente(String dni,String password)
                   {
                        boolean correcto = false;
                        
                        Paciente aux = PacienteDAO.BuscarPaciente(dni);
                        
                        
                        if ((aux!=null)&&(aux.getContrasenia().equals(password)))
                             
                        {     
                             correcto = true;
                             
                        }          
                        
                        return correcto;
                   }
                   
                   
              
              }
              then you use from the java code :

              new URL ("http://admin/login?usuario=xxx&passw=xxx")

              thats all
              • 4. Re: Write Files through return channel
                843851
                Hello,

                I am also using the Osmosys SDK. I am also working with a servlet but when i execute following code in mhp i get a null reference

                RCInterface[] interfaces = manager.getInterfaces();

                interfaces = null? Does this mean that i don't have a return channel available?

                Any help would be appreciated

                Thanks in advance
                • 5. Re: Write Files through return channel
                  843851
                  Yes, that means there's no RC available. The solutioin is simple, while vewing the emulator tv screen, use the virtual remote control (the on in the ocap vew mode) and enter the menu, look for the network configuration and active it to ethernet with automatic conf. When you see the menu, you'll understand easily.

                  Cheers
                  • 6. Re: Write Files through return channel
                    843851
                    Thanks for your reaction. I got the rc working, and now can access it.

                    But i still have a problem with the RC. I have a servlet which works good. I also created a java project to test this servlet and i can connect without any problems.
                    When i try to connect via the MHP emulator i get connection refused. (This is the same code as the java project!)
                    So it seams the servlet is refusing connection only from the mhp program ( it works in my browser as well)

                    Any thoughts?

                    Thanks alot
                    • 7. Re: Write Files through return channel
                      843851
                      Hello people,
                      This thread has been very useful to me, but I've reached to the same problem. I can't use the return channel from the emulator though I tried to configure it in several different ways. Have you find any solution?
                      Cheers,
                      Miguel
                      • 8. Re: Write Files through return channel
                        843851
                        Maybe windows is blocking traffic from the emulator?

                        Have you got the default windows firewall enabled? Maybe has something to do with this.