Buffering Bluetooth data streams
Are you experiencing very slow transfer times between Bluetooth-connected printers and your J2ME application?
This may have to do with how you're buffering the data as it's going out.
Look at this code, which reads the content from a buffer named Datos and writes it to an OutputStream os:
os.write(Datos.charAt(i));
i++;
}
This seems like it should work -- you're basically reading one character at a time and writing it out to os. The problem with this is that each os.write() operation is using one full OutputStream buffer. When you're working on a constrained device, this can be a problem, since you could easily encounter full buffers before you're done sending data. Once you use up all buffers (including system buffers) the device will wait before trying again. In Motorola iDEN phones, this is currently set at 10000 ms -- which means that in this operation, each call to while() would introduce a 10 second delay!
Simply replacing the code above with
will do the trick.
