B
Boki
Hi All,
I try a bluelet demo, I change some code here, I want to move
these codes of run()
========================================================
out.writeUTF( "Boki Back Msg" );
out.flush();
========================================================
to a soft key event, but it never work ( exception error is 0 / null )
public void commandAction(Command c, Displayable s) {
========================================================
out.writeUTF( "Boki Back Msg" );
out.flush();
========================================================
}
My original thread:
=============================================
public void run()
{
StreamConnection c = null;
try
{
localDevice = LocalDevice.getLocalDevice(); // obtain reference to
singleton
localDevice.setDiscoverable(DiscoveryAgent.GIAC); // set Discover mode
to LIAC
String uuidString = "102030405060708090A0B0C0D0E0F010";
UUID uuid = new UUID(uuidString, false);
String url = "btspp://localhost:" + uuid.toString()
+";name=Boki_SPP";
server = (StreamConnectionNotifier)Connector.open( url );
localDevice.setDiscoverable(DiscoveryAgent.GIAC);
ServiceRecord rec = localDevice.getRecord( server );
rec.setAttributeValue( 0x0008, new DataElement(
DataElement.U_INT_1, 0xFF ) );
} catch (Exception e)
{
System.out.println("try1 fail"+e.getMessage());
System.out.println(e);
}
while( !done)
{
try {
System.out.println("try2");
c = server.acceptAndOpen();
RemoteDevice rdev = RemoteDevice.getRemoteDevice( c );
DataInputStream in = c.openDataInputStream();
String s = in.readUTF();
DataOutputStream out = c.openDataOutputStream();
========================================================
out.writeUTF( "Boki Back Msg" );
out.flush();
========================================================
// close current connection, wait for the next one
// c.close();
} catch (Exception e)
{
System.out.println("try2 fail");
}
} // while
}
I try a bluelet demo, I change some code here, I want to move
these codes of run()
========================================================
out.writeUTF( "Boki Back Msg" );
out.flush();
========================================================
to a soft key event, but it never work ( exception error is 0 / null )
public void commandAction(Command c, Displayable s) {
========================================================
out.writeUTF( "Boki Back Msg" );
out.flush();
========================================================
}
My original thread:
=============================================
public void run()
{
StreamConnection c = null;
try
{
localDevice = LocalDevice.getLocalDevice(); // obtain reference to
singleton
localDevice.setDiscoverable(DiscoveryAgent.GIAC); // set Discover mode
to LIAC
String uuidString = "102030405060708090A0B0C0D0E0F010";
UUID uuid = new UUID(uuidString, false);
String url = "btspp://localhost:" + uuid.toString()
+";name=Boki_SPP";
server = (StreamConnectionNotifier)Connector.open( url );
localDevice.setDiscoverable(DiscoveryAgent.GIAC);
ServiceRecord rec = localDevice.getRecord( server );
rec.setAttributeValue( 0x0008, new DataElement(
DataElement.U_INT_1, 0xFF ) );
} catch (Exception e)
{
System.out.println("try1 fail"+e.getMessage());
System.out.println(e);
}
while( !done)
{
try {
System.out.println("try2");
c = server.acceptAndOpen();
RemoteDevice rdev = RemoteDevice.getRemoteDevice( c );
DataInputStream in = c.openDataInputStream();
String s = in.readUTF();
DataOutputStream out = c.openDataOutputStream();
========================================================
out.writeUTF( "Boki Back Msg" );
out.flush();
========================================================
// close current connection, wait for the next one
// c.close();
} catch (Exception e)
{
System.out.println("try2 fail");
}
} // while
}