View unanswered posts | View active topics It is currently Sat Dec 20, 2014 4:21 am






Reply to topic  [ 2 posts ] 
[Bluetooth]cCmdMessage / btSendmessage / SendmessageWithParm 
Author Message
Rookie

Joined: Sun May 04, 2008 2:20 pm
Posts: 2
Post [Bluetooth]cCmdMessage / btSendmessage / SendmessageWithParm
Hi,

There seem to be multiple ways of sending a message (NXT - NXT) via Bluetooth. Some of them are:

cCmdMessageWriteToBluetooth(nQueueID, nXmitBuffer, nSizeOfMessage)
btSendMessage(nResult, nPort, nXmitLength, nXmitBuffer, bWaitForReply)
SendMessageWithParm(dont know paramaters)

There's a similar function related to each of them for recieving messages.
The last one is of an older version of RobotC I believe (?).

Now I'm confused which one I should use for sending messages. I hope someone can tell me what the advantages/disadvantages of these functions are, and which I should definately use/not use.

Thanks.


Sun May 04, 2008 2:49 pm
Profile
Rookie

Joined: Wed Nov 19, 2014 4:47 am
Posts: 2
Post Re: [Bluetooth]cCmdMessage / btSendmessage / SendmessageWith
Hey,

I am currently learning RobotC and I have only looked at bluetooth briefly. I have not heard of the first two methods of sending bluetooth messages that you have listed but I have used the third method (SendMessageWithParm) and I have been able to send and receive with this method. There are definitely advantages and disadvantages with this method. The disadvantage of this method would be that you can only send three variables at once. Here is how you would send three variables:

Sending Variables:

void BluetoothSend () {

int var1;
int var2;
int var3;

SendMessageWithParm(var1, var2, var3)

}

Receiving Variables:

void BluetoothReceive () {

int var1 = messageParm[0];
int var2 = messageParm[1];
int var3 = messageParm[2];

}

Here is how I got around the three variable limit:
(The example below sends four variables)
(The process is split into two parts and two variables are sent and then the other two are sent)

Sending Variables Part One:

void BluetoothSendA () {

int var1;
int var2;

SendMessageWithParm(var1, var2)

}

Receiving Variables Part One:

void BluetoothReceiveA () {

int var1 = messageParm[0];
int var2 = messageParm[1];

}

Sending Variables Part Two:

void BluetoothSend B() {

int var3;
int var4;

SendMessageWithParm(var3, var4)

}

Receiving Variables Part Two:

void BluetoothReceiveB () {

int var3 = messageParm[0];
int var4 = messageParm[1];

}

The advantage of this method would be that the process is easy and straight forward. If you only need to send small amounts of variables then I would suggest this method but if you are needing to send a large amount of variables (e.g. 20 at a time) then this method can still work but the code would be very long and take up a lot more memory than it should.

It may be worth your time to look into the other bluetooth methods to see if they function more efficiently. Unfortunately I am new to bluetooth so someone else may need to assist you in answering the rest of the question but hopefully what I have replied with has helped you out.


Wed Nov 19, 2014 7:48 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.