调用readRemoteRssi()后BLE出现重复消息问题求助
gatt.readRemoteRssi() Causing Duplicate Data Receipt on Low-End LG/Samsung Devices Hey there, I’ve seen several developers hit this exact problem—you’re definitely not alone in facing this quirk with low-end LG and Samsung devices when calling gatt.readRemoteRssi().
From what I’ve gathered and troubleshooted with peers, this is almost always tied to buggy BLE stack implementations on these lower-spec devices. The readRemoteRssi() call seems to trigger an unexpected state in the GATT connection, which leads to the stack re-sending cached data packets repeatedly.
Here are some practical fixes that have worked for others:
- Throttle
readRemoteRssi()calls: Avoid calling this method too frequently (try setting a minimum interval of 1 second or more). Low-end BLE stacks can’t handle the extra load of frequent RSSI reads alongside regular data transfers. - Add data deduplication logic: Implement a unique identifier (like a sequence number) in your data packets. In your receive callback, check if the incoming packet’s ID has already been processed—if so, discard it immediately.
- Validate connection state pre/post call: Before and after invoking
gatt.readRemoteRssi(), check the GATT connection status usinggatt.getConnectionState(). If the state looks abnormal (e.g., disconnecting/reconnecting), re-initialize the connection to reset the stack. - Adjust MTU size: Some developers have reported success by reducing the BLE MTU size from the default (often 23) to a smaller value (like 64 or 128) on these devices. A smaller MTU reduces the processing burden on the low-end BLE stack, making it less likely to glitch when handling RSSI reads.
- Switch to passive RSSI reporting: If real-time RSSI isn’t critical, have your BLE peripheral device periodically send RSSI values as part of its regular data payload instead of relying on active
readRemoteRssi()calls. This avoids triggering the stack bug entirely.
A few folks also mentioned that updating the device’s firmware (if available) can sometimes resolve the BLE stack issues, though that’s not always an option for end-users.
内容的提问来源于stack exchange,提问作者elcuco

