Bluetooth Peripheral ADVERTISE_FAILED_DATA_TOO_LARGE

不问归期 提交于 2019-11-30 12:12:22

I suspect that this is the line of code causing the trouble:

advertiseData.setIncludeDeviceName(true);

The advertisement will not have enough space for both the device name and a 16 byte service UUID. So if you include the above then add:

advertiseData.addServiceUuid(new ParcelUuid(serviceUUID)); 

You will get the error you describe. Try removing the first line.

Atul Kumar

Basically your data exceeds 31 bytes, so you need to trim it down.

Change this to false, then it will work:

advertiseData.setIncludeDeviceName(false);

You can either change your device's name to something shorter. Example: XYZ_Name_pic - > XYZ

Go to bluetooth -> settings - > rename device name

or you can pass false instead of true

advertiseData.setIncludeDeviceName(false); // pass false not true

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!