Skip to content
32 changes: 31 additions & 1 deletion app/Http/Controllers/RadioController.php
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,37 @@ public function setTimeoutConfig($seconds)
return response()->json(['message' => 'Server error'], 500);
}

public function getDigitalVoice()
{
$command = "get_digital_voice -p 1";
$output = explode("\n", (string) exec_uc($command))[0];

if ($output == "OFF" || $output == "ON") {
return response($output, 200);
}

(new ErrorController)->saveError(static::class, 500, 'API Error: Error during getting the digital voice mode - ' . $output);
return response()->json(['message' => 'Server error'], 500);
}

public function setDigitalVoice(int $value)
{
if (!in_array((string) $value, ['0', '1'], true)) {
(new ErrorController)->saveError(static::class, 500, 'API Error: digital voice value must be 0 or 1');
return response()->json(['message' => 'Server error'], 500);
Comment thread
mtsthibau marked this conversation as resolved.
Comment thread
mtsthibau marked this conversation as resolved.
}

$command = "set_digital_voice -a " . $value. " -p 1";
$output = explode("\n", (string) exec_uc($command))[0];

if ($output == "OK") {
return response(true, 200);
}

(new ErrorController)->saveError(static::class, 500, 'API Error: Error during updating the digital voice mode - ' . $output);
return response()->json(['message' => 'Server error'], 500);
}

public function getBitrate()
{
$command = "get_bitrate"; /*UPDATE COMMAND*/
Expand Down Expand Up @@ -947,7 +978,6 @@ public function getPowerLevel($profile)

public function setPowerLevel(Request $request)
{

if ($request->powerLevel >= 0 && $request->powerLevel <= 100) {
$command = "set_power -a " . $request->powerLevel . " -p " . $request->profile;
$output = explode("\n", (string) exec_uc($command))[0];
Comment thread
mtsthibau marked this conversation as resolved.
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public function showAllUsers()

public function showOneUser($id)
{
if (!$user = User::firstWhere('email', $id)) {
$user = User::find($id);

if (!$user) {
(new ErrorController)->saveError(static::class, 404, 'Could not find user');
return response()->json(['message' => 'Not found'], 404);
} else {
Expand Down
3 changes: 2 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,13 @@
$router->post('/voice/timeout', ['uses' => 'RadioController@restartVoiceTimeout']);
$router->get('/voice/timeout/config', ['uses' => 'RadioController@getTimeoutConfig']);
$router->post('/voice/timeout/config/{seconds}', ['uses' => 'RadioController@setTimeoutConfig']);
$router->get('voice/digital', ['uses' => 'RadioController@getDigitalVoice']);
$router->post('voice/digital/{value}', ['uses' => 'RadioController@setDigitalVoice']);
Comment thread
mtsthibau marked this conversation as resolved.
Comment thread
mtsthibau marked this conversation as resolved.
$router->get('/bitrate', ['uses' => 'RadioController@getBitrate']);
$router->get('/snr', ['uses' => 'RadioController@getSNR']);
Comment thread
mtsthibau marked this conversation as resolved.
$router->get('{profile}', ['uses' => 'RadioController@getRadioStatus']);
$router->get('powerlevel/{profile}', ['uses' => 'RadioController@getPowerLevel']);
$router->post('powerlevel', ['uses' => 'RadioController@setPowerLevel']);

});

$router->group(['prefix' => '/geolocation'], function () use ($router): void {
Expand Down