Estimote / Android-Fleet-Management-SDK

Estimote Fleet Management SDK for Android
https://developer.estimote.com
MIT License
836 stars 451 forks source link

Samsung phone not scanning (Unable to start BLE scanning. Error code: 4) #270

Closed rajeshkanna777 closed 6 years ago

rajeshkanna777 commented 6 years ago

Yesterday i bought new phone samsung j7 and i installed estimot app form play store the scanning not happen Android version:7.0 sdk version 1.4.0 phone model:samsung j7

Last time i posted same issues Moto e4 not scanning but still yet i did not get proper solution, i check BLE scanner app i saw the list of EST Beacon but esimote app not showing the beacon

I got this error when i used estimot sdk LollipopBluetoothAdapter$1.onScanFailed:244 Unable to start BLE scanning. Error code: 4

Poberro commented 6 years ago

We received btsnoop logs on forum for Samsung J7 and we were able to find what might be cause an issue. Problems with Moto E4 might be caused by the same thing. Can you send us BT Snoop logs so we can confirm that? Samsung J7 does not support power conservation features like hardware filters and batch scanning and SDK is trying to turn them on by default which causes an error. In Proximity SDK can you try to use withLowLatencyPowerMode() in your code and see if it is scanning?

   proximityObserver = ProximityObserverBuilder(applicationContext, EstimoteCloudCredentials(YOUR_APP_ID, YOUR_APP_TOKEN))
                .withLowLatencyPowerMode()
                .build()
Poberro commented 6 years ago

Here is Java version:

    ProximityObserverBuilder proximityObserver = new ProximityObserverBuilder(applicationContext, new EstimoteCloudCredentials(YOUR_APP_ID, YOUR_APP_TOKEN))
        .withLowLatencyPowerMode()
        .build();
rajeshkanna777 commented 6 years ago

12-18 18:08:18.237 7544-7580/com.estimote.notification I/OpenGLRenderer: Initialized EGL, version 1.4 12-18 18:08:18.237 7544-7580/com.estimote.notification D/OpenGLRenderer: Swap behavior 1 12-18 18:08:18.242 7544-7580/com.estimote.notification D/mali_winsys: EGLint new_window_surface(egl_winsys_display, void, EGLSurface, EGLConfig, egl_winsys_surface*, egl_color_buffer_format, EGLBoolean) returns 0x3000, [1080x1920]-format:1 12-18 18:08:20.481 7544-7544/com.estimote.notification D/ViewRootImpl@f340af9[MainActivity]: MSG_RESIZED_REPORT: frame=Rect(0, 0 - 1080, 1920) ci=Rect(0, 72 - 0, 0) vi=Rect(0, 72 - 0, 0) or=1 12-18 18:08:20.482 7544-7544/com.estimote.notification I/Choreographer: Skipped 133 frames! The application may be doing too much work on its main thread. 12-18 18:08:22.086 7544-7581/com.estimote.notification D/BluetoothAdapter: STATE_ON 12-18 18:08:22.088 7544-7581/com.estimote.notification D/BluetoothAdapter: STATE_ON 12-18 18:08:22.093 7544-7581/com.estimote.notification D/BluetoothLeScanner: Start Scan 12-18 18:08:22.096 7544-7581/com.estimote.notification D/BluetoothAdapter: STATE_ON 12-18 18:08:22.098 7544-7581/com.estimote.notification D/BluetoothAdapter: STATE_ON 12-18 18:08:22.104 7544-7581/com.estimote.notification D/BluetoothAdapter: STATE_ON 12-18 18:08:22.106 7544-7581/com.estimote.notification D/BluetoothAdapter: STATE_ON 12-18 18:08:22.111 7544-7544/com.estimote.notification E/EstimoteSDK: LollipopBluetoothAdapter$1.onScanFailed:244 Unable to start BLE scanning. Error code: 4 12-18 18:08:28.030 7544-7549/com.estimote.notification I/art: Do partial code cache collection, code=27KB, data=28KB 12-18 18:08:28.030 7544-7549/com.estimote.notification I/art: After code cache collection, code=26KB, data=28KB 12-18 18:08:28.030 7544-7549/com.estimote.notification I/art: Increasing code cache capacity to 128KB got same issues

Poberro commented 6 years ago

Those look like logs from Estimote SDK 1.4.0, not from Proximity SDK. Did you try Proximity SDK with the code I provided above? Try this code (undocumented scanner API from Proximity SDK):

    BluetoothScanner scanner = new EstimoteBluetoothScannerFactory(context).getSimpleScanner();
    scanner.estimoteConnectivityScan()
        .withLowLatencyPowerMode()
        .withOnPacketFoundAction(new Function1<EstimoteConnectivity, Unit>() {

          @Override
          public Unit invoke(EstimoteConnectivity estimoteConnectivity) {
            Log.i("ProximitySDK", "Found device " + estimoteConnectivity.getDeviceId());
            return null;
          }
        }).start();

And see if it is detecting devices using connectivity packet.

rajeshkanna777 commented 6 years ago

Hi Poberro Am currently doing beacon ranging so i used estimot sdk 1.4.0 this is my code public class MainActivity extends AppCompatActivity implements BeaconManager.BeaconRangingListener {

private static final String TAG = "MainActivity";
private BeaconManager beaconManager;

private static final BeaconRegion ALL_ESTIMOTE_BEACONS_REGION = new BeaconRegion("ranged region", null, null, null);

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    beaconManager = new BeaconManager(getApplicationContext());
    beaconManager.setBackgroundScanPeriod(TimeUnit.SECONDS.toMillis(6), 0);
    beaconManager.setRangingListener(this);
    beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
        @Override
        public void onServiceReady() {
            beaconManager.startRanging(ALL_ESTIMOTE_BEACONS_REGION);
        }
    });

}

@Override
protected void onResume() {
    super.onResume();

    MyApplication app = (MyApplication) getApplication();

    if (!SystemRequirementsChecker.checkWithDefaultDialogs(this)) {
        Log.e(TAG, "Can't scan for beacons, some pre-conditions were not met");
        Log.e(TAG, "Read more about what's required at: http://estimote.github.io/Android-SDK/JavaDocs/com/estimote/sdk/SystemRequirementsChecker.html");
        Log.e(TAG, "If this is fixable, you should see a popup on the app's screen right now, asking to enable what's necessary");
    } else if (!app.isBeaconNotificationsEnabled()) {
        Log.d(TAG, "Enabling beacon notifications");
        // app.enableBeaconNotifications();
    }
}

@Override
public void onBeaconsDiscovered(BeaconRegion beaconRegion, List<Beacon> beacons) {
    Log.d(TAG, String.valufOf(beacon.size()));
}

} this code is not working can you give me some alternate solution. And i need java code, i checked this link https://github.com/Estimote/Android-Proximity-SDK/tree/master/example/ProximityApp this is kotlin code, can you send me java link.

Poberro commented 6 years ago

There is a new maintenance release of Estimote SDK 1.4.1. Please check if it works for you.

rajeshkanna777 commented 6 years ago

Thanks! ya its working now but i need some time to test and i ll let you know if i get any issues.

Poberro commented 6 years ago

Please note that this is only a maintenance release and this SDK will be deprecated. You should consider switching to Proximity SDK.