// demo3.cpp : simple c++ demo for robotdll.dll
//

#include <stdio.h>
#include "../robotdll.h"

int main(int argc, char *argv[])
{
    char *port = "147.175.125.30";
    int netport = 7123;
    if (argc > 1) port = argv[1];
    if (argc > 2) netport = atoi(argv[2]);
    if (argc < 2)
    {
        printf("usage: demo3 serial-port|ip-address [network port]\n");
        return 0;
    }

    //create new robot control object
    int r = robot_init(1);
    Sleep(500);  

    //setup user name
    robot_user(r, "john", "turtle");
    Sleep(500);

    //connect to the robot
    printf("connecting to %s...\n", port);
    robot_portnumber(r, netport);
    short x = robot_connect(r, port);
    printf("connect(): %d\n", x);
    Sleep(500);
    if (x > 0) printf("Connected\n");
    else
    {
        printf("Could not connect\n");
        return 1;
    }

    //turn left 60 degrees
    robot_lt(r, 60 * 8);

    //shutdown
    printf("Closing...\n");
    robot_done(r);
    return 0;
}
