#include <cstdlib>
#include <iostream>
#include <string>
#include <conio.h>
#include "nxt.h"
using namespace std;

//set up the NXT - just an example - most of them is not used
Connection *connection = new Bluetooth();
Filesystem *fs = new Filesystem(connection);

int main()
{
  Nxt_file file;
  unsigned int i;
  try{
    cout << "Try to connect to the NXT" << endl;
    connection->connect(40);
    cout << "Connected" << endl;
    cout << "Number of files on NXT" << fs->create_file_list("*.*") << endl; //show all files
    i=0;
    while(i< fs->get_file_list_size()){
      file = fs->get_file_list_element(i);
      cout << "Filename: " << file.name << "  Filesize: " << file.size << endl;
      i++;
    }
    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();
  }
  system("pause");
  return 0;
}