android BluetoothDevice.getName() return null

前端 未结 7 610
没有蜡笔的小新
没有蜡笔的小新 2020-11-28 11:37

On sometime, BluetoothDevice.getName() return null. How can i fix it? remoteDeviceName maybe null in following code. And i need distinguish my device and other devices by re

7条回答
  •  孤独总比滥情好
    2020-11-28 11:52

    I was trying to display name of my RN4020 Bluetooth module and faced the same issue. Found the problem in Microchip's forum:

    If you enabled private service or MLDP, the maximum bytes of device name is 6 bytes, due to the 31 byte advertisement payload limitation.

    I had set the device name to 9 characters. Setting the name to 4 bytes fixed the issue.

    If you recognize the UUID's of your custom services so you know its your device you can also connect to the device and read its name (if its longer than 6 bytes in my case). This was also suggested in Microchips forum.

    http://www.microchip.com/forums/m846328.aspx

提交回复
热议问题