Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arduino 1.6 Command Line Execution #26

Open
wants to merge 4 commits into
base: arduino-1.6
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,31 +70,30 @@ public function indexAction($auth_key, $version)
}
}

public function arduinoCommandAction()
public function arduinoCommandAction($auth_key, $version)
{
// Get compiler parameters from paramaters.yml
//$params = $this->generateParameters();

// JSON from Builder to send to arduino compiler
$request = $this->getRequest()->getContent();

//{"params":"testparams","request":"testrequest"}
$request = json_decode($request, true);
$params = $this->generateParameters();

if ($request === null) {
return new Response(json_encode(array("success" => false, "json_decode_error" => json_last_error())));
if ($auth_key !== $params["auth_key"])
{
return new Response(json_encode(array("success" => false, "step" => 0, "message" => "Invalid authorization key.")));
}

// Get the arduino command line handler
$compiler = $this->get('arduino_command_handler');
if ($version == "v1")
{
$request = $this->getRequest()->getContent();

// Get resulting binary from arduino
$reply = $compiler->main($request);
//$reply = array();
if (empty($reply)) return new Response(json_encode(array("success" => false, "message" => "Arduino failed to respond")));
//Get the compiler service
$compiler = $this->get('arduino_command_handler');

return new Response(json_encode($reply));
$reply = $compiler->main($request, $params);

return new Response(json_encode($reply));
}
else
{
return new Response(json_encode(array("success" => false, "step" => 0, "message" => "Invalid API version.")));
}
}

public function deleteAllObjectsAction($auth_key, $version)
Expand Down
Loading