private fun advertise(tek:String){bluetoothManager.adapter.bluetoothLeAdvertiser
val advertiser: BluetoothLeAdvertiser=BluetoothAdapter.getDefaultAdapter().bluetoothLeAdvertiser
val settings = AdvertiseSettings.Builder().setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED).setConnectable(true).setTimeout(0).setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM).build()
val uuid = UUID.randomUUID()
val pUuid = ParcelUuid(UUID.fromString(uuid.toString()))
val data: AdvertiseData = AdvertiseData
.Builder()
.addServiceData(pUuid,tek.toByteArray()).build()
val advertiseCallback = object: AdvertiseCallback(){
override fun onStartSuccess(settingsInEffect: AdvertiseSettings){
Log.d(TAG,"BLE Advertising start")
super.onStartSuccess(settingsInEffect)
}
override fun onStartFailure(errorCode: Int){
Log.d(TAG,"BLE Advertising onStartFailure: $errorCode")
super.onStartFailure(errorCode)
}
}
advertiser.startAdvertising(settings, data, advertiseCallback)
finish()
}
This is code that I wrote to advertise through BLE. The data which is tek here is a string that is longer than 31 bytes (eg.QUNf4ScRXQ9mJDVI7k5T1THGr7l7Fvpquk4ASMySRn8=). Is there any way that I can advertise this through BLE? When I try to advertise this on the code above, it gives onStartFailure code :1, which means the data is too long.