1 Reply Latest reply on Mar 9, 2018 8:47 AM by e.pratt_1639216

    BLE101 example does not work on my Android 7.0 phone

    heimo.gaicher_1629436

      Hello,

       

      I've taken my first steps in programming an Android app with BLE. For my experiments, I use the CY8CKIT-042-BLE Pioneer Kit.

      Now I've tried to import the files in an Android project and flashing the Android BLE app example from GitHub on my phone.

       

      GitHub - cypresssemiconductorco/bleapp

       

      Everything seems fine, no warnings, no mistakes. I can open and connect the app and start bluetooth. But unfortunately, when I click on "Search for device", nothing happens. No device can be found.

       

      When I use another BLE app (eg CySmart, Bluefruit LE), I can communicate with the target, read CapSense values and turn the red LED on / off.

       

      Can someone give me a hint what maybe is going wrong?

       

      (The Android zip-file and a screen shot of the app is attached)

        • 1. Re: BLE101 example does not work on my Android 7.0 phone
          e.pratt_1639216

          I don't know the specifics of the code/java base you are working with, but at a glance:

          /**

               * Scans for BLE devices that support the service we are looking for

               */

              public void scan() {

                  /* Scan for devices and look for the one with the service that we want */

                  UUID   capsenseLedService =       UUID.fromString(capsenseLedServiceUUID);

                  UUID[] capsenseLedServiceArray = {capsenseLedService};

           

           

                  // Use old scan method for versions older than lollipop

                  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {

                      //noinspection deprecation

                      mBluetoothAdapter.startLeScan(capsenseLedServiceArray, mLeScanCallback);

                  } else { // New BLE scanning introduced in LOLLIPOP

                      ScanSettings settings;

                      List<ScanFilter> filters;

                      mLEScanner = mBluetoothAdapter.getBluetoothLeScanner();

                      settings = new ScanSettings.Builder()

                              .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)

                              .build();

                      filters = new ArrayList<>();

                      // We will scan just for the CAR's UUID

                      ParcelUuid PUuid = new ParcelUuid(capsenseLedService);

                      ScanFilter filter = new ScanFilter.Builder().setServiceUuid(PUuid).build();

                      filters.add(filter);

                      mLEScanner.startScan(filters, settings, mScanCallback);

                  }

              }

          This code looks like it is scanning, but filtering scans based on whether it has a specific service available? As far as I know, in order to know if a service is available for a device, you would have to first connect to it. This means that when you are scanning, you are filtering all devices out erroneously? Try removing the filters and see if you can see the unit popup after that.