new file: software/app.php
new file: software/debug.php new file: software/module/report/routes.php new file: software/module/update/routes.php new file: software/public/index.php new file: software/router.php
This commit is contained in:
1 parent
87e828962b
commit
dc78008721
6 files changed
+233
No files matched your search
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
// Reporting endpoint for sensors to report the temperature of each of its sensors etc.
|
||||
|
||||
|
||||
$router->get('/report', function($req) {
|
||||
echo "Nothing to see here!\n";
|
||||
http_response_code(200);
|
||||
});
|
||||
|
||||
$router->post('/report', function($req) {
|
||||
echo 'body:' . var_dump($req->getBody()) . "\n";
|
||||
DumpHTTPRequestToFile::execute("/tmp/out.txt");
|
||||
http_response_code(200);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
$router->get('/favicon.ico', function() {
|
||||
http_response_code(404);
|
||||
});
|
||||
|
||||
$router->get('/update', function() {
|
||||
//(new DumpHTTPRequestToFile)->execute( __DIR__ . '/dumprequest.txt');
|
||||
|
||||
if ( $_SERVER['HTTP_USER_AGENT'] == 'ESP8266-http-Update' && isset($_SERVER['HTTP_X_ESP8266_SKETCH_MD5']) ) {
|
||||
$user_agent = $_SERVER['HTTP_USER_AGENT'];
|
||||
$curr_firmware_md5 = $_SERVER['HTTP_X_ESP8266_SKETCH_MD5'];
|
||||
$firmware_file = __DIR__ . '/firmware.bin';
|
||||
$firmware_md5 = md5_file($firmware_file);
|
||||
echo "USER_AGENT -> ESP8266-http-Update\n";
|
||||
echo 'X_ESP8266_SKETCH_MD5 -> ' . $_SERVER['HTTP_X_ESP8266_SKETCH_MD5'] . "\n";
|
||||
echo 'MD5 file hash of ' . $firmware_file . ': ' . $firmware_md5;
|
||||
if ( $curr_firmware_md5 == $firmware_md5 ) {
|
||||
http_response_code(204);
|
||||
}
|
||||
else {
|
||||
$fwdata = file_get_contents($firmware_file);
|
||||
header('Content-Length:' . strlen($fwdata));
|
||||
echo $fwdata;
|
||||
http_response_code(200);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
http_response_code(400);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user