On My Addroid app I'm trying to add some extra data when I try to start ble advertising, and as I've read, advertise data must be <= 31 bytes.
That's how I do it:
var testData = "abcdefghij"
var data = AdvertiseData.Builder().apply {
addServiceData(
ParcelUuid(MY_UUID),
testData.toByteArray(Charsets.UTF_8)
)
}
bleAdvertiser.startAdvertising(
settings.build(),
data.build(),
advertiseCallback
)
In this way everything works well. Now if testData
fields become
var testData = "abcdefghijk"
advertising starts to fail due to exceeded advertise data size limit.
If a single char occupies 2 bytes, why if I had a string of 11 characters did I exceed the limit of 30 bytes?