How can I advertise via BLE 100 bytes?
SDK >= 26
I am able to advertise 20 bytes, but when I advertise more than 20 bytes, I get an Exception.
I have already read these articles:
Android: Sending data >20 bytes by BLE
How to send more than 20 bytes data over ble in android?
As I right understand, the mentioned links are no solution for advertising but for P2P connections, am I right?
My code:
private fun startAdvertising() {
goForeground()
Log.d(tag, "Service: Starting Advertising")
if (mAdvertiseCallback == null) {
val settings = buildAdvertiseSettings()
mAdvertiseCallback = SampleAdvertiseCallback()
if (mBluetoothLeAdvertiser != null) {
mBluetoothLeAdvertiser!!.startAdvertising(settings, data, mAdvertiseCallback)
}
}
}
private fun buildAdvertiseData(): AdvertiseData {
val advertisingData = AdvertiseData.Builder()
val uuid = BeaconWiliot.manufactureUuid
advertisingData.addServiceUuid(uuid)
advertisingData.setIncludeDeviceName(false)
advertisingData.addServiceData(uuid, ByteArray(20))
return advertisingData.build()
}