PHP How do I get the broadcast from the bluetooth gateway over the HTTP protocol server?

you may check the document of thinkphp5. Where’s the error log for thinkphp5?

Do you use apache or nginx. For apache, the access log and error log is usually

/var/log/httpd/error_log

and

/var/log/httpd/access_log

it’s very depend on your system.

  • This is the tp5 error log on the server

As noted elsewhere on the web, php://input content does not get through if request is redirected. Maybe your web server has a redirect from an URL starting with www to an URL without www, or from URLs using HTTP to URLs using HTTPS. Check your web server logs to verify this, and act accordingly to avoid the redirection when making calls to the web service.

thinkphp5 do the redirect 302 and make php://input can’t be readed

it seems thinkphp5 has a help function input(); try the code

var_dump(input())

* Is this the right configuration

* Now this is received has not received.

The log shows requests from gateway. It means the setting for gateway is ok.

I check the document of thinkphp5. It says you should use class Request.getInput() method to get ‘php://input’

image

Still not good, has the server received the data now?

sorry. I have no better idea. Can you run a example without any framework?

Make it as simple as possible. e.g.

<?php

$cont = file_get_contents('php://input');
$data = @msgpack_unpack($cont);

error_log(var_export($data, 1), 3, "/tmp/ble.log");

I don’t know anything about the framework.

Or you can try to test it with our MQTT broker first. see the link How to test

  • It’s the same without the framework, you can’t pass the data

I tested with code and it works fine.

<?php

$cont = file_get_contents("php://input");
echo("len " . strlen($cont) . "\n");

file_put_contents("/tmp/dump_" . time() . ".log", $cont);

Please try to change the settings of your gateway

  • host: testota.bconimg.com
  • port: 80
  • URI: post.php

I will check the data at my end

I have been using the browser to request the error. I just need to save the data to the database after I receive it. Thank you for your trouble!

Hello, I would like to ask about the data that has been parsed. Is this the MAC address of the gateway or the MAC address of the bluetooth device?

@aprilpeas

It’s the MAC address of the bluetooth device. see the wiki for more details.

Does the same bluetooth device have the same MAC address that is parsed every time