connectAsyc
Hello,
Our team is having problem in
establishing a connection with MetaWear boards after a long period of
inactivity using an Android application.
establishing a connection with MetaWear boards after a long period of
inactivity using an Android application.
When the application we are
developing is launched for the first time the user is asked to associate
3 boards with his profile. During this "pairing" procedure, we scan the
BLE devices, retrieve the MAC addresses of
the boards selected by the user and store them locally on the Android
device. After that the application connects to the board without
performing a scan but using the MAC addresses saved before as you
described in the documentation:
developing is launched for the first time the user is asked to associate
3 boards with his profile. During this "pairing" procedure, we scan the
BLE devices, retrieve the MAC addresses of
the boards selected by the user and store them locally on the Android
device. After that the application connects to the board without
performing a scan but using the MAC addresses saved before as you
described in the documentation:
// Other required imports
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
public class MainActivity extends Activity implements ServiceConnection {
private final String MW_MAC_ADDRESS= "EC:2C:09:81:22:AC";
private MetaWearBoard board;
public void retrieveBoard() {
final BluetoothManager btManager=
(BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
final BluetoothDevice remoteDevice=
btManager.getAdapter().getRemoteDevice(MW_MAC_ADDRESS);
// Create a MetaWear board object for the Bluetooth Device
board= serviceBinder.getMetaWearBoard(remoteDevice);
}
}
The aforementioned procedure
works perfectly the first time, when we previously made a scan to find
the devices. The problem we are seeing is that the boards do not
successfully connect after a long period of inactivity
(e.g. the next day); connectAsyc always fails. If we perform a BLE scan
before attempting to connect to the boards everything comes back to work
perfectly.
works perfectly the first time, when we previously made a scan to find
the devices. The problem we are seeing is that the boards do not
successfully connect after a long period of inactivity
(e.g. the next day); connectAsyc always fails. If we perform a BLE scan
before attempting to connect to the boards everything comes back to work
perfectly.
Currently, in order to get
around the problem, we perform a BLE scan of 5 seconds when the
application is started. I would like to know if this is the correct way
to handle the situation or if there is another solution
to get the result; the scan needs quite a lot of time (we tried also
with shorter scan periods but sometimes is not enough).
around the problem, we perform a BLE scan of 5 seconds when the
application is started. I would like to know if this is the correct way
to handle the situation or if there is another solution
to get the result; the scan needs quite a lot of time (we tried also
with shorter scan periods but sometimes is not enough).
Why the boards do not
respond? Do they automatically enter some sort of standby mode after a
long period of inactivity? Is there a way to understand if a board has
entered this state?
respond? Do they automatically enter some sort of standby mode after a
long period of inactivity? Is there a way to understand if a board has
entered this state?
Thanks
This discussion has been closed.
Comments
connectAsync
?getRemoteDevice
.