View unanswered posts | View active topics It is currently Tue Jul 17, 2018 11:09 am






Reply to topic  [ 1 post ] 
Bluetooth communication, between master and two slaves (NXT) 
Author Message
Rookie

Joined: Tue Feb 03, 2015 5:15 pm
Posts: 1
Post Bluetooth communication, between master and two slaves (NXT)
Hello all
I have a problem with bluetooth communication, between master and two slaves (NXT bricks).
All messages from master are received only by first slave connected to stream no 1, second slave (stream no 2) receives nothing.
It seems that the parameter 'nStream' of cCmdMessageWriteToBluetooth function is ignored. Below I attach the source code.
Thanks in advance for your comments.

RobotC ver. 3.62 for Lego Mindstorms
//---------------------------------------------------------------------------
// MASTER
//---------------------------------------------------------------------------
task main()
{
char msg[20];
int val;
TFileIOResult res;

eraseDisplay();
bNxtLCDStatusDisplay = true;
val = 1;
while(1)
{
sprintf(msg, "A%d", val);
while(bBTBusy)
wait1Msec(1);
res = cCmdMessageWriteToBluetooth(1, (ubyte*)msg, strlen(msg), mailbox1);
nxtDisplayCenteredTextLine(3, "msg=%s,res=0x%02X", &msg, res);
wait1msec(5000);
//
sprintf(msg, "B%d", val);
while(bBTBusy)
wait1Msec(1);
res = cCmdMessageWriteToBluetooth(2, (ubyte*)msg, strlen(msg), mailbox1);
nxtDisplayCenteredTextLine(5, "msg=%s,res=0x%02X", &msg, res);
//
wait1msec(5000);
val++;
}
}
//---------------------------------------------------------------------------
// SLAVES
//---------------------------------------------------------------------------
task main()
{
char msg[20];
int size;

eraseDisplay();
bNxtLCDStatusDisplay = true;
while(1)
{
while(bBTBusy)
wait1Msec(1);
size = cCmdMessageGetSize(mailbox1);
if(size > 0)
{
while(bBTBusy)
wait1Msec(1);
cCmdMessageRead(msg, size, mailbox1);
msg[size] = '\0';
nxtDisplayCenteredBigTextLine(4, "%s", &msg);
}
wait1Msec(1);
}
}


Wed Feb 04, 2015 9:19 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

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.