How to receive messages from a GPS that uses GPRS via PHP?

3

I have a Gosafe G91i device, a GPS device that sends its location from time to time to an IP and a port that I can configure. At the moment, IP and port of an online server (Orange gps-trace) are set and I would like to set it to a server of mine, where I will store the data. At first, I do not need performance, I just want to see if I can receive the messages. What kind of PHP server should I use? Can it be some simple socket? Any suggestion? Thank you.

The PHP code I have so far from the socket server, still does not handle the messages.

    
asked by anonymous 18.03.2014 / 13:19

2 answers

2

I found the answer to this Stack Overflow question: How to listen to a TCP port using PHP?

I configured GPS using the command (without quotes):

*IP#senha_padrao#IP_Externo#Porta#

I placed my internal network IP in the code that Meraxes user posted , the same port and then it worked, I'm getting the GPS messages.

    
18.03.2014 / 14:26
0

I was able to make gps connect to this code / a> how to deal with and what is the variable that captures msgs?

require_once('/webserver/production/htdocs/assets/SocketServer.class.php'); // Include
    $server = new SocketServer("192.168.1.4",5008); //Criar um servidor de ligação para um determinado endereço IP e ouvir a porta 5008 para conexões
    $server->max_clients = 10; // Número de conexoes simultanea permitido
    $server->hook("CONNECT","handle_connect"); // Executa a funcao handle_connect cada vez que alguem se conecta
    $server->hook("INPUT","handle_input"); // Executar handle_input sempre que é enviado um texto para o servidor
    $server->infinite_loop(); // Inicia o servidor

    function handle_connect(&$server,&$client,$input){
        $this->db->query("insert into teste (texto) values ($input)"); ////////////////////////////////////////////////////////////////////////////////////////

        SocketServer::socket_write_smart($client->socket,"String? ","");
    }

    function handle_input(&$server,&$client,$input){// tratar entrada aq
        $trim = trim($input); // removendo espaços no texto de entrada

        //$this->db->query("insert into teste (texto) values ($trim)");///////////////////////////////////////////////////////////////////////////////////////////

        if(strtolower($trim) == "quit"){ // Parar servidor
            SocketServer::socket_write_smart($client->socket,"Ok! Goodbye..."); // Give the user a sad goodbye message, meany!
            $server->disconnect($client->server_clients_index); // Disconecta o cliente
            return;
        }

        $output = strrev($trim); // inverter string
        SocketServer::socket_write_smart($client->socket,$output); // envia o texto invertido
        SocketServer::socket_write_smart($client->socket,"String? ",""); // solicitar outro texto
    }
    
18.11.2015 / 20:09