modified: .gitignore
modified: software/README.md modified: software/app.php modified: software/database/sqlite.php modified: software/device-api.php modified: software/router.php
This commit is contained in:
1 parent
50eec7e284
commit
c44e580120
6 files changed
+62
-15
No files matched your search
+25
-1
@@ -1,7 +1,30 @@
|
||||
<?php
|
||||
|
||||
// Returns a new ID for device to use for future communication.
|
||||
$router->get('/api/id', function($req) {
|
||||
$router->post('/api/register', function($req) {
|
||||
$data = $req->getJSONBody();
|
||||
//echo "Body: ".var_dump($data)."\n";
|
||||
|
||||
// Verify a mac address was sent...
|
||||
if(!isset($data['mac_address']) || !preg_match("/^[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]$/i",$data['mac_address'])) {
|
||||
echo $data['mac_address']." does not match a mac address.\n";
|
||||
http_response_code(400);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
$newDevice = [
|
||||
'id' => 'device123',
|
||||
'mac_address' => $data['mac_address'],
|
||||
'ip_address' => '192.168.1.2',
|
||||
'seen_ip_address' => '192.168.1.2',
|
||||
'firmware_version' => '1.0.1',
|
||||
'temperature_offset' => 0,
|
||||
'humidity_offset' => 0,
|
||||
'last_updated' => date('Y-m-d H:i:s'),
|
||||
'last_seen' => date('Y-m-d H:i:s')
|
||||
];
|
||||
$deviceDb->addDevice($newDevice);
|
||||
*/
|
||||
http_response_code(200);
|
||||
});
|
||||
|
||||
@@ -35,3 +58,4 @@ $router->get('/api/update', function() {
|
||||
|
||||
http_response_code(400);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user