Script php to receive wifi data

0

I have a Wi-Fi sender sensor (CC3200 from texas instruments) and I want to send the data via wifi to a database MySQL local (local PC).

The sensor metric is configured as a http client.

In the PC I have installed XAMPP , the database already developed, a Script PHP ( servidor.php ) that serves as the gateway for the data of the speck.

I put said Script below:

<?php

//incluimos el script insertarbd.php donde tenemos la función crear_base_datos()    
include 'insertarbd.php';
//incluimos el script de emergencias.php
include 'emergencias.php';

//Cogemos de la url el valor de los sensores enviados por el PIC mediante $_GET
@$buffer=$_GET["value"];
//@$buffer=$_POST["value"];

//Llamamos a la función crear_base_datos que se va encargar de almacenar en la base 
//de datos los valores de los sensores
crear_base_datos($buffer);

//llamamos a la función de emergencias
//emergencias();

//Almacenamos los datos en un fichero de texto (Opcional)
$DescriptorFichero = fopen("fichero_prueba.txt","w"); 

//Escribimos la primera línea dentro de él 
fputs($DescriptorFichero,$buffer); 

//Cerramos el fichero 
fclose($DescriptorFichero); 

?>

In a previous project all this worked for me, but now I have changed my sensor and when I send the data the following happens to me (according to the capture with Wireshark ):

**HTTP/1.1 400 Bad Request**

My questions are:

  • Should I put the directory in the "GET" message? That is, do I have to do a GET with "/servidor.php?value=123456\n" or do I have to include the directory "/xampp/htdocs.../servidor.php?value=123456" ?
  • Is there a problem for this connection between the sensor and the database to occur using a Script PHP that you have not taken into account?
asked by AL_Sp 27.06.2017 в 12:43
source

1 answer

0

Usually your local server ( xampp ) will be listening to puerto 80 and will redirect requests to one of the following directories \xampp or \htdocs this will be taken as the root directory of the site. If no path or file is specified, usually apache will deliver the file index.html , index.php ... According to the configuration.

You must configure a static IP for the LAN in the machine that makes servidor to avoid problems when accessing from other machines in the network LAN .

Once this is done you must point from the machines that you want to access said IP .

Example, assuming that the IP of the server is 192.168.1.10 and that the Script PHP that we want to access is called servidor.php and it is in the root directory.

http://192.168.1.10/servidor.php
    
answered by 27.06.2017 в 16:50