2 Replies Latest reply on Jul 6, 2018 3:01 AM by psyu

    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.

          • 2. Re: BLE101 example does not work on my Android 7.0 phone
            psyu

            Hello,

             

            There was an issue in PSoCCapSenceLedService.java file please change the service and characteristics UUID values in BLE component in PSoC Creator and also change the modified UUID values in Java file. Also modify statement ----> if(uuid.equals(capsenseCharacteristicUUID)) to --->if(uuid.equalsIgnoreCase(capsenseCharacteristicUUID)) as shown in below statements in Java file.

             

            / In this case, the only notification the apps gets is the CapSense value.
              // If the application had additional notifications we could
              // use a switch statement here to operate on each one separately.

            if(uuid.equalsIgnoreCase(capsenseCharacteristicUUID)) {
            mCapSenseValue = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_SINT16,0).toString();
            }

              // Notify the main activity that new data is available
              broadcastUpdate(ACTION_DATA_RECEIVED);

              }

             

             

             

             

             

             

            Thanks,

            PSYU.