SUBJECT: Data exchange between PC and Android device /
ASUNTO: Intercambio de datos entre PC y dispositivo Android
Hello everyone.
I have an Inventory program based on
- H.M.G.
- Hmg4Web - uhttpd
- JMG-cordova app
Built like this:
- Central Module:
Windows program made with Hmg 3.0.25 (Dbf Data)
- Web Communication with NEARBY Android Portable Terminals (Same Local Network):
uhttpd Server and prg-CGI Modules made with Hmg4Web_002
For CLOSE operation - SAME LOCAL NETWORK, it had been sufficient to link the Central Module with the Android terminals through the Harbor UHTTPD server that serves the CGI modules that serve as both the Front-End Interface for the Android devices as well as the Back-End affecting the DBF tables that are shared with MODULO.CENTRAL
NEW NEED:
- Web Communication with FAR (OFF-LINE) Android Portable Terminals:
THIS IS where the JMG-cordova app is BORN
I use uhttpd.exe server
(v.0.4.4 FIXED_THREADS from (c)2009 by Francesco Saverio Giudice)
It WORKED very well for me when I used it to generate the HTML to the Client, serving as a simple and easy Front-End and Back-End.
NOW THE CHALLENGE IS DIFFERENT. The NEED NOW is:
1.- The FAR Terminals must be able to operate OFF-LINE
2.- The Front-End must be separated from the Back-End. I do not require the server-side PRG-CGI module to generate anything from the front-end (HTML), the Client will take care of that.
3.- I DO NOT REQUIRE SSL or MultiThreads since the FAR terminals are very few, they operate the business logic completely OFF-LINE and when they exchange data it is until they are on the SITE and linked to the LOCAL WIFI NETWORK, which is a website TRIVIAL local
4.- Because the communication is between different OS's, I can't find any other way that the Client and the server should be able to communicate via $Ajax, HttpRequest, Fetch-Api or maybe WebSocket?
FOR THE NEW STAGE I'M STILL TRYING WITH UHTTPD
A.- For the BACK-END SERVER side (CGI Module) I use a PRG compiled as CGI, for now very simple and simple, configured to receive requests and respond to requests. It reads the Request and accordingly generates the responses that are data from .dbf tables, which reside on the PC and at that point the prg program hard-coded opens tables, and generates responses either in array, json or hash, whichever is most compatible with the scenario.
B.- On the FRONT-END CLIENT side I use JMG to encapsulate an html-javascript-jQuery APP using cordova to run in the ANDROID webview. That is, it is responsible for generating all the HTML for the user interface.
For all this I based and adapted ideas from JMG. (Robert)
CURRENT SITUATION:
I have not achieved communication, my first approach is the simplest, I make an $Ajax request from the Front-End Client side and the server receives it, (200) but when generating the response it is rejected for violating the CORS rules, generating the error:
Access to XMLHttpRequest at 'http://192.168.1.110/cgi-bin/menu_jmg.h ... IMPLE_TEXT'
from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Which means it doesn't find the appropriate SERVER side uhttpd/CGI Module headers:
(Content-Type different from HTML) and
("Access-Control-Allow-Origin *")
PROBLEM:
I require to be able to change the headers either in the CGI module or perhaps in the uhttpd.
I can't find how to make uhttpd respond in any way other than HTML and introduce the headers outside the <body>
It always responds with fixed headers by default.
I have also not been able to compile the uhttpd that is included in:
harbor\core\extras\httpsrv and maybe from there use the insert header functions that I see in the sources. But I still don't even know if I'm going down that path right.
Get uhttpd to respond in some way that supports $Ajax, HttpRequest(), or Fetch-API communication.
I don't dare use Mod-Harbour for this either. Because?
- I have not seen how to use .HRBs instead of .PRGs from Mod-Harbour
- I found it TOO ROBUST for such a simple need.
Maybe this solution does not even require a web module but I don't know.
Any ideas or suggestions for this small scenario of:
Data exchange between PC and Android device on the same local network via WiFi. ?
I would appreciate any comments!!
Arturo Lopesoria.
(Mexico)
-----------------------------------------------------------------------------------------
ASUNTO: Intercambio de datos entre PC y dispositivo Android
Hola a todos.
Tengo un programa de Inventarios basado en
- HMG
- Hmg4Web - uhttpd
- app JMG-cordova
Construido así:
- Módulo Central:
Programa Windows hecho con Hmg 3.0.25 (Datos Dbf)
- Comunicación Web con Terminales Portátiles Android CERCANOS (Misma Red Local):
Servidor uhttpd y Módulos prg-CGI hechos con Hmg4Web_002
Para la operación CERCANA - MISMA RED LOCAL Había sido suficiente enlazar el Mósulo Central con las terminales Android mediante el servidor Harbour UHTTPD que atiende a los módulos CGI que sirven tanto de Interfz Front-End para los dispositivos Android así como de Back-End afectando las tblas DBF que se comparten con el MODULO.CENTRAL
NUEVA NECESIDAD:
- Comunicación Web con Terminales Portátiles Android LEJANAS (OFF-LINE):
ES AQUI donde NACE la app JMG-cordova
Utilizo el servidor uhttpd.exe
( v.0.4.4 FIXED_THREADS de (c)2009 de Francesco Saverio Giudice )
Me FUNCIONABA muy bien cuando lo usaba para generar el HTML al Cliente, sirviendome como un sencillo y fácil Front-End y Back-End.
AHORA EL RETO ES DIFERENTE. La NECESIDAD AHORA es:
1.- Las Terminales LEJANAS deben de poder funcionar OFF-LINE
2.- El Front-End debe estar separado del Back-End. No requiero que el modulo PRG-CGI del lado servidor genere nada del front-End (HTML), de eso se encargará el Cliente.
3.- NO REQUIERO SSL ni MultiThreads ya que las terminales LEJANAS Son Muy Pocas, operan la lógica de negocio totalmente OFF-LINE y cuando intercambian datos es hasta que se encuentran en el SITE y enlazada la la RED- WIFI LOCAL que es una web local TRIVIAL
4.- Debido a que la comunicación es entre distintos S.O.'s No encuentro otra forma que El Cliente y el servidor deberan poder comunicarse vía $Ajax, HttpRequest, Fetch-Api o tal vez WebSocket?
PARA LA NUEVA ETAPA AUN SIGO INTENTANDO CON UHTTPD
A.- Para el lado SERVIDOR BACK-END (Módulo CGI) uso un PRG compilado como CGI, por ahora muy simple y sencillo, cofigurado para recibir peticiones y responder a las solicitudes. Lee el Request y acorde a ello genera Las respuestas que son datos procedentes de tablas .dbf, que reciden en la PC y en ese punto el programa prg de manera hard-coded abre tablas, y genera respuestas ya sea en formato array, json o hash, lo que resulte más compatible con el escenario.
B.- Del lado CLIENTE FRONT-END Uso JMG para encapsular mediante cordova una APP html-javascript-jQuery para ejecutarse en el webview ANDROID. Esto es, se encarga de generar todo el HTML para la interfaz de usuario.
Para todo ello me basé y adapté ideas de JMG. (Roberto)
SITUACION ACTUAL:
No he logrado la comunicación, mi primer aproach el más sencillo, hago una petición $Ajax del lado Cliente Front-End y el servidor la recibe, (200) pero al generar la respuesta es rechazado por violar las normas CORS, generando el error:
Access to XMLHttpRequest at 'http://192.168.1.110/cgi-bin/menu_jmg.h ... IMPLE_TEXT'
from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Lo que significa que no encuentra los encabezados apropiados del lado SERVIDOR uhttpd/Modulo CGI:
( Content-Type diferente a HTML ) y
( "Access-Control-Allow-Origin *" )
PROBLEMA:
Requiero poder cambiar los encabezados ya sea en el módulo CGI o tal vez en el uhttpd.
No encuentro cómo lograr hacer que uhttpd pueda responder de otra manera que no sea HTML y lograr introducir los encabezados fuera del <body>
Siempre responde con unos encabezados fijos por default.
Tampoco he logrado compilar el uhttpd que se incluye en:
harbour\core\extras\httpsrv y tal vez desde ahí utilizar las funciones de insertar encabezados que veo eln los fuentes. Pero aún ni siquiera sé si voy bien por ese camino.
Lograr que uhttpd responda de alguna manera compatible con la comunicación compatible tipo $Ajax, HttpRequest() o Fetch-API.
Tampoco me animo a usar Mod-Harbour para esto. Porqué?
- No he visto cómo hacer para utilizar .HRBs en lugar de .PRGs desde Mod-Harbour
- Me result DEMASIADO ROBUSTO para una necesidad tan simple.
Tal vez esta solucion n siquera requiera un módulo web pero yo lo desconozco.
Alguna idea o sugerencia para este pequeño escenario de:
Intercambio de datos entre PC y dispositivo Android en la misma red local vía WiFi. ?
Agradecería cualquier comentario!!
Arturo Lopesoria.
(México)
-------------------------------------------------------------------
Data exchange between PC and Android device on the same local network via WiFi. ?
Moderator: Rathinagiri
- arturo_lopesoria
- Posts: 31
- Joined: Tue Sep 09, 2008 3:05 am
- Location: Mexico
- serge_girard
- Posts: 3204
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Data exchange between PC and Android device on the same local network via WiFi. ?
Arturo,
I did exchange via MySQL database. Maintain etc. via HMG programs and viewing via website PHP programs. So via tablet op SmartPhones or PC accessible.
In my case end-user used a tablet to let cumstomers sign a form (update in MySQL db) and HMG program timers did the rest... (a bit complicated but after all it worked perfect)
Greetings, Serge
I did exchange via MySQL database. Maintain etc. via HMG programs and viewing via website PHP programs. So via tablet op SmartPhones or PC accessible.
In my case end-user used a tablet to let cumstomers sign a form (update in MySQL db) and HMG program timers did the rest... (a bit complicated but after all it worked perfect)
Greetings, Serge
There's nothing you can do that can't be done...
- arturo_lopesoria
- Posts: 31
- Joined: Tue Sep 09, 2008 3:05 am
- Location: Mexico
Re: Data exchange between PC and Android device on the same local network via WiFi. ?
Dear Serge
I appreciate your kind response.
The path you have implemented sounds much more robust and seems to be the most accepted. On the other hand, what I am trying seems to be already obsolete.
However, I continue trying to rescue for my tiny and trivial projects the old way of working with a completely offline client that only communicates with the server when it is on site, and wants to update catalogs and send the result of its work online. batch, and really for this simple thing it still seems like there are too many ingredients to do it through the official route.
I was hoping that something as simple and easy as uhttpd and dbf could still be used but it seems that I will have to give up for good.
I appreciate your kind response.
The path you have implemented sounds much more robust and seems to be the most accepted. On the other hand, what I am trying seems to be already obsolete.
However, I continue trying to rescue for my tiny and trivial projects the old way of working with a completely offline client that only communicates with the server when it is on site, and wants to update catalogs and send the result of its work online. batch, and really for this simple thing it still seems like there are too many ingredients to do it through the official route.
I was hoping that something as simple and easy as uhttpd and dbf could still be used but it seems that I will have to give up for good.
- serge_girard
- Posts: 3204
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Data exchange between PC and Android device on the same local network via WiFi. ?
Arturo,
It may sound complicated but after all it is *not* rocket science.... It is indeed robust and secure.
Indeed you need to be online and if connection often fails you will need to go offline. To resolve this will involve complex coding (but I did it: when no internet connection I switch tot local DBF)...
Don't give up to soon!
Serge
It may sound complicated but after all it is *not* rocket science.... It is indeed robust and secure.
Indeed you need to be online and if connection often fails you will need to go offline. To resolve this will involve complex coding (but I did it: when no internet connection I switch tot local DBF)...
Don't give up to soon!
Serge
There's nothing you can do that can't be done...
- arturo_lopesoria
- Posts: 31
- Joined: Tue Sep 09, 2008 3:05 am
- Location: Mexico
Re: Data exchange between PC and Android device on the same local network via WiFi. ?
Serge:
I am interested that when you are offline you use DBF's.
Currently my Androd Client is only capable of using localdb (the sqlite variant that comes by default in the webview) or localstorage but I have never implemented access to dbf with Android.
Is it on Android where you have implemented local dbf?
In that case, what is the path you have chosen to achieve it?
I am interested that when you are offline you use DBF's.
Currently my Androd Client is only capable of using localdb (the sqlite variant that comes by default in the webview) or localstorage but I have never implemented access to dbf with Android.
Is it on Android where you have implemented local dbf?
In that case, what is the path you have chosen to achieve it?
- serge_girard
- Posts: 3204
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Data exchange between PC and Android device on the same local network via WiFi. ?
Arturo,
On Android not yet with DBF. Maybe someone else has? I think it might be possible.
On Android not yet with DBF. Maybe someone else has? I think it might be possible.
There's nothing you can do that can't be done...
- arturo_lopesoria
- Posts: 31
- Joined: Tue Sep 09, 2008 3:05 am
- Location: Mexico
Re: Data exchange between PC and Android device on the same local network via WiFi. ?
+1 Me too !! I think it might be possible