Archived from groups: alt.cellular.bluetooth (More info?)
Avrei bisogno del vostro aiuto.
Sto realizzando un'applicazione per lo scambio di messaggi tra due
dispositivi. Il primo dispositivo è un PC e il secondo un telefonino. I due
dispositivi utilizzano Bluetooth per comunicare. Ho decisamente le idee
confuse. C'è qualcuno che conosce il problema? Può dirmi qualcosa in più?
Per quanto riguarda la parte client ho utilizzato j2me, il wireless toolkit
e le API JSR82. Il problema riguarda il server perchè da quello che ho
capito non è possibile utilizzare le API JSR 82 su J2se. Ho utilizzato
allora lo stack che ho trovato su javabluetooth.org. Mi sono anche procurato
anche un dongle USB e ho installato il bridge USB - SerialDriver PL2303 sul
pc.
Questo è il codice per il server. L'esecuzione si blocca sull'istruzione
che ho segnato con gli asterischi e non viene più eseguita nessuna
istruzione.
Il problema riguarda, secondo me le prime istruzioni del main(). Queste
sono necessarie altrimenti viene sollevata un'eccezione e il BluetoothStack
non viene inizializzato. Il fatto è che non si riesce a scrivere niente
sullo stream della porta e l'esecuzione rimane bloccata. L'implementazione
di questo stack utilizza le porte seriali e non l'USB per questo sono
necessarie le prime istruzioni. C'è qualcuno che sà come bisogna fare? Non
so come fare.Grazie!!
N.B. Se volete rispondetemi direttamente.
// This server actually runs forever. However, it can be stopped
// by terminating the KVM from the command line
// The server can terminate client connections by
// setting the client connections public variable "end" to "true"
// like: L2CAPEchoServer.Client.end = true;
while( true )
{
L2CAPConnection conn = null;
// start the communication with the client
public void run()
{
byte[] data = null;
int length;
System.out.println( "Client is connected" );
while( !end )
{
try
{
// prepare a receive buffer
length = clientconn.getReceiveMTU();
data = new byte[length];
// read in the data sent by the client (method blocks!)
length = clientconn.receive(data);
System.out.println( "Received " + length + " bytes from
client" );
// and immediately send it back on the same connection
(echo)
clientconn.send(data);
}
catch( IOException e )
{
System.out.println("IOException: " + e.getMessage());
}
}
clientconn.close();
}
}
You are about to answer a thread that has been inactive for more than 6 months. If you still wish to proceed, please ensure that your posting is original and does not duplicate or overlap any prior responses to this thread.