0x023E is the "Connection failed to be established" error. This means the master sent a connection request to the slave after seeing a connectable advertisement packet, but the slave didn't respond to the request within a very short time mandated by the BLE specification. Fundamentally, when this happens, you have to attempt the connection again.
The real cause for the 0x023E error can be difficult to pin down, but it usually occurs for one of two reasons:
>> Should I be having my python script automatically retry the connection when it fails like this?
That's correct. If and when the
connection_disconnected event happens, checking the "reason" code will tell you why it occurs, and if it is 0x023E, then you should simply retry the same connection back to the same device.
I'm using multiple BLE112 modules hooked up to a 3.3V power supply and a BLED112 connected to my computer. I've been writing a script in Python that interfaces with the BLED112 via the Python BGLib library, and I'm noticing some odd behavior. When I try connecting, occasionally I get a Disconnected event with code 0x023E (connection failed to be established). I have no idea what could be causing this error, nor do I know how to go about getting more information. What might be causing the connection to fail? Should I be having my python script automatically retry the connection when it fails like this? Any insight would be helpful.
I see! That's useful to know. The dongle and the modules both are flashed to 1.3.2-122, so I'm not sure that's the issue. I've got all three modules on a single breadboard--could that be causing issues in my environment? They're all advertising slaves, but they're in close proximity.
Having that many modules all in close proximity (especially if you are talking about millimeters or a few centimeters) may cause an issue if you are trying to establish or maintain connections with all of them simultaneously. However, the "many devices" problem which specifically causes this issue tends to be more related to having many scanning devices in the vicinity, rather than many advertising devices in the vicinity.
There is typically enough accidental or intentional (random) spread in timing between advertising packets that there will not be much or any overlap there. On the other hand, if you have three identically flash modules in the same environment which are all powered at exactly the same time, then there may a higher chance of overlap. As a test, you might try flashing only one or two of the modules with connectable firmware, and see if the problem continues.
I am seeing this issue with the BLE113-256K module. When I try and connect with BGUI from my laptop (via the BLED112) I get that error ~25% of the time.
We also sometimes fail to connect with our custom iOS app.
I am running v1.4.0-127 on the BLED112 and my BLE113