#include <cstdlib>
#include <iostream>
#include <string>
#include <conio.h>
#include "nxt.h"
using namespace std;
//set up the NXT
Connection *connection = new Bluetooth();
Brick *nxt = new Brick(connection);
int main()
{
string program_name = "program.rxe"; //remember to set this
try{
cout << "Try to connect to the NXT" << endl;
connection->connect(40);
cout << "Connected" << endl;
cout << "Start program: " << program_name << endl;
nxt->start_program(program_name,true);
cout << "Program running: " << nxt->get_current_program() << endl;
cout << "Press any key to stop execution" << endl;
while(!_kbhit()){}//hit a key to end
cout << "Terminating running program" << endl;
nxt->stop_programs(true);
connection->disconnect();
}
catch (Nxt_exception& e){
//some error occurred - print it out
cout << e.what() << endl;
cout << "error code: " << e.error_code() << endl;
cout << "error type: " << e.error_type() << endl;
cout << e.who() << endl;
connection->disconnect();
}
return 0;
}