Depending on the amount of noise (wireless activity), there could be interference with the BLE radio establishing the connection;
It could be that your software code is messing up :)
It could be that the peripherals are crashing/stop advertising, and thus aren't being connected to?
The problem is most likely in the details of your implementation, as the use-case you laid out doesn't seem to have any flaws in the theory.
For connecting/disconnecting: The client is initiating the connection, and then dissolving the connection when it is done. If you are connecting/disconnecting with 5 or 6 devices, then it sounds like it is something that sometimes occurs, but not conistently?
Most likely the peripherals are crashing, or the central is failing to find the advertisement packets from the peripheral, or the RSSI is not very high, and thus the connection attempt is flaky;
If you absolutely want the sequence order to remain the same, then you would want to handle connection errors with a retry or something.
If you only want a best-effort attempt, then you can just skip when a connection attempt fails, and move onto the next device in order.
Increasing your scan time/window/settings on the central, or increasing/decreasing your advertisement windows/settings on the peripherals might yield positive results. Having 7 devices advertising simultaneously could potentially cause lots of interference with wireless transmissions.
- BLE modules are very close to each other.
- Client module is scanning continuously. Server module is advertisement continuously. I am adding a png file related to the BLE connection settings. If you want to see Bluetooth Settings, you can look at the png file. I changed time/window/settings on the central-peripheral.But it was not a direct effect of the connection problem.
- There are 7 server and 1 client modules. For example, Client connects to the first 4 server modules respectively. Client could not connect to fifth module.The client sends a request to connect to the sixth server module.
- Client module can be connected to 7 server modules in general but client module can sometimes be connected to 5-6 server module. I want to solve the connection problem
- BLE Profile Custom
- Profile role Server (GATT Server)
- GAP role Peripheral and Central
Based on the connection parameters; With a possible window of 50 ms maximum, the unit could theoretically miss only 2 packets and trigger the supervision timeout event. Increasing the supervision timeout might fix the connection issue? (With 50 ms, give a retry failure of 3 in-a-row still acceptable, so set the timeout to 200 ms?)
Also, just for giggles, you could try enabling the "Duplicate Filtering" setting; This should only remove advertisements that are exactly the same as the previous advertisement packet; It might do something, but most likely nothing. (Not sure if it keeps track of very last packet, or last packet for the associated BD address)
I increased the supervision timeout but the problem was not solved.
- Can you explain the following times with a few simple examples? What are the effects in BLE. Which values should be?
Connection interval Minumum (ms) Maximum (ms)
Fast scan parameters Scan window(ms) Scan interval(ms)
BLE does some things to try to minimize EMI interference on the radio communications. The Connection interval is how often the central device will ask for data from the peripheral device (minimum 7.5 ms to maximum 4 s). Lower maximum means faster communication, but more power usage.
The scan windows for Fast Scan parameters determines how long the unit powers the radio for scanning for devices (how long the radio is active essentially), longer times are more likely to find a device, but will use power longer. The scan interval is how long it waits between each scan window. If you set the two equal, that will give you 100% scanning time and radio activity, but will use power for 100% of the time too.
Your scan parameters will only affect how fast the unit finds a new device. Having the scan window and the interval the same will be 100% scanning time. If you set the window to less than the interval, then you will get (Scan Window) / (Scan Interval) % duty cycle that the radio is actively scanning for a device's advertisements.
For the connection interval, the lower it is, the faster the communications will be, but the more power you will use. Thus, if you have a high speed data transmission that will turn off the radio when you are done, then you can set this interval lower to have the connection complete faster. However, if you are polling devices in a round-robin fashion, to slow down the communications for saving power or because you are leaving the devices connected for a long period of time, then you would want a longer connection interval.
Connection interval 7.5 ms - 50 ms is what I normally see. Fast Scan Parameters 30 ms,30 ms is also pretty normal.