Send message from pc to NXT via Bluetooth

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

Send message from pc to NXT via Bluetooth

Postby phai » Fri May 11, 2007 11:09 pm

Hi

Im trying to send a message to NXT using sendPacket(byte b) (lejos api)...from pc...I did made a java program in pc that could communicate with nxt via bluetooth using RXTX..and I tried to send message to NXT, but NXT always read nothing..i just wondering why...My java program could connect NXT port via bluetooth but NXT coudlnt read any message...

COuld anyone here help me plz...

this is my message

byte[] array = {(byte) (4 & 0xFF),(byte)((4 & 0xFF00) >> 8),(byte)0x97};

public SerialWriter ( OutputStream out )
{
this.out = out;
}

public void run ()
{
try
{
//int c = 0;
//while ( c < s.length() )
//{
this.out.write(array);
this.out.flush();
this.out.close();
// c++;
//}
}
catch ( IOException e )
{
e.printStackTrace();
}
}
phai
New User
 
Posts: 3
Joined: Fri May 11, 2007 1:38 pm

Postby lawrie » Sat May 12, 2007 2:21 pm

You need to run a program similar to the BTRespond example on the NXT to wait for a connection.

You also, currently, need to put a two-byte header on any message you send, which gives the length of the message with the least significant byte first.

A future will release with support Bluetooth streams without the need to do this type of thing.
lawrie
leJOS Team Member
 
Posts: 918
Joined: Mon Feb 05, 2007 1:27 pm

Postby phai » Sat May 12, 2007 3:55 pm

Thanx a lot...:)..

It is working now.....
Anyway could NXT be a master using lejos???and pc be a slave...
phai
New User
 
Posts: 3
Joined: Fri May 11, 2007 1:38 pm


Return to NXJ Software

Who is online

Users browsing this forum: Yahoo [Bot] and 5 guests

cron
more stuff