Hi,
I have been hammering at this problem for a few weeks now and can seem to get anywhere! I usually am able to find a program for one side of the communication channel so I have something that is standardised and so I can test against it, but i cant find anything!
The scenario is this, I wish to create two sections of a system, one using Java (JME2) which just sends data (strings) to a PC server which replies to these strings with, lets say, ACKs. The following is what i've come up with so far with no cookie! PC Bluetooth adapter MAC address: 000C76D416AD
The PC client:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not _BluetoothRadio Is Nothing Then
Dim myByte() As Byte
Dim _BluetoothListener As New BluetoothListener(BluetoothService.SerialPort)
_BluetoothListener.LocalEndPoint.Address = _BluetoothRadio.LocalAddress
_BluetoothListener.LocalEndPoint.Port = 1
_BluetoothListener.Authenticate = False
_BluetoothListener.Start()
_BluetoothClient = _BluetoothListener.AcceptBluetoothClient
Dim _NetworkStream As NetworkStream = _BluetoothClient.GetStream()
_NetworkStream.Read(myByte, 0, 255)
Dim returndata As String = Encoding.ASCII.GetString(myByte)
MsgBox(returndata)
Else
MessageBox.Show("No devices found...")
For Each Control As Control In Me.Controls
Control.Enabled = False
Next
End If
End Sub
The JME2 section
status.setText("Sending...");
String ServiceURL = "btspp://000C76D416AD:1";
int failPoint = 0;
try {
// create a server connection
StreamConnectionNotifier notifier = (StreamConnectionNotifier) Connector.open(ServiceURL);
failPoint = 1;
// accept client connections
StreamConnection connection = notifier.acceptAndOpen();
failPoint = 2;
// prepare to send/receive data
byte buffer[ = new byte[100];
String msg = "hello there";
InputStream is = connection.openInputStream();
failPoint = 3;
OutputStream os = connection.openOutputStream();
failPoint = 4;
// send data to the client
os.write(msg.getBytes());
failPoint = 5;
// read data from client
is.read(buffer);
connection.close();
failPoint = 6;
status.setText("Done!!");
} catch(IOException e) {
status.setText("failPoint: " + failPoint + " - " + e.toString());
}