rendered paste body synchronized (ConnectorOpenMonitor) {
String url = "btspp://00027207698F:1;authenticate=false;encrypt=false;master=false"; //+ myService.toString()
try {
form.setTitle("0");
if(connection!=null) {
connection.close();
connection = null;
}
connection = (StreamConnection) Connector.open(url, Connector.READ_WRITE, true);
form.setTitle("01");
is = connection.openDataInputStream();
os = connection.openDataOutputStream();
form.setTitle("02");
form.setTitle("03");
os.writeUTF("img");
form.setTitle("03a"+Integer.toString(imageData.length));
os.writeInt(imageData.length);
form.setTitle("03b"+Integer.toString(imageData.length));
// os.write(imageData,0,imageData.length);
int i =0;
int mmtu = 4096;
int len = 0;
debug.setText("Szarhossz: "+imageData.length);
while(i*mmtu<=imageData.length) {
len = (i+1)*mmtu<=imageData.length?mmtu:imageData.length-i*mmtu;
//if(i>220)
//debug.setText(debug.getText()+"\n"+i+" write(xx,"+(i*mmtu)+","+len);
os.write(imageData,i*mmtu,len);
i++;
}
os.flush();
// read data from the server
form.setTitle("03d");
form.setTitle("04");
if (is != null) {
is.close();
}
if (os != null) {
os.close();
}
connection.close();
System.gc();
form.setTitle("05");
} catch (Exception e) {
form.setTicker(new Ticker(e.toString()));
e.printStackTrace();
}
}