This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to get the BLE chip's advertisement raw data on Android APP

Dear all

Good day!

I want to develop the Android APP to received the BLE's ad raw data(which is dynamic change). Which API should I called to get the raw data? And should I refresh the scan API to get the dynamic data ? Or do you have the demo code for Android APP?

Thanks & Regards Jenson

Parents
  • Hi.

    You can find source code for our Smartphone demo apps here.

    If you check out the nRF UART app, see line 159 of DeviceListActivity.java:

    private BluetoothAdapter.LeScanCallback mLeScanCallback =
                new BluetoothAdapter.LeScanCallback() {
    
            @Override
            public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                    	
                    	  runOnUiThread(new Runnable() {
                              @Override
                              public void run() {
                                  addDevice(device,rssi);
                              }
                          });
                       
                    }
                });
            }
        };
    

    The scanrecord byte array contains the advertisement data.

    You should check out android's documentation and Scanrecord and bluetooth LE.

Reply
  • Hi.

    You can find source code for our Smartphone demo apps here.

    If you check out the nRF UART app, see line 159 of DeviceListActivity.java:

    private BluetoothAdapter.LeScanCallback mLeScanCallback =
                new BluetoothAdapter.LeScanCallback() {
    
            @Override
            public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                    	
                    	  runOnUiThread(new Runnable() {
                              @Override
                              public void run() {
                                  addDevice(device,rssi);
                              }
                          });
                       
                    }
                });
            }
        };
    

    The scanrecord byte array contains the advertisement data.

    You should check out android's documentation and Scanrecord and bluetooth LE.

Children
Related