Android: Bluetooth Serial (Com Port) communication with Android Phone -


i trying communicate bluetooth programmable microcontroller. bluetooth device on microcontroller communicates (specifically) on bluetooth serial com port number 4.

question: how can android app read data com port (number 4)?

i know uuid known unique id,that works device, don't think has specifying com port.

static final uuid myuuid = uuid.fromstring("00001101-0000-1000-8000-00805f9b34fb"); btsocket = btdevice.createrfcommsockettoservicerecord( myuuid); btsocket.connect(); valid.append( btdevice.getname() + "\n" + btdevice.getaddress()); north.append("socket connected"); inputstream mminstream = btsocket.getinputstream(); outputstream mmoutstream = btsocket.getoutputstream(); byte[] buffer = new byte[10]; int bytes; stringbuffer str = new stringbuffer(); while (true)                            {                                     try {     mmoutstream.write("a".getbytes());          //reads # of bytes until end of stream reached         bytes = mminstream.read(buffer);         //transform string                 str.append(buffer.tostring()+"\t");                         //clear buffer         log.e("data", "the data: "+ str.tostring());         south.settext(str.tostring());          str.delete(0,str.length());        } catch (ioexception e) {         break; } }} 

the com port exists on microcontroller, not bluetooth device attached it. bluetooth device not know com port microcontroller used connect it. bluetooth device's connection micro via tx , rx lines. fact attached pins on micro assigned specific com port irrelevant , unknown bluetooth device.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -