Closed hurelhuyag closed 9 months ago
The advertisement data has a maximum limit with 31 bytes. You put too many bytes in the advertisement.
Note that each record in the advertisement data is a TLV(Length[1byte]+Type[1byte]+Value) structure, so the length in your code equals: 2+7(advName) + 2 + 16(uuid) + 2 + dataLength(serializedData) + 2 + 2(0x2e19) + dataLengh(serializedData), obviously it exceeded the maximum length of 31
Remove something and keep your advertisement data length less then 31 bytes and try again.
See: https://developer.android.com/reference/kotlin/android/bluetooth/le/BluetoothLeAdvertiser https://developer.apple.com/documentation/corebluetooth/cbperipheralmanager/1393252-startadvertising
@yanshouwang thanks. I didn't know that limit. But I am just curious, Why is there UUID as a option if limit is just 31 bytes.
Based on my understanding. I tried to create a minimal advertisement example. But it was not working. Here is what I did.
Setup:
Advertisement start:
But it is failing at
await peripheralManager.startAdvertising()
The output: