android - New Lollipop BLE API does not detect all advertising packets -


i have seen few posts same question have no been able solution problem.

i see callback function (onscanresult) new ble api detects advertising packets peripheral first time. not see subsequent packets @ all. strange thing happens on few devices. not happen on s4 running lollipop have been seeing issue on 1 plus one. have been able connect peripheral though, using bluetooth gatt methods.

i start , stop scan delay of 2 seconds in between. seem work fine if use old api on lollipop devices scanning seems lot slower.

             if (isscanning)                     {                          if (build.version.sdk_int >= build.version_codes.lollipop)                         {                              if(first_time)                             {                                 first_time = false;                                 scanner = bluetoothadapter.getdefaultadapter().getbluetoothlescanner();                                 settings = new scansettings.builder()                                         .setscanmode(scansettings.scan_mode_low_latency                                         )                                         .build();                                  filters = new arraylist<scanfilter>();                              }                     scanner.startscan(filters, settings, new scancallback());                          }else {                             mbluetoothadapter.startlescan(mlescancallback);                         }                          isscanning = !isscanning;                     }                  try {                 thread.sleep(2000);             } catch (interruptedexception ie) {                 log.e(tag, "monitorthread.interruptedexception-1");             }           if (!isscanning) {                      if (build.version.sdk_int >= build.version_codes.lollipop) {                         scanner.stopscan(new scancallback());                       } else {                          mbluetoothadapter.stoplescan(mlescancallback);                      }                      isscanning = !isscanning;                  } 

do have solution this? have been breaking head on issue not able leads. appreciated.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -