PC Send Bluetooth

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #3970
    Author Image
    seb heliboles
    Participant

    Hello,

    I want to send a message with the pc to the NXT with your function void Bluetooth::send(unsigned char *buffer, unsigned int num_bytes) and I would like more details to use this for sending a message.
    Sorry for my english, I’m french.

    #3973
    Author Image
    Anders Søborg
    Keymaster

    Hi this is for the C++ library…

    Ok could you please post some code of what you are trying to do

    Anders

    #3977
    Author Image
    seb heliboles
    Participant

    I use this code

     #include <cstdlib>
        #include <iostream>
        #include <string>
        #include <conio.h>
        #include "nxt.h"
    
        using namespace std;
    
        Bluetooth *blue = new Bluetooth();
        int port ,erreur=0;
        int main()
        {
    
            try{
                cout << "Tentative de connexion" << endl;
                cout << "Selectionner le port" <<endl;
                while(erreur==0){
                    try{
    
                        scanf("%d",&port);
                        blue->connect(port);
                        cout << "Connexion reussi" << endl;
                        erreur=1;
                    }
                    catch (Nxt_exception& e){
                        printf("- Port %d Erreur \n",port);
                    }
                }
    
            }
            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;
                return 0;
            }
            unsigned int b=2;
            unsigned char un[]={'0','a'};
            blue->send(&un[0],b);
    
    }
    
    #3978
    Author Image
    Anders Søborg
    Keymaster

    Everything looks ok – but the command that you are sending does not make sense to the NXT firmware. Also be sure to close the connection when you are done. If you go to the documentation you can see the source code for some of the things that I implemented. You can find the documentation here

    Anders

    #3983
    Author Image
    seb heliboles
    Participant

    I do not understand what I have to write in the table to be understood by the nxt.
    I have to use a procedure?

    • This reply was modified 10 years, 9 months ago by Author Imageseb heliboles.
    #3994
    Author Image
    Anders Søborg
    Keymaster

    Hi

    Have a look at motor file to see how to run a motor

    Anders

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

Posted in

Make a donation