Data exchange between PC and Android device on the same loca

Data exchange between PC and Android device on the same loca

Postby Arturo Lopesoria » Tue Feb 20, 2024 11:52 pm

Hello everyone.
I am a FWPPC user but now I have been making small leaps towards Android.

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 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.

2.- I do not require SSL or MultiThreads since it is a TRIVIAL local website between a PC and one or two Android Devices.

3.- The Client and the server should be able to communicate via $Ajax, HttpRequest, Fetch-Api or perhaps WebSocket?

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 an html-javascript-jQuery APP encapsulated using CORDOVA to run in an ANDROID webview. That is, it is responsible for generating all the HTML for the user interface.
For 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 Client side and the server receives it, but when generating the response it violates the CORS rules, generating the error:

Access to XMLHttpRequest at 'http://192.168.1.110/cgi-bin/menu_jmg.hrb?qry=ASKING_SIMPLE_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 headers uhttpd/CGI Module

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 get the "Access-Control-Allow-Origin *" header in.
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.

Any ideas or suggestions for this small scenario of:

Data exchange between PC and Android device on the same local network via WiFi. ?
Arturo LS
Arturo LS
User avatar
Arturo Lopesoria
 
Posts: 94
Joined: Fri Aug 10, 2007 1:47 am
Location: Mexico DF

Re: Data exchange between PC and Android device on the same loca

Postby Otto » Wed Feb 21, 2024 8:42 am

Arturo,
Have you already tried configuring the Apache configuration `Header set Access-Control-Allow-Origin`?
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: Data exchange between PC and Android device on the same loca

Postby Arturo Lopesoria » Wed Feb 21, 2024 12:45 pm

I appreciate your info Otto, it is almost certainly a solution if I use Apache.
The problem is that I don't know if Mod-Harbour /or/ Apache directly allow me to run HRB's /CGI's / instead of PRG's directly, which is MANDATORY in this specific case.
Arturo LS
User avatar
Arturo Lopesoria
 
Posts: 94
Joined: Fri Aug 10, 2007 1:47 am
Location: Mexico DF

Re: Data exchange between PC and Android device on the same loca

Postby Otto » Wed Feb 21, 2024 1:07 pm

Hello Arturo,

I can't quite remember. But I believe I tested it at the beginning.

Since my pressing issues were the development of screens and the flow of the program, I did not look into it further.

Also, one loses focus if one experiments too much.

I also tested CGI only once and it worked well.

But I have the original mod_harbour version in use and no problems.

I also have a mod_harbour regional platform.

https://puon24.com/

Moreover, I only have in-house servers and just a 200/200 connection. I think we should ask Antonio for advice.

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: Data exchange between PC and Android device on the same loca

Postby Antonio Linares » Thu Feb 22, 2024 5:23 am

Dear Arturo,

mod_harbour allows to run HRBs directly
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Data exchange between PC and Android device on the same loca

Postby Arturo Lopesoria » Thu Feb 22, 2024 4:38 pm

Hello Otto and Atonio agradezco sus respuestas.

This means to me that it is my time to enter the world of Mod Harbor beyond simple exploration.
It seems that I will say goodbye to my beloved uhttpd.
Arturo LS
User avatar
Arturo Lopesoria
 
Posts: 94
Joined: Fri Aug 10, 2007 1:47 am
Location: Mexico DF

Re: Data exchange between PC and Android device on the same loca

Postby Antonio Linares » Thu Feb 22, 2024 5:00 pm

Estimado Arturo,

Has revisado el nuevo producto de Carles Aubia ?

https://runnerxbase.app/

Es uhttpd supervitaminado :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Data exchange between PC and Android device on the same loca

Postby Otto » Thu Feb 22, 2024 5:03 pm

Arturo, What kind of software do you plan to develop?
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: Data exchange between PC and Android device on the same loca

Postby Arturo Lopesoria » Thu Feb 22, 2024 11:40 pm

Estimado Arturo,

Has revisado el nuevo producto de Carles Aubia ?

https://runnerxbase.app/

Es uhttpd supervitaminado :-)
regards, saludos

Antonio Linares


No conozco el Producto pero claro qu lo voy a checar
Gracias Antonio.
Un Abrazo
Arturo LS
User avatar
Arturo Lopesoria
 
Posts: 94
Joined: Fri Aug 10, 2007 1:47 am
Location: Mexico DF

Re: Data exchange between PC and Android device on the same loca

Postby Arturo Lopesoria » Thu Feb 22, 2024 11:44 pm

.. Kind of software...

Otto:
For several years I have had some products taking Physical Inventory of Products or Fixed Assets. Check In Out and ToolRoom.

They perform work very separate from ERPs in a Non-Critical environment.

The PC module is basically catalog and reports.
Mobile terminals perform the CRUD part.
The update is almost always Batch.

When Windows Mobile appeared I migrated the mobile part to FWPPC.

Now it is necessary to completely leave WindowsMobie and go with Android but old Users are very used to working Off-Line.
Arturo LS
User avatar
Arturo Lopesoria
 
Posts: 94
Joined: Fri Aug 10, 2007 1:47 am
Location: Mexico DF

Re: Data exchange between PC and Android device on the same loca

Postby Otto » Fri Feb 23, 2024 8:02 am

Arturo,

please see my post:

viewtopic.php?f=45&t=42128&p=252828&hilit=LocalStorage&sid=825fe8abdcb046c5dc6fd5501526530c#p252828

You can temporarily store data from a stocktaking or other not particularly extensive data securely in the LocalStorage of a Progressive Web App (PWA) until you have an internet connection again. LocalStorage offers a simple way to store key-value pairs directly in the user's browser, and is especially useful for PWAs that need to operate offline.

Here is a document how to make from a mod harbour webpage a PWA:
https://winhotel.space/harbourinopublic ... bapp2.html


Best regards,
Otto




Hello friends,
Here you see the source code how the mod harbour web APP sends the data with AJAX and how on the server a program gets the data and appends to a DBF file.
We delete the local storage if we get back success from the server.
If there raises a problem, the data remains stored in the local storage of the web browser.

Best regard,
Otto


Image

Image

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: Data exchange between PC and Android device on the same loca

Postby Arturo Lopesoria » Fri Feb 23, 2024 7:34 pm

Otto:
Thank you so much.

That seems to be exactly what I'm looking for:

How to configure the server and/or a harbor module to respond appropriately to a request from a PWA that is on a different Origin, avoiding violating the CORS policy

I will review it very carefully.
Thanks in advance
Arturo LS
User avatar
Arturo Lopesoria
 
Posts: 94
Joined: Fri Aug 10, 2007 1:47 am
Location: Mexico DF

Re: Data exchange between PC and Android device on the same loca

Postby Arturo Lopesoria » Fri Feb 23, 2024 7:37 pm

Arturo Lopesoria wrote:
Estimado Arturo,

Has revisado el nuevo producto de Carles Aubia ?

https://runnerxbase.app/

Es uhttpd supervitaminado :-)
regards, saludos

Antonio Linares


No conozco el Producto pero claro qu lo voy a checar
Gracias Antonio.
Un Abrazo


Gracias Antonio. He utilizado casi dos días y he avanzado algo con el estudio RX de Carles. Es un producto muy elegante.

1.- Entiendo el enfoque principal de Carles donde RX es responsable tanto del diseño front-end y del back-end de una manera muy sencilla, eso me parece fauloso para el mundo harbour.

2.- Aún no llego al punto de saber si es posible compilar a manera de no exponer el código html/prg en la PC que funge como servidor.

Tampoco he entendido bien todavía cómo hacer para que RX sirva únicamente back-end y permita conexiones desde un orígen distinto, pero seguiré estudiandolo más para ver si puedo usarlo cumpliendo con mis dos propósitos específicos actuales.
Arturo LS
User avatar
Arturo Lopesoria
 
Posts: 94
Joined: Fri Aug 10, 2007 1:47 am
Location: Mexico DF

Re: Data exchange between PC and Android device on the same loca

Postby Otto » Fri Feb 23, 2024 8:43 pm

Arturo,
If I may offer you some advice beforehand, then start your work with mod harbour from FIVETECH.

Antonio has proven all along (I have been involved since 1994) that he solves problems for us and clears the obstacles out of the way.

Although perhaps mod harbour CGI from FIVETECH might be even better, I believe it limits oneself. In the meantime, I have also adopted a pragmatic attitude and use some HTML programs and a bit of PHP, if there are ready-made solutions.

It's not like when you develop a program, it's immediately used by thousands at the same time.
You grow into it.

I myself use our own in-house servers with all clients. We work in parallel from mod harbour and over RDP on the same server.
Years ago, we switched all our users to Remote Desktop.

At the time, I practically rewrote my FW pocket PC application to FIVEWIN in one afternoon and since then, we have been accessing the server via a RDP client with smartphones, and the application runs on the server but is operated through the smartphone.

Best regards,
Otto

Look this:
viewtopic.php?f=3&t=25121&p=215898&hilit=rdp&sid=a5b2f60221d1e2df8f28ccace9605b79#p215898

viewtopic.php?f=3&t=41929&p=251482&hilit=rdp&sid=a5b2f60221d1e2df8f28ccace9605b79#p251482


Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: Data exchange between PC and Android device on the same loca

Postby Arturo Lopesoria » Fri Feb 23, 2024 11:30 pm

A FIVEWIN desktop program on the server does the hard work.
This FW-program monitors a directory. A PHP program writes a text file to this directory.
In the text file the report request is stored.

//write Report task
$Report = fopen( $filename . "txt", "w");
if ($Report == false)
{
echo ("Error in opening new Report");
exit();
}
fwrite($Report, "Print Report: Verkauf ");
fclose($Report);



The FIVEWIN program prepares all the data for the report and stores the data in a CSV file.
PHP program is waiting:
while ($x <= 2)
{
sleep(1);

if (file_exists($filename . "csv"))
{
echo "filename:" . $filename . "csv" . "<br>";


if (file_exists( $filename . "tx" ))
{
echo "lock file exists" . "<br>";
}
else
{
echo "break:" . $filename . "<br>";
$link = true;

break;
}
}
echo "The number is: $x <br>";
$x++;
}

}


Then the PHP program shows the report.

-Otto


Its a simple and great idea !! Thanks Otto

On the other hand, I will be seeing which FiveTech product to continue with.
Antonio is obviously a great Guru for the Harbor community
Arturo LS
User avatar
Arturo Lopesoria
 
Posts: 94
Joined: Fri Aug 10, 2007 1:47 am
Location: Mexico DF

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 81 guests