Bluetooth Peripheral ADVERTISE_FAILED_DATA_TOO_LARGE

前端 未结 3 1645
北荒
北荒 2020-12-16 15:37

I am trying to advertise in NEXUS 9 and getting the error of ADVERTISE_FAILED_DATA_TOO_LARGE. It was working perfectly fine when I was adding the service after successfully

相关标签:
3条回答
  • 2020-12-16 16:19

    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.

    0 讨论(0)
  • 2020-12-16 16:22

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

    Change this to false, then it will work:

    advertiseData.setIncludeDeviceName(false);
    
    0 讨论(0)
  • 2020-12-16 16:23

    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

    0 讨论(0)
提交回复
热议问题