Hey folks,
I'm developing a long-range application with nRF52840 DK that (optionally) uses NUS (Nordic UART Service) to send data to Samsung S10+; there is no problem establishing connection with the nRF52840 or receiving the data from 1+ km distance. It's the GATT Error 0x85 that I cannot resolve and I suspect it's behind the other random disconnections/problems. The long-range configuration was adapted from the ble-long-range samples provided by Nordic on github which uses nRF5_SDK_15.0.0. The IDE used is SES. The code from peripheral_long_range directory was used to implement Coded PHY on nRF52840 using nRF5_SDK_15.2.0. nRF Toolbox > UART is used to connect to DK.
In my application, if PHY is set to 1MBPS, the connection is established smoothly and no error is reported; on rare occasions, error 0x85 may show up, but disappears on reconnecting. Disconnecting and reconnecting to the device goes through seamlessly too.
However, when PHY is changed to Coded (from 1MBPS), GATT Error 0x13 is reported. Then, disconnecting and reconnecting to the device leads to GATT Error 0x85 which persists on all re-connection attempts.
I've tested connecting to nRF52840 DK when peripheral_long_range code is uploaded to it. Similar to results above, it connects fine when the connection is 1MBPS, but reports GATT Error 0x85 when PHY is changed to Coded.
Please see the attached images for screenshots of the scenarios above.
Based on above experiments, my conclusion at this point is that the problem is due to either a) peripheral_long_range code needing adjustment to accommodate missing settings of Coded PHY and/or b) BLE 5 implementation on Samsung S10+ is glitchy and is causing this problem. As I only have S10+ available for development purposes, I wonder if the problem persists on other Android devices (or iPhones). So, my questions are:
1) As the errors (0x85 and 0x13) are being reported on the phone only and debugging doesn't catch any errors in app_error.c > app_error_handler_bare(), I'm assuming this error is a complaint from the phone side (hence, conclusion b). Am I right in that assumption? If not, how can I debug this problem?
2) On the phone, Error 0x85 is always preceeded by the following connection state change (see image below). Is there any way I can find/debug this "Connection state" in my application code for nRF52840 DK?
3) I'm afraid I haven't found any other examples implementing Coded PHY (besides long-range-demo). Are there any examples for SDK 15.2.0 (or 15.3.0)?
The NUS part of the implementation is mentioned just in case it has some kind of impact. However, I've tested with different cases where NUS was sending data and another one where no data was being exchanged (while NUS service was still initialized). In both cases, the GATT Error 0x85 occurs only when Coded PHY is used.
I'd be happy to share anything further to debug this issue. Any help is appreciated.