Metawear(GPIO)
Hi Eric,
I also get some problem with the GPIO pin notification. Here is my code:
public static class PlaceholderFragment extends Fragment implements ServiceConnection {
private GPIO gpioCtrllr;
public PlaceholderFragment() {
}
public void setBtDevice(BluetoothDevice device) {
mwController= mwService.getMetaWearController(device);
mwController.setRetainState(false);
mwController.addDeviceCallback(new MetaWearController.DeviceCallbacks() {
@Override
public void connected() {
gpioCtrllr= (GPIO) mwController.getModuleController(Module.GPIO);
gpioCtrllr.setPinChangeType((byte) 10, GPIO.ChangeType.ANY);
gpioCtrllr.enablePinChangeNotification((byte) 0);
Toast.makeText(getActivity(), R.string.toast_connected, Toast.LENGTH_SHORT).show();
}
}).addModuleCallback(new GPIO.Callbacks() {
@Override
public void pinChangeDetected(byte pin, byte state) {
Log.i("MainActivity", String.format(Locale.US, "pin= %d, pin changed= %d",
pin, state));
}
});
mwController.connect();}
and the logcat show "D/BluetoothGatt﹕ onNotify() - Device=D0:98:80:5B:E7:91 UUID=326a9006-85cb-9195-d9dd-464cfbbae75a" all the time even when I press the sensor to change the voltage up to 2.5V
and how the metawear notify me when the state changed by the way.
thanks,
Mark
This discussion has been closed.
Comments
gpioCtrllr.setDigitalInput((byte) 1, PullMode.NONE);