Menu

#38 bluetooth communication

open
nobody
None
5
2013-01-02
2011-09-26
feicht
No

Hello!
I am trying to set up some bluetooth communication between NXT/Mindstorm and the PC via the application "Bricx Command Center".
For test purposes I would like to use the function "Tools/Send Messages".

In the NXT I've implemented the following slave program attached.
Through "Send Message" I am trying to send messages.
It does not work...

Can you support?
Matthias.Feicht@bt.com

------

// Slave Programm

#include "NXCDefs.h"

#define BT_CONN 0 // Verbindungsnummer
#define OUTBOX 2 // Nummer Outbox
#define INBOX 1 // Nummer Inbox

sub BTCheck (int conn)
{
if (!BluetoothStatus(conn)==NO_ERR)
{
TextOut(5,LCD_LINE2,"Fehler");
Wait(1000);
StopAllTasks(); //Programm beenden
}
else
{
TextOut(5,LCD_LINE2,"OK!");
Wait(1000);
ClearScreen();
}
}

task main()
{
int eingang;
int ausgang;

BTCheck(BT_CONN); //Prüfen, ob Verbindung besteht

while(true)
{
ReceiveRemoteNumber(INBOX,true,eingang); //Zahl empfangen

TextOut(0, LCD_LINE1, "Erhaltene Zahl:");
NumOut(0,LCD_LINE2, eingang);

ausgang=eingang*eingang;

TextOut(0, LCD_LINE3, "Quadrat");
NumOut(0,LCD_LINE4, ausgang);

SendRemoteNumber(BT_CONN,OUTBOX, ausgang);

Wait(1000);
ClearScreen();
}
}

Discussion

MongoDB Logo MongoDB