Bluetooth Android RFCOMM / SPP error handling suggestions

橙三吉。 提交于 2019-11-30 10:02:16

You need not worry about data corruption over SPP , Bluetooth provides 2 levels of CRC , one at the baseband and then one at the L2CAP level, Both have retransmission mechanism for any detected corruptions - thus applications will receive only good packets.

About the second question - Yes on the Socket streams that you are connected on you will receive IOExceptions if the underlying Bluetooth connections get disconnected, Android cannot handle automatic restore - typically applications need to detect the reason for disconnection and try re-connect as applicable. So if you want to continue your data exchange from the point you last successfully received / sent then for it your application should maintain some sort of sequence number and light protocol to achieve a resume. The other option is to simply start from the beaning of data exchange upon a re-connect (So it depends on your usecase)

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