Windows Embedded Handhel 6.5 app development synchronize windows PC - php

What is the best alternative to synchronize an app on Windows Mobile 6.5 with SQL Server Compaq with an php aplication on a PC server.
The phone does not always have internet access beacouse coverage issues, also can be connected to a PC via USB.
The data are in a table in SQL Server Compaq on the phone, the data are text and a number, associated through an identifier. This is updated from time to time where there is no internet connection. Then this data update a database in SQL Server 2008 on a server that has internet access.
There is also the possibility to update the phone's data table from the server to add more data to be updated in the field.
I hope you understand me because English is not my native language.
I was thinking of using exchange to send emails with updated data or use a service like dropbox to keep an updated file and that file is processed.
Which approach is better?
I hope you can guide me.
thank you very much.

If you are running a SQLClient on the CE device that connects to a SQL server, the best solution is to use the SQL synchronization options. This is also called RDA, see for example: http://etutorials.org/Programming/building+solutions+with+the+microsoft+net+compact+framework/Part+II+Essential+Architectural+Concepts/Chapter+7.+Data+Synchronization/RDA/
If the databases on the device and on the server are not connected, the automatic ID generation on the device and the server create different unique IDs. These will result in a conflict, when you update the data from multiple sources. If you do not need to handle conflicts with multiple sources updating the same database, you may simple send the updates between the server and the client and vice versa on regular intervals using http GET/POST or simple socket server/client.
Usually sometimes disconnected devices use http or another network protocol to pull and push updates. Files are rarely used for push/pull updates.
As you used the php TAG for this question too, using http with a php server with a database in the background, you can use php to extract data sent via GET/POST and also provide data back to the device using xml (or another format).

Related

Setting up URL for a webservice

I'm trying to plan out a mobile application (iOS) that has to connect to a remote database. After doing some research, I found that I'd have to connect to the DB by using a PHP framework.
I learned this from reading multiple articles, but I specifically got my information from this stack overflow question: How to connect mysql with swift?
What I'm confused on is how I can set up the URL for the web service. How is this accomplished? Is this some sort of server you pay for? Can you set the URL to be the same as your remote database server?
For example, in the last piece of code in the linked stack overflow answer, the user had:
//URL to our web service
let URL_SAVE_TEAM = "http://192.168.1.103/MyWebService/api/createteam.php"
What exactly is this?
I think I am misunderstanding a concept here.
"192.168.1.103" or "google.com" identifies a server (PC) on the local network or on the internet. It is either your own PC or a rented one from some hosting provider. I would suggest the following steps:
Identify what platform do you want to use as your remote database. I see you are quoting some text about mysql, but there are a lot more choices. You could look into noSQL databases like CouchDB or you could use just a file with text hosted somewhere.
Based on the platform you can check where you could buy hosting for your database. I could suggest looking into Amazon AWS, they can provide you a free Linux PC, where you can host MYSQL server or CouchDB server or even a simple file server to host your data. You can also first try to install corresponding server to your local machine (e.g. to the same one running iOS emulator) and try to connect using http://localhost address (url).
Connect to the corresponding server from your iOS App and write logic to read, update, create, delete data if it is needed.

Direct communication between php script to client (Windows or Android)

I am thinking about a scenario where I want to send a data packet from my php service (based on certain behaviour) to a client (can be Android or Windows) connected to it.
A device which is connected to the internet is going to have an ip address.
So is it possible to send a packet (using socket or else) to this ip directly (without polling from client end) and can this data be read from the client.
Scenario is like this :
Client A --------------Registers Own IP Address-----------------> Server
Client B --------------Registers Own IP Address-----------------> Server
Events :
Some changes occur in the database (say)
Server detects the affected client (via some algo),say Client A
Sends a packet to Client A
Client A <--------------Send Data Packet----------------- Server
Is this at-all possible ?
If yes, how effective can this be ?
Please note that, Push notifications is not applicable in my situation.
I am looking for a live (realtime) data transmission system between client and server (both ways).
Any suggestion, help will be useful. Thanx
Absolutely possible to have persistent sockets open.
but I would say this would fail in a hosted environment. GoDaddy etc shuts that down. Been there done that.
I would highly recommend choosing a programming language like java (Whatever you are comfortable with). It is only going to be 200 lines of code.

How to receive GPS data from device with PHP?

I have a car GPS device, the only thing I can change is the IP-address.
Is it possible to have shared hosting with a dedicated IP-address (that part is possible) and then to have a PHP script that picks up the data that is being send?
So what is in my mind:
GPS device send gps data to IP-address.
That IP-address has a PHP script that picks up the data and use it.
As requested a little bit more detailed.
There is a question that is exactly the same but don't have an answer: how-to-get-data-from-gps-and-send-to-server-and-how-save-to-database
It is a Chinese car GPS device with a standard IP address. So it sends data to that IP address. Then they give us a website where we can login with the product code and we can see the GPS location.
It is possible to change the IP address in this device. I have found shared hosting with a dedicated IP address, but that means the IP address just replaces the URL so it works just as an URL, so it is not that I can change the server and install something like openGTS.
But I have no idea what kind of data (I don't think it is just GET or POST data) this device is sending. So I am wondering if the GPS is sending the data to an IP address whether I have to do something special with java on that server or I am able to use a PHP script to pickup what the GPS device is sending? Once I get the data I know what to do with it. All I need is the data to be picked up by a PHP script.
There is not a shortcut as I was hoping. For a gps tracker device that sends TCP/UDP data to an ip address and port we really need a server. There will be no POST/GET data. The server will receive data through a port that needs to be decoded. But it was not as complicated as I thought. Even without any knowledge of Java I was able to install a software and manipulate it to my liking.
What I did:
Got a windows server (2012) hosting (6 months for free) so I could
try it out.
Downloaded opengts and followed their instruction manual exactly. And did not find it hard at all. It worked without having much headache
Once I got to the part where everything was working I could play around with the device and it was working fine. Ofcourse we need to know the protocol (the data) that the device is sending and decode so it can be saved in the database.
you need this:
The phone(Number) (with GPS).
A SmartPhone( Androir and develop your own APP) - (Like a Sub-Server).
A (Home Server) or (WebServer) with MySQL(Data Base).
A Script with PHP in your Server or WebPage(Point 3).
So:
The (Phone Number with GPS) just wait for a call or something to send the "Data".
(The SmartPhone) get the data from (The Phone Number with GPS).
Read the Message Board ONLY from your (Phone Number with GPS) with (your Own APP Android) AND Process the "Data" with (your Own Android APP).
Get the "String" of (Lat) and (Lon) Coordinates Or ALL your need from the (Message Board) and SEND to your (PHP Script) using HTTP request to your (Home Server or WebPage) From your (SmartPhone) Using your (Own Android APP).
Work with your (PHP Script) and save in your (MySQL Data Base).
... you can do everything now with the "Data", like show with other php script and google maps api, or use for a desktop application on java, or visual basic, etc..etc..., or all you wish.
Note:
*Not use your (SmartPhone) for nothing, only for prossesing "Data" of ALL (Phone Numbers) your want Using your (Own Android APP) Reading the Message Board with Code, so your (SmartPhone) now is like a "Mini Server" and only works as an intermediary between your (Phone Number with GPS) and your (PHP Script) in your (Home Server or WebPage) with (MySQL Data Base).
You need to use Database, create php script (POST query) and update query into database when GPS position change, than you can have access to this position from database with another php script (GET and return json object)
If you have a shared hosting, you'll only have the 80 port open. So in your device, you will need to make HTTP requests to that IP on port 80.
In order to make a correct HTTP request, read the RFC2616 (http://www.w3.org/Protocols/rfc2616/rfc2616.html) to get started with HTTP protocol.
At minimum, you will need to provide a hostname and URI in your HTTP request.
On that URI, your PHP script will be able to read data and do something with it.

How to connect VB.NET to Web Host

Basically, I want to create an application like this:YOUTUBE
I want to create an application that when I add some information from my web host (either PHP or MYSQL) VB.NET will read it.
From your website you'll need to insert the data into your MySQL database.
The problem with using the database provided by your web host is that the chances are, due to 'Security Reasons' the will have disabled external access.
This means that any files outside of your web server (your sites root/sub directory) will not be able to access the data. So, while your website will be able to connect without a problem, your program will not.
Some hosts give its customers the opportunity to add an IP address to a white list which enables them to bypass their security system. However, most will not give you this option.
My suggestion is that you either rent a VPS where you can run both the WebServer and Your MySQL database (and PHPMyAdmin) from or Set Up A MySQL database on your PC (its not that difficult just read the manual and youll be fine). If you had a VPS then you would no longer need your pre hosted webserver as you could run your own. You would need to point your domain name to your VPS webserver. It will act just like any other.
By running your own MySQL Databse you are given the option to enable remote access. This means that any external entity with the correct details will be able to connect.
If you cant get a VPS or don't want to run your own server or rent a server that allows for external access. Check out db4free.net .They provide you with a free MySQL Database with external access for Developers to test out their systems. They are not ultra fast so that's something you may want to be aware of. Another thing is that your data that's held can be removed at any time. The servers are not there to be used permanently just for testing.
So how do I connect to it through VB???
Good Question! To establish a connection, I suggest you use MySQL.Data library provided my DevMySQL themselves and import it into your program. Done so by Imports MySQL.Data.MySQLClient. This is written by them to work with their databases. Yes you can connect using some of the functions already in VB but in my opinion they don't work as efficiently. You'll need to download the MySQLConnector to connect as well.
Hopefully That Answers Your Questions. Any Problems Just Comment below!
Regards
Joe

Making the web server as a relay between two sides

I want to control a robot from the web, the robot is connected to Android device. The operation will be as the following :
a web application written using JavaScript and HTML runs on desktop computer which takes the keyboard input from the user and send them to the android device connected to the robot.
the android device receive the commands and then send them to Arduino board which used to control the robot.
But how should I deliver the data to the Android device which doesn't has a static IP address?
I have two approaches to solve that :
the JavaScript application sends the keyboard input to a web server runs PHP and MySQL , then the php application store the data on the MySQL database. An application runs on Android connected to that web server and extract the data from the MySQL database.
the JavaScript sends the data to the web server. The android application connected to the web server receives the data directly so the web server is just used as a relay.
The first approach is easy to do but its slow , so my question is...
How to implement the second approach and which web technologies should I use to implement it? And how to make the web server works as relay between two sides?
PS : I am planning to use 000webhost.com as web server. so I will not use my own server
You can either have your Android application poll the webserver for outstanding commands. This is a little inefficient in terms of data usage, but if you're on an unlimited 3G plan / wi-fi, you could live with it. It will be very easy to implement.
Alternatively, set up a TCP server on your server, and have your Android application open a socket connection with the server. This way, your web application can send commands to the server which will immediately stream them to the Android device. It will be slightly harder to implement, but will be more efficient and robust if done right.
PS - Most shared servers don't allow you to open a TCP server on your host so you might be forced to go with the first option.
PPS - I wasn't aware of Google Cloud Messaging. It seems to be a good solution for you what you're attempting to achieve. You should have a look into it.

Categories