How to send commands to gps tracker with php - php

I'm trying to develop php based tracking software for my gps tracker gps107.
My tracker has GPRS and I have successfully associated my tracker with open source tracking software "Traccar" which is written in java and located in my server.
But now I want to develop my own custom software for my needs in php.
I also have the protocol manual where I can see available commands and their responses.
example command for locating:
server -> device
**,imei:359586018966098,100
device -> server imei:353451044508750,001,0809231929,,F,055403.000,A,2233.1870,N,11354.3067,E,0.00,,;
How can I send these commands with php ?

The communication between server and a device is made with UDP or TCP protocol. To make this type of a connection with PHP you have to create PHP socket server. Then you assign server IP and port to your device, and the device will connect to the server as a client. After that you can receive and send commands.
PHP Doumentation about sockets: http://php.net/manual/en/book.sockets.php
Excample socket server: http://devzone.zend.com/209/writing-socket-servers-in-php/

Related

Best way to connect two socket servers (node.js and ratchet php)

There are two socket servers that have to send messages to each other. The first one is a node.js server with socket.io. The second is ja php websocket (ratchet - http://socketo.me/).
The second server (ratchet) runs in a php application (created with a php framework like laravel or symfony) that contains a basic chat application.
The node.js server is like a global manager that can convey messages to multiple socket servers.
The communication ways are planned as follows:
Scenario a)
-> client / browser sends a message via websocket
-> php app receives message from browser by ratchet socket and stores this message in database
-> php sends / forwards message to node.js via socket
-> php sends response to client / browser via websocket
Scenario b)
-> node.js server sends a message to all connected php clients via socket
-> php receives message from node.js and stores this message in database
-> php sends this message to one or more connected browser clients
-> browser receives messages from php via websocket
What is the best way to enable this communication way? The browser is already able to talk to the ratchet server. But I have no idea how the ratchet server can talk to the node.js server an act as a normal socket client so that they will establish and hold a connection to each other. Is there a command to send a “hello, I am a new client that wants to establish a connection” message to the node.js server or vice versa?
Is this a good concept at all? Or is there a better way to send socket messages over multiple instances? Are there any tips, tutorials or examples? Other questions to this topic are very old or contains a different setup.
I'd probably use this : https://github.com/ratchetphp/Pawl to have PHP sending messages to nodejs.
Then about the concept being good, I think not.
There is no point in having two differents websockets servers imo.
I'd probably use only one websockets server (nodeJS), and have PHP and node "talk" together through a messaging queue like rabbitMQ / REDIS

How to create a Arduino/Raspberry pi api?

I always want to create an API which lets me send value over the internet to an specific Arduino board or raspberry, I know that I can do it with a third party Server like>
https://www.teleduino.org/
or https://www.yaler.net/ or if I use Raspberry I can install it Android and send data through GCM. But I don't want to use any other server, I already have a PHP hosting.
I think that I need to open a XMPP port or something to call directly the Ethernet shield or the the raspberry pi IP.
Will I need a static IP.
Any suggestions?
You want to write you own PROTOCOL, it can be based or use other protocol.
If you have complete access to server, my suggestion is to use TCP Socket direcly (Client class on arduino with write e read, like using the Serial), if you can't then you have to "tunnel" your PROTOCOL over an accepted protocol on the server. If it has php then the protocol il HTTP, witch is based on TCP. see http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Example_session

Make the Android app as a Server..?

How to make the android app as Server. I installed web server in the Android device and tried to call the service from the php which is the client. Its telling that it is unable to listen to the socket. I Implemented SOAP to send the request from the Php client to the Android server. Any suggestion.>?
Or is there any other method.? other than TCP socket listening.
please read below link fetch data from server to andriod mobile
http://codeoncloud.blogspot.in/2013/07/android-mysql-php-json-tutorial.html

PHP script that enables client communication with custom hardware

We have a wireless device (WIFI enabled) that calls a PHP script to enter data into MySQL db. Am trying to find a way to see if the server (through PHP script) can "connect" to the client device (has a microcontroller but doesn't have an OS or display) and pass some data.
The client is a electronic board connected to a gate and the server needs to tell the device to open the gate. Seems to be pretty straight forward but am new to this.
If the client is configured to listen on a specific port, you can open a socket connection to it from the server (using fsockopen()).
You'll need to configure the client though, which I have no idea how to do because your client is nothing standard.

Send udp packet on LAN from web browser

I have built a simple TAPI app that will run on a machine on the LAN that connects to the office PBX, it allows me to receive dial, answer, hangup etc commands (which I was planning on receiving via a udp packet). I did this with the intention to integrate the office CRM system to the phone system.
Having done this and testing using a simple python app to send the udp packets I find myself wondering how to send the udp packets to this app given that the CRM system is a web app written in php/javascript.
We use Firefox in the office and so I was going to start with a Firefox extension, but I thought I would ask and see if anyone has any experience on sending udp packets over a lan from a browser using java or flash or from a browser extension/plugin.
Or is there a better cross browser way to send commands to an app on a network pc when the web app is hosted online?
Maybe in the CRM you could use javascript and JSONP to make a request to a local HTTP server, and that server could then send the UDP packets instead.

Categories