java - Not Reading Data from Bluetooth Health Device (for Android 2.2 and above) -


i trying capture (data)reading on android phone 'bluetooth health devices' such oximeter, thermometer, weighing scale machine etc. able connect device phone when goes read data stuck on there only. doing following steps..(android 2.2) first creating socket connection

  1. bluetoothsocket socket.connect();// socket connection-----done successfully

  2. bluetoothsocket tmp= device.createrfcommsockettoservicerecord(my_uuid); //here my_uuid="00001101-0000-1000-8000-00805f9b34fb";

  3. in read thread

    byte[] buffer = new byte[37];// think here not getting exact bytes

    int bufferbytes = 0, bufferindex = 0;

        log.e(tag, "message_read....");     communications comms = null;     bundle bundle = new bundle();     try {          comms = new communications();          log.e(tag, "after communications....");      } catch (exception e) {         log.e(tag, "error in communicaton....");     }       // keep listening inputstream while connected     while (true) {          log.e(tag, "its coming in while");         try {              try {                 bufferbytes = mminstream.read(buffer);// code stuck here not going down till health device off(its directly jump exception after device off)             } catch (indexoutofboundsexception e) {                 log.e(tag, "bufferbytes error ====== +e.getmessage());             }                //log.e(tag, "bufferbytes====== "+bufferbytes);             while (bufferbytes > bufferindex) {                  string[] message = comms.receivemessage(buffer,                         bufferindex, bufferbytes);                 bufferindex = integer.parseint(message[1]);                 log.e(tag, "bufferindex====== "+bufferindex);                 if (message[0] != null) {                      /*                      * processing message sent device                      */                     stringtokenizer dataintokens = new stringtokenizer(                             message[0]);                      if (dataintokens.hasmoretokens() == true) {                          string token = dataintokens.nexttoken();                         log.e(tag, "token====== "+token);                         if (token.equals("a")) {                              int weight = 0;                             if (dataintokens.hasmoretokens() == true) {                                  weight = integer.parseint(dataintokens                                         .nexttoken());                                  // send message activity                                 msg = mhandler                                         .obtainmessage(scaleactivity.message_read);                                 bundle.putint(scaleactivity.weight,                                         weight);                                 msg.setdata(bundle);                                 mhandler.sendmessage(msg);                             }                         } else if (token.equals("b")) {                              int weight = 0;                             if (dataintokens.hasmoretokens() == true) {                                  weight = integer.parseint(dataintokens                                         .nexttoken());                                  // send message activity                                 msg = mhandler                                         .obtainmessage(scaleactivity.message_read);                                 bundle.putint(                                         scaleactivity.weight_to_save,                                         weight);                                 msg.setdata(bundle);                                 mhandler.sendmessage(msg);                             }                         }                     }                 }             } 

and tried android 4.0 hdp example also.which available here our heath devices not comaptible hdp. not working me.

i in same situation. able stablish connection , create socket using ssp profile (uuid 00001101-0000-1000-8000-00805f9b34fb). have verified bluetooth health device exposing ssp service executing reflection code (the method retrieve device exposed uuids hidden in api level):

class<?> cl = class.forname("android.bluetooth.bluetoothdevice"); method method = cl.getmethod("getuuids"); object retval = method.invoke(mybtdevice); 

(retval contains array of valid uuid device services can connect to.)

i think problem that, before trying read anything, set of command/s have sent device, otherwise read method hang forever. have been googling days trying figure out hidden protocol without success. have search manufacturer name , model nothing (digifox fingertip pulse oximeter).

my hope that, whith device custom software running in windows provided communicates device , able read measures. may need use kind of bluetooth analyzer or packet sniffer check data sent device before reading anything. if able working post here.

regards.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -