node-ble-host icon indicating copy to clipboard operation
node-ble-host copied to clipboard

RPi4 - Error: This item does not fit, needs 18 bytes but have only 17 left

Open PhantomRay opened this issue 2 years ago • 6 comments

Hi there I have been always using this library in RPi 2 Zero with latest Raspberry Pi OS without any issues. However it always throws error when I run the same Peripheral sample code.

The error is like this

Error: This item does not fit, needs 18 bytes but have only 17 left
    at addData (/home/pi/dev/blue-test/node_modules/ble-host/lib/advertising-data-builder.js:30:10)
    at AdvertisingDataBuilder.add128BitServiceUUIDs (/home/pi/dev/blue-test/node_modules/ble-host/lib/advertising-data-builder.js:66:3)
    at /home/pi/dev/blue-test/bt.js:68:10
    at /home/pi/dev/blue-test/node_modules/ble-host/lib/ble-manager.js:2356:17
    at cont (/home/pi/dev/blue-test/node_modules/ble-host/lib/ble-manager.js:491:5)
    at /home/pi/dev/blue-test/node_modules/ble-host/lib/ble-manager.js:478:6
    at Object.callback (/home/pi/dev/blue-test/node_modules/ble-host/lib/internal/adapter.js:616:5)
    at HciSocket.onData (/home/pi/dev/blue-test/node_modules/ble-host/lib/internal/adapter.js:1174:10)
    at HciSocket.emit (node:events:526:28)
    at /home/pi/dev/blue-test/node_modules/hci-socket/lib/hci-socket.js:105:9

Am I missing anything?

PhantomRay avatar Apr 14 '22 11:04 PhantomRay

I think it's some kind of environment issue, because if I put RPi 2's microSD card into RPi 4, everything works as expected.

However I cannot figure out why.

PhantomRay avatar Apr 14 '22 11:04 PhantomRay

How does your code look like where you call the advertisement builder?

Emill avatar Apr 14 '22 13:04 Emill

It's exactly a copy and paste from README page.

PhantomRay avatar Apr 14 '22 13:04 PhantomRay

I might be wrong. I will get back to you.

PhantomRay avatar Apr 14 '22 13:04 PhantomRay

I think somehow I messed up the code.

Sorry for the false alarm.

Have a wonderful Easter!

PhantomRay avatar Apr 14 '22 13:04 PhantomRay

Hi @Emill I have found out the issue. I was using "MyDevice4" as device name and then the error pops up. Shorter name will be fine.

Any suggestions on device name length? I thought it could be longer.

PhantomRay avatar Apr 15 '22 06:04 PhantomRay

The final legacy advertisement packet can be no longer that 31 bytes. So it wasn't just the name, it was a combination of everything else.

alancnet avatar Sep 05 '22 17:09 alancnet