node-ble-host
node-ble-host copied to clipboard
RPi4 - Error: This item does not fit, needs 18 bytes but have only 17 left
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?
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.
How does your code look like where you call the advertisement builder?
It's exactly a copy and paste from README page.
I might be wrong. I will get back to you.
I think somehow I messed up the code.
Sorry for the false alarm.
Have a wonderful Easter!
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.
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.