0

I'm trying to receive data in mobile(android) devices from a BLE device based on nRF52840 and custom firmware.

Here is my setting

  • sampling rate : 250Hz
  • mobile devices : Galaxy flip z 3, Galaxy S22
  • Used library : RxBleAndroid

To check whether the BLE device sends data correctly or not, I tested it using nRF Connect for Desktop. There were about 250 samples per second. (nRF52840 dongle was equipped with the Desktop)

However, in mobile devices, there were about 20~30 samples per second. I already checked these mobile devices could receive 250 samples per second using a commercial device. So I think it is not a problem of mobile devices, but code.

Here is my code

fun connectDevice(){
    rxBleDevice = rxBleClient.getBleDevice(lxDeviceAddress)
    connectSubscription = rxBleDevice.establishConnection(false)
        .subscribe(
            { rxBleConnection ->
                this.rxBleConnection = rxBleConnection
                Log.v(TAG, "success to connect")

            }
        ) { throwable ->
            throwable.printStackTrace()
        }
}

fun bleNotification() = rxBleConnection
    .setupNotification(lxDeviceUUID)
    ?.doOnNext { notificationObservable->
    }

fun readDataFromDevice(){

    scanSubscription.dispose()

    bleNotification()
        ?.observeOn(io.reactivex.rxjava3.android.schedulers.AndroidSchedulers.mainThread())
        ?.flatMap { notificationObservable -> notificationObservable }
        ?.subscribe({ bytes ->
            Log.v(TAG, byteArrayToHex(bytes))
        }, { throwable ->
            throwable.printStackTrace()
        })

}

I called connectDevice() to connect the BLE device, and called readDataFromDevice() to read data.

Could you give me some solutions?

LYG
  • 41
  • 1
  • 7

2 Answers2

0

It all depends on the Bluetooth chip in the device (how good its radio scheduler is) and the circumstances such as connection interval, number of concurrent connections, if BLE antenna is shared with WiFi antenna and so on. So, not that much depends on your code. You just seem to set up a regular notification listener.

Emil
  • 16,784
  • 2
  • 41
  • 52
0

the BLE connection performance mainly depends on three connection parameters: connection interval, latency, and timeout. These are negotiated between peripheral and central after connecting. The peripheral can request for parameters by giving their range, but it is the central that decides the final parameters in our case the mobile and PC applications. So, there will be a change in the values of these parameters between mobile and pc apps, also between different OS's. Hence the change in throughput. As @Emil covered it depends on hardware as well.

Shiva
  • 3
  • 2