Shop OBEX P1 Docs P2 Docs Learn Events
eb500 and j2me midlet — Parallax Forums

eb500 and j2me midlet

ALAPISCOALAPISCO Posts: 3
edited 2007-10-17 01:26 in Learn with BlocklyProp
Im trying to send a string to the eb500 via a midlet , fist the program searches for available devices and prints on screen details about them, after that it tries to make a connection to a device with service 0x1101which is the one used for the eb500, it is supossed to show the string on the debuger window on the eb500 but nothing happens. Can any1 help me on this pls? am I missing something?



the code I am trying to use is the following :


for he midlet


try{

DiscoveryAgent myDiscoveryAgent = LocalDevice.getLocalDevice().getDiscoveryAgent();
add = LocalDevice.getLocalDevice().getBluetoothAddress();
myDiscoveryAgent.startInquiry(DiscoveryAgent.GIAC,this);
try {

Thread.sleep(10000);
} catch (InterruptedException ex) {
ex.printStackTrace();
}

myDiscoveryAgent.cancelInquiry(this);
RemoteDevice [noparse]/noparse remoteDevices = myDiscoveryAgent.retrieveDevices(DiscoveryListener.INQUIRY_COMPLETED);
DataOutputStream dos = null;

UUID myService = new UUID(0x1101);
servicios = servicios + myDiscoveryAgent.selectService(myService,ServiceRecord.NOAUTHENTICATE_NOENCRYPT,false);


try{
StreamConnection conn = (StreamConnection) Connector.open(servicios);

if (servicios != null) {
conn = (StreamConnection) Connector.open(servicios);
dos = conn.openDataOutputStream();
dos.writeUTF("Hola Oscar");
// dos.writeChars("Hola");
dos.flush();
dos.close();
}
} catch (Exception ex) {
}




for (int i = 0 ;i<remoteDevices.length;i++)

try {
results = results + remoteDevices.toString() + " " + remoteDevices.getFriendlyName(true);

} catch (IOException ex) {
ex.printStackTrace();
}




} catch (BluetoothStateException ex) {

ex.printStackTrace();
}



and the code for the eb500

' {$STAMP BS2px}

serialin VAR Byte
INPUT 5
PAUSE 1000
SEROUT 1,84, [noparse][[/noparse]"con 00:1A[noparse]:D[/noparse]C:8B[noparse]:D[/noparse]E:78",CR]
SERIN 0,84,[noparse][[/noparse]WAIT("ACK",CR)]
WaitForConnection:
IF IN5 = 0 THEN WaitForConnection

main:
serialIn(0) = 0
SERIN 0,84,1000,main,[noparse][[/noparse]STR serialIn\3\"!"]
PAUSE 100
LOOKDOWN serialIn(0),[noparse][[/noparse]100,101],serialIn
BRANCH serialIn,[noparse][[/noparse]test1, test2]
SEROUT 1,84,[noparse][[/noparse]"none", CR]
PAUSE 5
GOTO main
test1:
SEROUT 1,84,[noparse][[/noparse]"a"]
GOTO main
test2:
SEROUT 1,84,[noparse][[/noparse]"b"]
DEBUG STR serialIn,CR
GOTO main

Comments

  • FranklinFranklin Posts: 4,747
    edited 2007-10-17 01:26
    Please post in one forum only. Go back and delete the posts in the places you have them until you have only one.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
Sign In or Register to comment.