new file: README.md
modified: app.php renamed: update.php -> device-api.php new file: integration.php deleted: registration.php deleted: report.php
This commit is contained in:
1 parent
9c2de8aad5
commit
2e5a70d33f
6 files changed
+36
-37
No files matched your search
@@ -0,0 +1,13 @@
|
|||||||
|
# Controller Software for DC Sensor
|
||||||
|
|
||||||
|
## API definition
|
||||||
|
|
||||||
|
- id
|
||||||
|
- GET: Returns a new ID for device to use for future communication.
|
||||||
|
- metrics
|
||||||
|
- GET: Prometheus metrics endpoint for temperatures.
|
||||||
|
- report
|
||||||
|
- POST: Device reports temperature back on this endpoint.
|
||||||
|
|
||||||
|
## UI
|
||||||
|
- manage
|
||||||
+6
-3
@@ -12,7 +12,10 @@ $router->get('/', function($req) {
|
|||||||
http_response_code(200);
|
http_response_code(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
require_once('update.php');
|
$router->get('/favicon.ico', function() {
|
||||||
require_once('report.php');
|
http_response_code(404);
|
||||||
require_once('registration.php');
|
});
|
||||||
|
|
||||||
|
require_once('device-api.php');
|
||||||
|
require_once('integration.php');
|
||||||
|
|
||||||
@@ -1,12 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$router->get('/favicon.ico', function() {
|
// Returns a new ID for device to use for future communication.
|
||||||
http_response_code(404);
|
$router->get('/api/id', function($req) {
|
||||||
|
http_response_code(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
$router->get('/update', function() {
|
// Device reports temperature back on this endpoint.
|
||||||
//(new DumpHTTPRequestToFile)->execute( __DIR__ . '/dumprequest.txt');
|
$router->post('/api/report', function($req) {
|
||||||
|
echo 'body:' . var_dump($req->getBody()) . "\n";
|
||||||
|
DumpHTTPRequestToFile::execute("/tmp/out.txt");
|
||||||
|
http_response_code(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
$router->get('/api/update', function() {
|
||||||
if ( $_SERVER['HTTP_USER_AGENT'] == 'ESP8266-http-Update' && isset($_SERVER['HTTP_X_ESP8266_SKETCH_MD5']) ) {
|
if ( $_SERVER['HTTP_USER_AGENT'] == 'ESP8266-http-Update' && isset($_SERVER['HTTP_X_ESP8266_SKETCH_MD5']) ) {
|
||||||
$user_agent = $_SERVER['HTTP_USER_AGENT'];
|
$user_agent = $_SERVER['HTTP_USER_AGENT'];
|
||||||
$curr_firmware_md5 = $_SERVER['HTTP_X_ESP8266_SKETCH_MD5'];
|
$curr_firmware_md5 = $_SERVER['HTTP_X_ESP8266_SKETCH_MD5'];
|
||||||
@@ -29,4 +35,3 @@ $router->get('/update', function() {
|
|||||||
|
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// Prometheus metrics endpoint for temperatures.
|
||||||
|
$router->get('/metrics', function($req) {
|
||||||
|
http_response_code(200);
|
||||||
|
});
|
||||||
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<?php
|
|
||||||
// Device registration endpoint
|
|
||||||
|
|
||||||
$router->get('/registration', function($req) {
|
|
||||||
echo "Nothing to see here at registration!\n";
|
|
||||||
http_response_code(200);
|
|
||||||
});
|
|
||||||
|
|
||||||
$router->post('/registration', function($req) {
|
|
||||||
echo 'body:' . var_dump($req->getBody()) . "\n";
|
|
||||||
//DumpHTTPRequestToFile::execute("/tmp/out.txt");
|
|
||||||
http_response_code(200);
|
|
||||||
});
|
|
||||||
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<?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);
|
|
||||||
});
|
|
||||||
|
|
||||||
Reference in new issue
Block a user